Author Topic: GetPiece help  (Read 1215 times)

0 Members and 1 Guest are viewing this topic.

Offline Spasman

  • Major
  • *
  • Posts: 55
GetPiece help
« on: July 10, 2007, 05:41:00 pm »
I'm making an invite system, where if the player types "/invite <playerID>" he invites that player ID to his team. GetPiece is not being too cooperative in this, here's the code, it's quite simple:

Code: [Select]
if Text = '/invite' then begin
     if GetPlayerStat(ID,'team') = 4 then begin
         SayToPlayer(ID,'Invite sent to '+IDToName(GetPiece(Text, ' ', 1)));
         SayToPlayer(GetPiece(Text, ' ', 1),'You have been anonymously invited to delta team.');
         SayToPlayer(GetPiece(Text, ' ', 1),'Type /canijoin to join.');
     end;
end;

The it has a "Type mismatch" error with the GetPiece(Text, ' ', 1) at most...
Anything you see wrong there? I'm stumped...
« Last Edit: July 10, 2007, 05:46:15 pm by Spasman »

Offline EnEsCe

  • Retired Soldat Developer
  • Flamebow Warrior
  • ******
  • Posts: 3101
  • http://enesce.com/
    • [eC] Official Website
Re: GetPiece help
« Reply #1 on: July 10, 2007, 10:33:10 pm »
GetPiece returns a string, the first parameter of SayToPlayer is a byte. You need to do
strtoint(GetPiece(Text, ' ', 1))

Offline Spasman

  • Major
  • *
  • Posts: 55
Re: GetPiece help
« Reply #2 on: July 11, 2007, 10:13:54 pm »
Oh awesome, I'm not too good with programming parameter types.

Thanks.
« Last Edit: July 14, 2007, 09:25:44 pm by Spasman »

Offline urraka

  • Soldat Developer
  • Flagrunner
  • ******
  • Posts: 703
Re: GetPiece help
« Reply #3 on: July 11, 2007, 10:43:54 pm »
You're too good? xD

Also, when you do
Code: [Select]
if Text = '/invite' then begin
I think it only evaluates to true if the complete text is just '/invite'. So i would do this way:
Code: [Select]
if GetPiece(Text, ' ', 0) = '/invite' then begin
urraka

Offline zyxstand

  • Veteran
  • *****
  • Posts: 1106
  • Mother of all Bombs
Re: GetPiece help
« Reply #4 on: July 12, 2007, 12:10:29 am »
also, i heard that it's better to use GetPlayerStat(ID,'Name') instead of IDToName(ID)....
Can't think of anything original to put here...

Offline Spasman

  • Major
  • *
  • Posts: 55
Re: GetPiece help
« Reply #5 on: July 14, 2007, 09:28:20 pm »
oops, not too good i mean ;[

yeah thanks, its working now