if (strcmp("/jail", cmdtext, true, 10) == 0) { SetPlayerPos(playerid,2042.7137,988.9628,10.6719); return 1; } return 0; }
I made a jail command. But when i type it, it jails me and not the player.
Код:
if (strcmp("/jail", cmdtext, true, 10) == 0) { SetPlayerPos(playerid,2042.7137,988.9628,10.6719); return 1; } return 0; } |
if (strcmp("/jail", cmdtext, true, 10) == 0) { tmp = strtok(cmdtext, idx); if(!strlen(tmp)) { SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /jail [playerid]"); return 1; } new playa; playa = ReturnUser(tmp); tmp = strtok(cmdtext, idx); if(!strlen(tmp)) { SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /jail [playerid]"); return 1; } SetPlayerPos(playa,2042.7137,988.9628,10.6719); return 1; } }
I made a jail command. But when i type it, it jails me and not the player.
Код:
if (strcmp("/jail", cmdtext, true, 10) == 0) { SetPlayerPos(playerid,2042.7137,988.9628,10.6719); return 1; } return 0; } |
new
cmd[256],
tmp[256],
idx
;
cmd = strtok(cmdtext, idx);
if(!strcmp(cmd, "/jail", true))
{
new id;
tmp = strtok(cmdtext, idx);
if(!strlen(tmp)) return SendClientMessage(playerid, 0xFF0000FF, "Usage: /jail <id>");
id = strval(tmp);
SetPlayerPos(id, 2042.7137,988.9628,10.6719);
return 1;
}
C:\Program Files\Rockstar Games\GTA San Andreas\Pawno 0.3b\filterscripts\jail.pwn(56) : error 017: undefined symbol "cmdtext" C:\Program Files\Rockstar Games\GTA San Andreas\Pawno 0.3b\filterscripts\jail.pwn(58) : error 017: undefined symbol "tmp" C:\Program Files\Rockstar Games\GTA San Andreas\Pawno 0.3b\filterscripts\jail.pwn(58) : error 017: undefined symbol "strtok" C:\Program Files\Rockstar Games\GTA San Andreas\Pawno 0.3b\filterscripts\jail.pwn(59) : warning 217: loose indentation C:\Program Files\Rockstar Games\GTA San Andreas\Pawno 0.3b\filterscripts\jail.pwn(59) : error 017: undefined symbol "tmp" C:\Program Files\Rockstar Games\GTA San Andreas\Pawno 0.3b\filterscripts\jail.pwn(60) : error 017: undefined symbol "COLOR_GRAD2" C:\Program Files\Rockstar Games\GTA San Andreas\Pawno 0.3b\filterscripts\jail.pwn(64) : error 017: undefined symbol "ReturnUser" C:\Program Files\Rockstar Games\GTA San Andreas\Pawno 0.3b\filterscripts\jail.pwn(65) : error 017: undefined symbol "tmp" C:\Program Files\Rockstar Games\GTA San Andreas\Pawno 0.3b\filterscripts\jail.pwn(65) : error 017: undefined symbol "strtok" C:\Program Files\Rockstar Games\GTA San Andreas\Pawno 0.3b\filterscripts\jail.pwn(66) : error 017: undefined symbol "tmp" C:\Program Files\Rockstar Games\GTA San Andreas\Pawno 0.3b\filterscripts\jail.pwn(67) : error 017: undefined symbol "COLOR_GRAD2" C:\Program Files\Rockstar Games\GTA San Andreas\Pawno 0.3b\filterscripts\jail.pwn(70) : warning 217: loose indentation C:\Program Files\Rockstar Games\GTA San Andreas\Pawno 0.3b\filterscripts\jail.pwn(71) : warning 217: loose indentation C:\Program Files\Rockstar Games\GTA San Andreas\Pawno 0.3b\filterscripts\jail.pwn(73) : warning 209: function "OnPlayerConnect" should return a value C:\Program Files\Rockstar Games\GTA San Andreas\Pawno 0.3b\filterscripts\jail.pwn(74) : error 010: invalid function or declaration Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase 11 Errors.
Yes, thats because you put "playerid" which means you are telling the script to jail the person typing the cmd.
You need to use strtok; or sscanf. pawn Код:
![]() |
C:\Program Files\Rockstar Games\GTA San Andreas\Pawno 0.3b\filterscripts\jail.pwn(99) : error 017: undefined symbol "strtok" C:\Program Files\Rockstar Games\GTA San Andreas\Pawno 0.3b\filterscripts\jail.pwn(99) : error 033: array must be indexed (variable "tmp") C:\Program Files\Rockstar Games\GTA San Andreas\Pawno 0.3b\filterscripts\jail.pwn(95) : warning 203: symbol is never used: "idx" C:\Program Files\Rockstar Games\GTA San Andreas\Pawno 0.3b\filterscripts\jail.pwn(92) : warning 204: symbol is assigned a value that is never used: "cmd" Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase 2 Errors.
strtok(const string[], &index)
{
new length = strlen(string);
while ((index < length) && (string[index] <= ' '))
{
index++;
}
new offset = index;
new result[20];
while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
{
result[index - offset] = string[index];
index++;
}
result[index - offset] = EOS;
return result;
}