/kick command won't work.
#1

Hello everyone, recently I was trying to create a simple /kick command and I am having some trouble with it.

So here how it looks like:

pawn Код:
CMD:kick(playerid, params[]);
{
    new targetid;
    new reason[50];
    new string[200];
    if(!IsPlayerAdmin(playerid))return SendClientMessage(playerid, COLOR_RED, "**[ERROR]** {FFFFFF}- You are {FF0000}not logged{FFFFFF} in as {FF8921}RCON{FFFFFF} Administrator.");
    if(!IsPlayerConnected(targetid))return SendClientMessage(playerid, COLOR_RED, "**[ERROR]** {FFFFFF}- The player is {FF0000}not connected{FFFFFF} at the moment.");
    if(sscanf(params, "us[50]", targetid, reason))return SendClientMessage(playerid, COLOR_WHITE, "Usage:{FFFFFF} /kick {FF8921}[{FFFFFF}ID{FF8921}] {FF8921}[{FFFFFF}REASON{FF8921}]{FF8921}");
    format(string, sizeof(string), "**[SERVER]** {FFFFFF}- {FF8921}Administrator %s[ID:%d]{FFFFFF} has {FF0000}kicked{FFFFFF} {FF8921}%s[ID:%d]{FFFFFF}, [{FF8921}Reason:{FFFFFF} %s]", GetName(playerid), playerid, GetName(targetid), targetid, reason);
    SendClientMessageToAll(COLOR_ORANGE, string);
    Kick(targetid);
    return 1;
}
And here are the errors I get:

pawn Код:
C:\Users\Arty\Desktop\Hazard Gaming\pawno\include\YSI\y_utils.inc(343) : warning 219: local variable "string" shadows a variable at a preceding level
C:\Users\Arty\Desktop\Hazard Gaming\pawno\include\YSI\y_utils.inc(497) : warning 219: local variable "string" shadows a variable at a preceding level
C:\Users\Arty\Desktop\Hazard Gaming\pawno\include\YSI\y_utils.inc(540) : warning 219: local variable "string" shadows a variable at a preceding level
C:\Users\Arty\Desktop\Hazard Gaming\pawno\include\YSI\y_utils.inc(558) : warning 219: local variable "string" shadows a variable at a preceding level
C:\Users\Arty\Desktop\Hazard Gaming\pawno\include\YSI\y_malloc.inc(216) : warning 219: local variable "string" shadows a variable at a preceding level
C:\Users\Arty\Desktop\Hazard Gaming\pawno\include\YSI\y_hooks/impl.inc(654) : warning 219: local variable "reason" shadows a variable at a preceding level
C:\Users\Arty\Desktop\Hazard Gaming\pawno\include\YSI\y_hooks/impl.inc(746) : warning 219: local variable "reason" shadows a variable at a preceding level
C:\Users\Arty\Desktop\Hazard Gaming\pawno\include\mSelection.inc(698) : warning 219: local variable "string" shadows a variable at a preceding level
C:\Users\Arty\Desktop\Hazard Gaming\pawno\include\streamer.inc(293) : warning 219: local variable "reason" shadows a variable at a preceding level
C:\Users\Arty\Desktop\Hazard Gaming\pawno\include\sscanf2.inc(224) : warning 219: local variable "reason" shadows a variable at a preceding level
C:\Users\Arty\Desktop\Hazard Gaming\pawno\include\sscanf2.inc(305) : warning 219: local variable "string" shadows a variable at a preceding level
C:\Users\Arty\Desktop\Hazard Gaming\pawno\include\sscanf2.inc(305) : warning 219: local variable "string" shadows a variable at a preceding level
C:\Users\Arty\Desktop\Hazard Gaming\pawno\include\sscanf2.inc(365) : warning 219: local variable "string" shadows a variable at a preceding level
C:\Users\Arty\Desktop\Hazard Gaming\pawno\include\sscanf2.inc(365) : warning 219: local variable "string" shadows a variable at a preceding level
C:\Users\Arty\Desktop\Hazard Gaming\gamemodes\hzg.pwn(555) : warning 219: local variable "reason" shadows a variable at a preceding level
C:\Users\Arty\Desktop\Hazard Gaming\gamemodes\hzg.pwn(793) : warning 219: local variable "reason" shadows a variable at a preceding level
C:\Users\Arty\Desktop\Hazard Gaming\gamemodes\hzg.pwn(1109) : error 055: start of function body without function header
C:\Users\Arty\Desktop\Hazard Gaming\gamemodes\hzg.pwn(1113) : error 010: invalid function or declaration
C:\Users\Arty\Desktop\Hazard Gaming\gamemodes\hzg.pwn(1114) : error 010: invalid function or declaration
C:\Users\Arty\Desktop\Hazard Gaming\gamemodes\hzg.pwn(1115) : error 010: invalid function or declaration
C:\Users\Arty\Desktop\Hazard Gaming\gamemodes\hzg.pwn(1119) : error 010: invalid function or declaration
C:\Users\Arty\Desktop\Hazard Gaming\gamemodes\hzg.pwn(1888) : warning 203: symbol is never used: "reason"
C:\Users\Arty\Desktop\Hazard Gaming\gamemodes\hzg.pwn(1888) : warning 203: symbol is never used: "string"
C:\Users\Arty\Desktop\Hazard Gaming\gamemodes\hzg.pwn(1888) : warning 203: symbol is never used: "targetid"
Pawn compiler 3.2.3664          Copyright (c) 1997-2006, ITB CompuPhase


5 Errors.
And I got not a single idea what may cause that..
Thanks in advance.
Reply
#2

Let's start by removing the ';' at the end of
pawn Код:
CMD:kick(playerid, params[]);
Reply
#3

pawn Код:
CMD:kick(playerid, params[]);
Change to:
pawn Код:
CMD:kick(playerid, params[])
reason is declared as global variable. Just change to:
pawn Код:
new
    reason_[ 50 ],
    string_[ 128 ]
;
PS: Don't forget to replace them in the command too.
Reply
#4

Quote:
Originally Posted by Jstylezzz
Посмотреть сообщение
Let's start by removing the ';' at the end of
pawn Код:
CMD:kick(playerid, params[]);
Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
pawn Код:
CMD:kick(playerid, params[]);
Change to:
pawn Код:
CMD:kick(playerid, params[])
reason is declared as global variable. Just change to:
pawn Код:
new
    reason_[ 50 ],
    string_[ 128 ]
;
PS: Don't forget to replace them in the command too.
Thanks guys, fixed it.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)