Official Soldat Forums

Server Talk => Scripting Discussions and Help => Topic started by: Hacktank on December 23, 2008, 06:54:15 am

Title: GetPiece() For targeting -|> SOLVED <|-
Post 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:
Code: [Select]
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
Title: Re: GetPiece() For targeting
Post by: iDante on December 23, 2008, 07:16:16 am
GetPiece starts at 0

Code: [Select]
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.
Title: Re: GetPiece() For targeting
Post by: GSx_Major on December 23, 2008, 07:20:44 am
Shouldn't the GetPlayerStat ID be Target?
Title: Re: GetPiece() For targeting
Post by: Hacktank on December 23, 2008, 02:16:53 pm
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
Title: Re: GetPiece() For targeting -|> Still Not Working <|-
Post by: GSx_Major on December 23, 2008, 04:32:31 pm
Not that part...

Code: [Select]
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?
Title: Re: GetPiece() For targeting -|> Still Not Working <|-
Post by: iDante on December 23, 2008, 06:10:07 pm
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.
Title: Re: GetPiece() For targeting -|> Still Not Working <|-
Post by: Hacktank on December 23, 2008, 06:26:37 pm
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.