2 Unknown Errors!!
#1

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.

Reply
#2

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

Huh?? whats the full line?
Reply
#4

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;
}
Reply
#5

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

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;
}
Reply
#7

Thanks!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)