[HELP] COP - 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: [HELP] COP (
/showthread.php?tid=69980)
[HELP] COP -
Hot - 21.03.2009
So ... I get this command from a job script:
Код:
//Variable:
new jailed[MAX_PLAYERS];
//Code at OnPlayerCommandText
if(strcmp(cmdtext, "/jail", true) == 0) {//UPDATED JAIL CMD ONlY JAILS IF THE SPECIFIED PERSON ISNT JAILED!
tmp = strtok(cmdtext, idx);
if(!strlen(tmp)) {
SendClientMessage(playerid, COLOR_GREEN, "Use: /jail [Player ID]");
return 1;
}
giveplayerid = strval(tmp);
if(jailed[giveplayerid]==0) {
if (gTeam[playerid] == COPS) {
if (IsPlayerConnected(giveplayerid)) {
GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
GetPlayerName(playerid, sendername, sizeof(sendername));
format(string, sizeof(string), "You have been jailed by officer %s!", sendername, playerid);
SendClientMessage(giveplayerid, COLOR_RED1, string);
format(string, sizeof(string), "%s has been jailed %s!", giveplayer, giveplayerid, sendername, playerid);
SendClientMessageToAll(COLOR_RED1, string);
printf(string);
SetPlayerInterior(giveplayerid,3);
jailed[giveplayerid] = 1;
SetPlayerPos(giveplayerid,198.3797,160.8905,1003.0300);
SetPlayerFacingAngle(giveplayerid,177.0350);
SetCameraBehindPlayer(giveplayerid);
PlayerPlaySound(giveplayerid,1082,198.3797,160.8905,1003.0300);
TogglePlayerControllable(giveplayerid,0); //So the player that is jailed can't use /kill
DisablePlayerCheckpoint(giveplayerid);
return 1;
}else{
format(string, sizeof(string), "ID %d is not connected.", giveplayerid);
SendClientMessage(playerid, COLOR_YELLOW, string);
}
}else{
format(string, sizeof(string), "You are not a cop", giveplayerid);
SendClientMessage(playerid, COLOR_YELLOW, string);
}
}else{
format(string, sizeof(string), "He/She is already jailed", giveplayerid);
SendClientMessage(playerid, COLOR_YELLOW, string);
}
}
NEW ERRORS:
Код:
C:\Documents and Settings\Gustavo\Desktop\samp02Xserver.win32\pawno\include\Seifader.inc(71) : warning 203: symbol is never used: "reason"
C:\DOCUME~1\Gustavo\Desktop\SAMP02~1.WIN\GAMEMO~1\LVCNR.pwn(325) : error 017: undefined symbol "strtok"
C:\DOCUME~1\Gustavo\Desktop\SAMP02~1.WIN\GAMEMO~1\LVCNR.pwn(325) : error 033: array must be indexed (variable "cmd")
C:\DOCUME~1\Gustavo\Desktop\SAMP02~1.WIN\GAMEMO~1\LVCNR.pwn(417) : error 017: undefined symbol "strtok"
C:\DOCUME~1\Gustavo\Desktop\SAMP02~1.WIN\GAMEMO~1\LVCNR.pwn(417) : error 033: array must be indexed (variable "tmp")
C:\DOCUME~1\Gustavo\Desktop\SAMP02~1.WIN\GAMEMO~1\LVCNR.pwn(428) : error 017: undefined symbol "giveplayer"
C:\DOCUME~1\Gustavo\Desktop\SAMP02~1.WIN\GAMEMO~1\LVCNR.pwn(428) : error 017: undefined symbol "giveplayer"
C:\DOCUME~1\Gustavo\Desktop\SAMP02~1.WIN\GAMEMO~1\LVCNR.pwn(428) : error 029: invalid expression, assumed zero
C:\DOCUME~1\Gustavo\Desktop\SAMP02~1.WIN\GAMEMO~1\LVCNR.pwn(428) : fatal error 107: too many error messages on one line
Compilation aborted.Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase
8 Errors.
AND FINALLY THE ERROR LINES :
Код:
409 = tmp = strtok(cmdtext, idx);
410 = if(!strlen(tmp)) {
414 = giveplayerid = strval(tmp);
416 = if(jailed[giveplayerid]==0) {
418 = if (IsPlayerConnected(giveplayerid)) {
420 = GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
COULD YOU HELP ME ?
Re: [HELP] COP -
MenaceX^ - 21.03.2009
Seems like you dont' have strtok..
Re: [HELP] COP -
Hot - 21.03.2009
Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
new string[256];
new cmd[256];
new idx;
cmd = strtok(cmdtext, idx);
new tmp[256];
new giveplayerid;
??
Yes, if strtok is that i have ...
Re: [HELP] COP -
Pghpunkid - 21.03.2009
Do you have the strtok function? Or is that it?
Re: [HELP] COP -
Rks25 - 21.03.2009
Did you define strtok function? Else we will continue like this, read how replied to Menace.
You did use it, but did you define it?
Re: [HELP] COP -
MenaceX^ - 22.03.2009
pawn Код:
//Add this somewhere.
strtok(const string[], &index, separator = ' ')
{
new length = strlen(string);
while ((index < length) && (string[index] <= separator))
{
index++;
}
new offset = index;
new result[20];
while ((index < length) && (string[index] > separator) && ((index - offset) < (sizeof(result) - 1)))
{
result[index - offset] = string[index];
index++;
}
result[index - offset] = EOS;
return result;
}