SA-MP Forums Archive
2 Unknown Errors!! - 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)
+--- Thread: 2 Unknown Errors!! (/showthread.php?tid=457304)



2 Unknown Errors!! - Mappers4Life - 10.08.2013

My friend taught me how to make a /kick command ((I suck at scripting)). We usually use ZCMD but it wasn't working so we used to default strcmp.. For some reason I get 2 errors.

Code:
Quote:

public OnPlayerCommandText(playerid, cmdtext[])
{
if (strcmp("/kick", cmdtext, true, 10) == 0)
{
new string[180], reason[80], giveplayerid;
if(sscanf(params, "us[64]", giveplayerid, reason)) return SendClientMessage(playerid, COLOR_WHITE, "COMMAND /simplekick [id] [why]");
if(!IsPlayerAdmin(playerid))
{
SendClientMessage(playerid, COLOR_WHITE, "You Are not an Admin!");
}
else
{
format(string, sizeof(string), "%s has been kicked by %s - Reason: %s", GetPlayerName(giveplayerid), GetPlayerName(playerid), reason);
SendClientMessageToAll(COLOR_WHITE, string);
Kick(giveplayerid);
}
return 1;
}
return 0;
}

Compiler:
Quote:

C:\Users\jack\Desktop\LARP\gamemodes\kicktesting.p wn(94) : warning 219: local variable "string" shadows a variable at a preceding level
C:\Users\jack\Desktop\LARP\gamemodes\kicktesting.p wn(94) : warning 219: local variable "giveplayerid" shadows a variable at a preceding level
C:\Users\jack\Desktop\LARP\gamemodes\kicktesting.p wn(95) : error 017: undefined symbol "params"
C:\Users\jack\Desktop\LARP\gamemodes\kicktesting.p wn(102) : warning 202: number of arguments does not match definition
C:\Users\jack\Desktop\LARP\gamemodes\kicktesting.p wn(102) : warning 202: number of arguments does not match definition
C:\Users\jack\Desktop\LARP\gamemodes\kicktesting.p wn(102) : warning 202: number of arguments does not match definition
C:\Users\jack\Desktop\LARP\gamemodes\kicktesting.p wn(102) : warning 202: number of arguments does not match definition
C:\Users\jack\Desktop\LARP\gamemodes\kicktesting.p wn(245) : warning 203: symbol is never used: "giveplayerid"
C:\Users\jack\Desktop\LARP\gamemodes\kicktesting.p wn(245) : warning 203: symbol is never used: "string"
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase


1 Error.




Re : 2 Unknown Errors!! - Naruto_Emilio - 10.08.2013

params is defined only if you use zcmd, you should change it to if(sscanf(cmdtext,


Re: 2 Unknown Errors!! - Mappers4Life - 11.08.2013

Huh?? whats the full line?


Re: 2 Unknown Errors!! - Dana_scully - 11.08.2013

pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
if (strcmp("/kick", cmd, true) == 0)
{
new string[180], reason[64], plid;
if(sscanf(cmdtext, "s[6]us[64]", cmd, plid, reason)) return SendClientMessage(playerid, COLOR_WHITE, "COMMAND /simplekick [id] [why]");
if(!IsPlayerAdmin(playerid))
{
SendClientMessage(playerid, COLOR_WHITE, "You Are not an Admin!");
}
else
{
format(string, sizeof(string), "%s has been kicked by %s - Reason: %s", GetPlayerName(plid), GetPlayerName(playerid), reason);
SendClientMessageToAll(COLOR_WHITE, string);
Kick(plid);
}
return 1;
}
return 0;
}



Re: 2 Unknown Errors!! - Mappers4Life - 11.08.2013

Now I get:
Quote:

C:\Users\jack\Desktop\LARP\gamemodes\kicktesting.p wn(92) : error 017: undefined symbol "cmd"
C:\Users\jack\Desktop\LARP\gamemodes\kicktesting.p wn(94) : warning 219: local variable "string" shadows a variable at a preceding level
C:\Users\jack\Desktop\LARP\gamemodes\kicktesting.p wn(95) : error 017: undefined symbol "cmd"
C:\Users\jack\Desktop\LARP\gamemodes\kicktesting.p wn(102) : warning 202: number of arguments does not match definition
C:\Users\jack\Desktop\LARP\gamemodes\kicktesting.p wn(102) : warning 202: number of arguments does not match definition
C:\Users\jack\Desktop\LARP\gamemodes\kicktesting.p wn(102) : warning 202: number of arguments does not match definition
C:\Users\jack\Desktop\LARP\gamemodes\kicktesting.p wn(102) : warning 202: number of arguments does not match definition
C:\Users\jack\Desktop\LARP\gamemodes\kicktesting.p wn(245) : warning 203: symbol is never used: "giveplayerid"
C:\Users\jack\Desktop\LARP\gamemodes\kicktesting.p wn(245) : warning 203: symbol is never used: "string"
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase


2 Errors.



Re: 2 Unknown Errors!! - Dana_scully - 11.08.2013

pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
if (strcmp("/kick", cmdtext, true, 10) == 0)
{
new string[180], reason[80], giveplayerid;
if(sscanf(cmdtext, "us[64]", giveplayerid, reason)) return SendClientMessage(playerid, COLOR_WHITE, "COMMAND /simplekick [id] [why]");
if(!IsPlayerAdmin(playerid))
{
SendClientMessage(playerid, COLOR_WHITE, "You Are not an Admin!");
}
else
{
format(string, sizeof(string), "%s has been kicked by %s - Reason: %s", GetPlayerName(giveplayerid), GetPlayerName(playerid), reason);
SendClientMessageToAll(COLOR_WHITE, string);
Kick(giveplayerid);
}
return 1;
}
return 0;
}



Re: 2 Unknown Errors!! - Mappers4Life - 11.08.2013

Thanks!