Author Topic: GetPiece() For targeting -|> SOLVED <|-  (Read 1299 times)

0 Members and 1 Guest are viewing this topic.

Offline Hacktank

  • Camper
  • ***
  • Posts: 462
  • Soldat Scripter
    • HTZRPG
GetPiece() For targeting -|> SOLVED <|-
« 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
« Last Edit: December 23, 2008, 06:29:49 pm by Hacktank »


Offline iDante

  • Veteran
  • *****
  • Posts: 1967
Re: GetPiece() For targeting
« Reply #1 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.

Offline GSx_Major

  • Major
  • *
  • Posts: 97
Re: GetPiece() For targeting
« Reply #2 on: December 23, 2008, 07:20:44 am »
Shouldn't the GetPlayerStat ID be Target?
...and headbutt the sucker through your banana suit!

Offline Hacktank

  • Camper
  • ***
  • Posts: 462
  • Soldat Scripter
    • HTZRPG
Re: GetPiece() For targeting
« Reply #3 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

@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
« Last Edit: December 23, 2008, 03:27:42 pm by Hacktank »


Offline GSx_Major

  • Major
  • *
  • Posts: 97
Re: GetPiece() For targeting -|> Still Not Working <|-
« Reply #4 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?
...and headbutt the sucker through your banana suit!

Offline iDante

  • Veteran
  • *****
  • Posts: 1967
Re: GetPiece() For targeting -|> Still Not Working <|-
« Reply #5 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
Don't trust any of the examples on that page, figure them out yourself. Same goes for any of those functions really.

Offline Hacktank

  • Camper
  • ***
  • Posts: 462
  • Soldat Scripter
    • HTZRPG
Re: GetPiece() For targeting -|> Still Not Working <|-
« Reply #6 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.