Official Soldat Forums
Server Talk => Scripting Discussions and Help => Topic started by: Hacktank on December 23, 2008, 06:54:15 am
-
I am trying to make my functions such as /flamer work as /flamer //self and /flamer <id> but I cannot get GetPeice to work rite, if I use this:
function OnCommand(ID: byte; text: string): boolean;
begin
If GetPiece(text,' ',2) <> Nil Then target := StrToInt(GetPiece(text,' ',2)) Else Target := ID
if GetPiece(text,' ',1) = '/flamer' then begin
ForceWeapon(target,11,GetPlayerstat(ID,'secondary'),0);
end;
end;
but it will not work. What am I doing wrong?
EDIT: It only works 1 out of 20 times if you specify an id.. wtf
-
GetPiece starts at 0
function OnCommand(ID: byte; text: string): boolean;
begin
If GetPiece(text,' ',1) <> Nil Then target := StrToInt(GetPiece(text,' ',1)) Else Target := ID
if GetPiece(text,' ',0) = '/flamer' then begin
ForceWeapon(target,11,GetPlayerstat(ID,'secondary'),0);
end;
end;
Should work.
-
Shouldn't the GetPlayerStat ID be Target?
-
Thanks iDante! But whats with the example on enesce help? http://enesce.com/help/html/Functions/GetPiece.html (http://enesce.com/help/html/Functions/GetPiece.html)
@GSx_Major:
The target is supposed to be the one who used the command if they dont specify an id, so admins can give things to others.
EDIT: It only works 1 out of 20 times if you specify an id.. wtf
-
Not that part...
ForceWeapon(Target, 11, GetPlayerstat(ID, 'Secondary'), 0);
If an admin uses it on someone else, they will get a flamer and the same secondary as the admin.
Was that what you intended?
-
Thanks iDante! But whats with the example on enesce help? http://enesce.com/help/html/Functions/GetPiece.html (http://enesce.com/help/html/Functions/GetPiece.html)
Don't trust any of the examples on that page, figure them out yourself. Same goes for any of those functions really.
-
Well major I have mana simalar commands such as pred vest rage(scripted-statcks) and more to come. The only ones that will get them banned are /falmer and /bow. Thanks for the help.