Kicks ID 0 instead of the ID typed -
lewismichaelbbc - 03.03.2012
when i type /kick 8 Reason, it kicks ID 0. Why does this happen?
pawn Code:
CMD:kick(playerid, params[]) //using ZCMD this is how your command will start off looking like.
{
if(PlayerInfo[playerid][pAdmin] >= 1)
{
SendClientMessage(playerid,COLOR_YELLOW,"Your admin level is not high enough to use this command");
return 1;
}
new adminname[MAX_PLAYER_NAME],otherplayerid,pname[24], reason[128];
GetPlayerName(otherplayerid,pname,sizeof(pname));
GetPlayerName(playerid,adminname,sizeof(adminname));
if(sscanf(params, "uz", otherplayerid, reason))
SendClientMessage(playerid, 0xFFFFFFFF, "/kick [playerid/name] [reason]");
else if(otherplayerid == INVALID_PLAYER_ID)
SendClientMessage(playerid, 0xFFFFFFFF, "This player is not connected");
else
{
new string[250];
format(string, sizeof(string), "Admin %s kicked %s | Reason: %s",adminname,pname, reason);
SendClientMessageToAll(0xFFFFFFFF,string);
Kick(otherplayerid);
}
return 1;
}
Re: Kicks ID 0 instead of the ID typed -
Twisted_Insane - 03.03.2012
Hmm, I'd suggest you to take mine, I don't have too much time to read your whole CMD! ^^
pawn Code:
CMD:kick(playerid, params[])
{
if(PlayerInfo[playerid][pAdmin] >= 3) {
new PID;
new reason[64];
new str[128];
new Playername[MAX_PLAYER_NAME], Adminname[MAX_PLAYER_NAME];
GetPlayerName(playerid, Adminname, sizeof(Adminname));
GetPlayerName(PID, Playername, sizeof(Playername));
if(sscanf(params, "us[64]", PID,reason)) return SendClientMessage(playerid, COLOR_GREY, "USAGE: /kick [playerid] [reason]");
if(!IsPlayerConnected(PID))
return SendClientMessage(playerid, COLOR_GREY, "Player is not connected!");
format(str, sizeof(str), "'%s' has been kicked by administrator '%s'. Reason: %s ", Playername, Adminname, reason);
SendClientMessageToAll(COLOR_RED, str);
Kick(PID);
}
else
{
SendClientMessage(playerid, COLOR_GREY, "You have to be level 3 to use that command!");
}
return 1;
}
Re: Kicks ID 0 instead of the ID typed -
2KY - 03.03.2012
If I remember correctly, 'z' as a sscanf parameter was removed and replaced. Take a look at the sscanf release topic again, and please for the love of god space your commands out more so they're readable.
Re: Kicks ID 0 instead of the ID typed -
Nuke547 - 03.03.2012
Try this
pawn Code:
CMD:kick(playerid, params[]) //using ZCMD this is how your command will start off looking like.
{
if(PlayerInfo[playerid][pAdmin] < 1)
{
SendClientMessage(playerid,COLOR_YELLOW,"Your admin level is not high enough to use this command");
return 1;
}
else
{
new adminname[MAX_PLAYER_NAME],otherplayerid,pname[24], reason[128];
if(sscanf(params, "uz", otherplayerid, reason))
{
SendClientMessage(playerid, 0xFFFFFFFF, "/kick [playerid/name] [reason]");
}
else
{
GetPlayerName(otherplayerid,pname,sizeof(pname));
GetPlayerName(playerid,adminname,sizeof(adminname));
new string[250];
format(string, sizeof(string), "Admin %s kicked %s | Reason: %s",adminname,pname, reason);
SendClientMessageToAll(0xFFFFFFFF,string);
Kick(otherplayerid);
}
}
return 1;
}
Re: Kicks ID 0 instead of the ID typed -
Twisted_Insane - 03.03.2012
I already posted one, which includes everything exactly he wants!
Re: Kicks ID 0 instead of the ID typed -
lordturhan - 03.03.2012
This happens to me too this is because sscanf and its pretty annoying.
I updated to sscanf 2.5 today lets see if it will get fix'd
Re: Kicks ID 0 instead of the ID typed -
Walsh - 03.03.2012
This is indeed a plugin problem, not a scripting problem. The command is fine.
Re: Kicks ID 0 instead of the ID typed -
lewismichaelbbc - 03.03.2012
Checked the log and get this message: [22:25:21] sscanf warning: Strings without a length are deprecated, please add a destination size.
How can i add a destination size?
Re: Kicks ID 0 instead of the ID typed -
Walsh - 03.03.2012
Instead of using
as your specifiers. Use
Your sscanf line should look like this
pawn Code:
if(sscanf(params, "us[128]", otherplayerid, reason))
Don't use "z" it is a depreciated specifier.
Re: Kicks ID 0 instead of the ID typed -
Twisted_Insane - 03.03.2012
pawn Code:
if(sscanf(params, "us[128]", otherplayerid, reason))