Wrong with my kick + ban command. -
BizzyD - 12.04.2011
Hello, there is something wrong with my kick + ban command. When i attemp to kick/ban someone. Nothing happends. And the name gets really weird.
This is my codes
pawn Код:
CMD:kick(playerid,params[])
{
new id,reason;
if(PlayerInfo[playerid][pAdminLevel] < 1) return SendClientMessage(playerid,COLOR_RED,"You've To Be Admin To Use This Command");
else if(sscanf(params,"us",id,reason)) return SendClientMessage(playerid,COLOR_RED,"Usage : /kick [playerid] [Reason]");
else if(id == INVALID_PLAYER_ID) return SendClientMessage(playerid,COLOR_RED,"Player Doesn't Exist");
else
{
new pName[24],name[24];
GetPlayerName(playerid,pName,24);
GetPlayerName(id,name,24);
new string[128];
format(string,128,"You've Kicked %s ,, Reason : %s",name,reason);
SendClientMessage(playerid,COLOR_YELLOW,string);
format(string,128,"You've Been Kicked By %s ,, Reason : %s",pName,reason);
SendClientMessage(id,COLOR_RED,string);
format(string,128,"Admin %s Kicked %s ,, Reason : %s",pName,id,reason);
SendClientMessageToAll(COLOR_YELLOW,string);
Kick(id);
format(string,sizeof(string),"%s Kicked %s ,, Reason : %s",pName,name,reason);
SaveIn("KickLog.txt",string);
}
return 1;
}
CMD:ban(playerid,params[])
{
new id,reason;
if(PlayerInfo[playerid][pAdminLevel] < 1) return SendClientMessage(playerid,COLOR_RED,"You've To Be Admin To Use This Command");
else if(sscanf(params,"us",id,reason)) return SendClientMessage(playerid,COLOR_RED,"Usage : /ban [playerid] [Reason]");
else if(id == INVALID_PLAYER_ID) return SendClientMessage(playerid,COLOR_RED,"Player Doesn't Exist");
else
{
new pName[24],name[24];
GetPlayerName(playerid,pName,24);
GetPlayerName(id,name,24);
new string[128];
format(string,128,"You've Banned %s ,, Reason : %s",name,reason);
SendClientMessage(playerid,COLOR_YELLOW,string);
format(string,128,"You've Been Banned By %s ,, Reason : %s",pName,reason);
SendClientMessage(id,COLOR_RED,string);
format(string,128,"Admin %s Banned %s ,, Reason : %s",pName,id,reason);
SendClientMessageToAll(COLOR_YELLOW,string);
Ban(id);
format(string,sizeof(string),"%s Banned %s ,, Reason : %s",pName,name,reason);
SaveIn("BanLog.txt",string);
}
return 1;
}
This is the kicklog:
Код:
AlexzzPro Kicked ,, Reason : test
When i kick my self, it gets like that.
It saves the kicks in the logs. But i dont get kicked at all.
And i dont know how to fix this.
Thanks, Alex
Re: Wrong with my kick + ban command. -
mamorunl - 12.04.2011
It has been a long time for me, but what happens if you use 'd' instead of 'u' in sscanf?
Re: Wrong with my kick + ban command. -
Voldemort - 12.04.2011
https://sampforum.blast.hk/showthread.php?tid=248197
Read my post and compare, you have made same mistakes
Re: Wrong with my kick + ban command. -
BizzyD - 12.04.2011
There is some differents betweeen sscanf + zcmd and strcmp
Re: Wrong with my kick + ban command. -
Mokerr - 12.04.2011
This should work:
pawn Код:
CMD:kick(playerid,params[])
{
new id,reason[128];
if(PlayerInfo[playerid][pAdminLevel] < 1) return SendClientMessage(playerid,COLOR_RED,"You've To Be Admin To Use This Command");
if(sscanf(params,"us[128]",id,reason)) return SendClientMessage(playerid,COLOR_RED,"Usage : /kick [playerid] [Reason]");
if(id == INVALID_PLAYER_ID) return SendClientMessage(playerid,COLOR_RED,"Player Doesn't Exist");
new pName[24],name[24];
GetPlayerName(playerid,pName,24);
GetPlayerName(id,name,24);
new string[128];
format(string,128,"You've Kicked %s ,, Reason : %s",name,reason);
SendClientMessage(playerid,COLOR_YELLOW,string);
format(string,128,"You've Been Kicked By %s ,, Reason : %s",pName,reason);
SendClientMessage(id,COLOR_RED,string);
format(string,128,"Admin %s Kicked %s ,, Reason : %s",pName,id,reason);
SendClientMessageToAll(COLOR_YELLOW,string);
Kick(id);
format(string,sizeof(string),"%s Kicked %s ,, Reason : %s",pName,name,reason);
SaveIn("KickLog.txt",string);
return 1;
}
Compare it with yours, and apply the modifications on the ban cmd.
Re: Wrong with my kick + ban command. -
BizzyD - 12.04.2011
It works fine
Thank you
You will of course get credit