Author Topic: another script problem  (Read 1592 times)

0 Members and 3 Guests are viewing this topic.

Offline chutem

  • Veteran
  • *****
  • Posts: 1119
another script problem
« on: November 21, 2007, 12:40:24 am »
Made another simple script:

Code: [Select]
procedure OnWeaponChange(ID, PrimaryNum, SecondaryNum: Byte);
begin
  Sleep (2000);
  ForceWeapon(ID,14,14,0);
end;

I assume that the 'ID' in the brackets for OnWeaponChange is declaring a variable so that means in my understanding this script should give a player a knew knife everytime they throw it (and select it or switch weapon or pick one up).
Its a script so I don't have to find knives when I play against throwing knives bots.
But
The script doesn't compile (i think) in the log file it says:
07-11-21 18:33:11 
  • Knives script -> [Error] (4:3): Identifier expected


So, yeah, thats the problem.

Help will be appreciated  ;D
« Last Edit: November 21, 2007, 10:01:56 pm by chutem »
1NK3FbdNtH6jNH4dc1fzuvd4ruVdMQABvs

Offline Toumaz

  • Veteran
  • *****
  • Posts: 1904
Re: another script problem
« Reply #1 on: November 21, 2007, 12:44:27 am »
Code: [Select]
procedure OnWeaponChange(ID, PrimaryNum, SecondaryNum: Byte);
begin
  ForceWeapon(ID,12,12,0);
end;

12 is rambo bows by the way, so you probably want to use 14 instead.

Offline chutem

  • Veteran
  • *****
  • Posts: 1119
Re: another script problem
« Reply #2 on: November 21, 2007, 12:59:12 am »
?? its number 12 in weapon select, oh wait, I saw this in the default scripts,
Changed script.
1NK3FbdNtH6jNH4dc1fzuvd4ruVdMQABvs

Offline EnEsCe

  • Retired Soldat Developer
  • Flamebow Warrior
  • ******
  • Posts: 3101
  • http://enesce.com/
    • [eC] Official Website
Re: another script problem
« Reply #3 on: November 21, 2007, 02:25:33 am »
get rid of the Procedure before ForceWeapon.

Offline chutem

  • Veteran
  • *****
  • Posts: 1119
Re: another script problem
« Reply #4 on: November 21, 2007, 02:57:33 am »
F***, stupid little mistakes.

So for events i need the procedure, but for functions i can't have it.
thanks.

EDIT: Hahahahahah lol that is so cool, but if I throw too many knives, I get kicked for possible cheat.
EDIT2: added sleep to delay new knife
« Last Edit: November 21, 2007, 03:08:27 am by chutem »
1NK3FbdNtH6jNH4dc1fzuvd4ruVdMQABvs

Offline urraka

  • Soldat Developer
  • Flagrunner
  • ******
  • Posts: 703
Re: another script problem
« Reply #5 on: November 21, 2007, 12:21:49 pm »
So for events i need the procedure, but for functions i can't have it.
thanks.

The "procedure" or "function" words are used only in the definition of the procedure/function. When you call it you don't write it.
urraka

Offline Kavukamari

  • Camper
  • ***
  • Posts: 435
  • 3.14159265358979, mmm... pi
Re: another script problem
« Reply #6 on: November 21, 2007, 12:58:52 pm »
and there is a space after Sleep

Quote
Sleep (2000)

and there should be a ';' after sleep() and forceweapon()
"Be mindful of fame, show a mighty courage, watch against foes. Nor shalt thou lack what thou desirest, if with thy life thou hast comest out from that heroic task."

Offline chutem

  • Veteran
  • *****
  • Posts: 1119
Re: another script problem
« Reply #7 on: November 21, 2007, 10:01:31 pm »
ok, changed

EDIT: Could that be causing lag between me and the server, because thats what I was getting?, like massive red cirles at the top-right.
« Last Edit: November 21, 2007, 10:03:28 pm by chutem »
1NK3FbdNtH6jNH4dc1fzuvd4ruVdMQABvs

Offline EnEsCe

  • Retired Soldat Developer
  • Flamebow Warrior
  • ******
  • Posts: 3101
  • http://enesce.com/
    • [eC] Official Website
Re: another script problem
« Reply #8 on: November 21, 2007, 10:55:00 pm »
Sleep will make the server sleep for 2 seconds. So yes, you will get 2 seconds of lag.

Offline chutem

  • Veteran
  • *****
  • Posts: 1119
Re: another script problem
« Reply #9 on: November 22, 2007, 09:54:00 pm »
oh. How do I make the script not force a knife for 2 seconds withought stopping the server then?
1NK3FbdNtH6jNH4dc1fzuvd4ruVdMQABvs

Offline Toumaz

  • Veteran
  • *****
  • Posts: 1904
Re: another script problem
« Reply #10 on: November 23, 2007, 02:52:25 am »
oh. How do I make the script not force a knife for 2 seconds withought stopping the server then?
Something along the lines of creating an array sized for all players, set the value of the player ID index in said array to 2 when you give the player a knife, and decrease it down to 0 in AppOnIdle.  Then only allow ForceWeapon to be used when said variable is 0.  Yes, I suck at explaining things properly.

Offline KwS Pall

  • Major(1)
  • Posts: 49
  • I'm going to write Tibia for Soldat
Re: another script problem
« Reply #11 on: November 23, 2007, 08:23:32 am »
Code: [Select]
var
weapon[1..32] of byte;

Procedure AppOnIdle(Ticks:integer);
var
i : byte;
begin
for i := 1 to 32 do begin
 if weapon[i] = 0 then ForceWeapon(i,14,14,0);
 if (weapon[i] < 3) and (weapon[i] > 0) then weapon[i] := weapon[i] -1;
 end;
end;

procedure OnWeaponChange(ID, PrimaryNum, SecondaryNum: Byte);
begin
weapon[id] := 2;
end;

try this one, it should work but i haven't got client to test it
I'm going to write Tibia for Soldat