SA-MP Forums Archive
strtok problem - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: strtok problem (/showthread.php?tid=87177)



strtok problem - Pawno_Master - 18.07.2009

What's wrong with this strtok command?

Код:
 	new tmp[128], string[128], cmd[128], idx, giveplayerid, sendername, giveplayer;
  cmd = strtok(cmdtext, idx);
  GetPlayerName(playerid, sendername, sizeof(sendername));
	if(strcmp(cmd, "/cuff", true) == 0)
	{
  if(gTeam[playerid] != TEAM_COPS){ return SendClientMessage(playerid, 0x919191FF, "BE ADMIN!");} // when player isn't admin, don't let to use command
  tmp = strtok(cmdtext, idx); // We assign that we use strtok in this command to 'tmp'
  if(!strlen(tmp)) return SendClientMessage(playerid, oranje, "USAGE: /cuff [id]"); // If no ID is given
  giveplayerid = strval(tmp); // Now we assign the 'giveplayerid'
  if(!IsPlayerConnected(giveplayerid)) return SendClientMessage(playerid, donkerrood, "That player doesn't exist"); // when 'giveplayerid' isn't online
	TogglePlayerControllable(playerid, 0);
  return 1;
	}
i get these errors and warnings

Код:
C:\Gta Sa Server Vernieuwd\gamemodes\freeroam.pwn(1616) : error 047: array sizes do not match, or destination array is too small
C:\Gta Sa Server Vernieuwd\gamemodes\freeroam.pwn(1617) : error 035: argument type mismatch (argument 2)
C:\Gta Sa Server Vernieuwd\gamemodes\freeroam.pwn(1617) : error 035: argument type mismatch (argument 2)
C:\Gta Sa Server Vernieuwd\gamemodes\freeroam.pwn(1621) : error 047: array sizes do not match, or destination array is too small
C:\Gta Sa Server Vernieuwd\gamemodes\freeroam.pwn(1615) : warning 203: symbol is never used: "giveplayer"
C:\Gta Sa Server Vernieuwd\gamemodes\freeroam.pwn(1615) : warning 203: symbol is never used: "sendername"
C:\Gta Sa Server Vernieuwd\gamemodes\freeroam.pwn(1615) : warning 204: symbol is assigned a value that is never used: "string"
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


4 Errors.
i know that if i use that command
cops can cuff anyone including cops and that they can cuff everybody with no problem with distance so the can cuff someone is the someone isn; t close to the cop

but i dont know how that works
im still learning and searching on that


Re: strtok problem - yom - 18.07.2009

Just use sscanf instead.


Re: strtok problem - Pawno_Master - 18.07.2009

i dont know anything about sscanf

any tut of it around here??

nothing found on wiki only a code



Re: strtok problem - yom - 18.07.2009

You must be kidding.

https://sampwiki.blast.hk/wiki/Fast_Commands#sscanf


Re: strtok problem - Pawno_Master - 18.07.2009

wtf -.-

anyway thanks alot


Re: strtok problem - yom - 18.07.2009

No problem.


Re: strtok problem - GTA967 - 18.07.2009

to get rid of thoes array errors try chaning the sizes to 256


Re: strtok problem - coole210 - 18.07.2009

pawn Код:
TogglePlayerControllable(playerid, 0);
Lol why would you set a strval if the person who does command gets cuffed :S


Re: strtok problem - ledzep - 18.07.2009

Quote:
Originally Posted by ekeleke
i dont know anything about sscanf
You don't know much about strtok either :P

If you learn SSCANF, you will love it.