Official Soldat Forums
Server Talk => Scripting Discussions and Help => Topic started by: VinceBros on December 08, 2009, 07:45:09 pm
-
Hi again guys, lol.
I work badly in a script, and an error has just popped in my face and it seems like i can't fix it.
I'm not so good explaining so i'm just gonna show you the pieces of script.
Huuh... an exemple :
var
Random : byte;
SomeoneGotId : boolean;
procedure OnPlayerSpeak(ID: Byte; Text: string)
begin
if Text = '!getid' then begin
Random := ID;
SomeoneGotId := true;
end;
if Text = '!giveid' then begin
Random := 0;
SomeoneGotId := false;
end;
end;
procedure OnLeaveGame(ID, Team: byte;Kicked: boolean);
begin
if (SomeoneGotId = true) and (Random = ID) then begin
Random := 0;
SomeoneGotId := false;
end;
end;
function OnPlayerCommand(ID: Byte; Text: string): boolean;
begin
// Test to see who got the Random id
if Text = '/whogotid' then begin
WriteConsole(ID, 'Random = ' + IDToName(Random),$FFFF0000);
end;
end;
Here is the problem. In the other procedures than OnPlayerSpeak, the Random variable is 255 and it displays : Random = Server Admin.
What is the problem ?
Thanks for solving it.
EDIT: FIXED AN ERROR IN THE EXEMPLE
-
Here is the problem. In the other procedures than OnPlayerSpeak, the Random variable is 255 and it displays : Random = Server Admin.
What is the problem ?
255 is server admin's ID, if you use this variable for other functions, rename this one so they won't collide?
-
Try renaming the variable to RandomX(in example..), also you don't need SomeoneGotId, just compare Random with 0.
-
Mmh, you don't see to understand my problem.
The Random Var in OnPlayerSpeak has the value of the ID.
But in the other functions it's the server admin, which should be the ID in OnPlayerSpeak
-
Maybe first try and then say I'm wrong?
-
Well my variable name in the script is not Random.
In the exemple, Yes. But i fixed problem :). Thanks anyway.