strtok problem
#1

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
Reply
#2

Just use sscanf instead.
Reply
#3

i dont know anything about sscanf

any tut of it around here??

nothing found on wiki only a code
Reply
#4

You must be kidding.

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

wtf -.-

anyway thanks alot
Reply
#6

No problem.
Reply
#7

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

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

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.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)