CMD:ban(playerid, params[])
{
if(PVar[playerid][pLevel] >= 4)
{
new
PID;
if(sscanf(params, "us[70]", PID, params)) return SendClientMessage(playerid, COLOR_RED, ""#CRED"USAGE: "#CORANGE"/Ban < Player ID > < Reason >");
if(!IsPlayerConnected(PID)) return SendClientMessage(playerid, COLOR_RED, "* That user is not connected!");
SendFMessage(PID, COLOR_LIGHTBLUE, "You have been banned by: %s(%d) for: %s", pName(playerid), playerid, params);
SendFMessageToAll(COLOR_LIGHTBLUE, "Admin: %s(%d) has banned: %s(%d) for: %s", pName(playerid), playerid, pName(PID), PID, params);
return BanEx(PID, params);
}
else return SendClientMessage(playerid, COLOR_RED, "You are not an admin!");
}
if(!IsPlayerConnected(PID)) return SendClientMessage(playerid, COLOR_RED, "* That user is not connected!");
if(PID == INVALID_PLAYER_ID) return SendClientMessage(playerid,-1,"* That user id is invalid");
try this RPN ====pname and u can change the info 2 fit urs but it works 100%
CMD:ban(playerid, params[]) { new playerb, string[128]; if(PlayerInfo[playerid][pAdmin] < 3) return SendClientMessage(playerid, COLOR_GREY, "You are not authorized to use this command."); if(!aDuty[playerid]) return SendClientMessage(playerid, COLOR_GREY, "You are not on admin duty."); if(sscanf(params, "us[128]", playerb, params)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /ban [playerid] [reason]"); if(PlayerInfo[playerid][pAdmin] < PlayerInfo[playerb][pAdmin]) return SendClientMessage(playerid, COLOR_GREY, "Player has a higher admin level than you."); format(string, sizeof(string), "AdmCmd: %s has been banned by %s, reason: %s", RPN(playerb), RPN(playerid), params); SendClientMessageToAll(COLOR_LIGHTRED, string); format(string, sizeof(string), "AdmCmd: %s has been banned by %s (%s), reason: %s", RPN(playerb), RPN(playerid) , RPIP(playerid), params); // Banning PlayerInfo[playerb][pBanned] = 1; AddBan(playerb); Kick(playerb); return 1; } |
I've always been facing problems while using this with Sscanf
pawn Код:
pawn Код:
|
CMD:ban(playerid, params[])
{
if(PVar[playerid][pLevel] >= 4)
{
new
PID;
if(sscanf(params, "us[70]", PID, params)) return SendClientMessage(playerid, COLOR_RED, ""#CRED"USAGE: "#CORANGE"/Ban < Player ID > < Reason >");
if(PID == INVALID_PLAYER_ID) return SendClientMessage(playerid,-1,"* That user id is invalid"); // now feeling good being spoon-feeded?
SendFMessage(PID, COLOR_LIGHTBLUE, "You have been banned by: %s(%d) for: %s", pName(playerid), playerid, params);
SendFMessageToAll(COLOR_LIGHTBLUE, "Admin: %s(%d) has banned: %s(%d) for: %s", pName(playerid), playerid, pName(PID), PID, params);
return BanEx(PID, params);
}
else return SendClientMessage(playerid, COLOR_RED, "You are not an admin!");
}
CMD:ban(playerid, params[])
{
if(PVar[playerid][pLevel] >= 4)
{
new
PID,reason[70];
if(sscanf(params, "us[70]", PID, reason)) return SendClientMessage(playerid, COLOR_RED, ""#CRED"USAGE: "#CORANGE"/Ban < Player ID > < Reason >");
if(!IsPlayerConnected(PID)) return SendClientMessage(playerid, COLOR_RED, "* That user is not connected!");
SendFMessage(PID, COLOR_LIGHTBLUE, "You have been banned by: %s(%d) for: %s", pName(playerid), playerid, reason);
SendFMessageToAll(COLOR_LIGHTBLUE, "Admin: %s(%d) has banned: %s(%d) for: %s", pName(playerid), playerid, pName(PID), PID, reason);
return BanEx(PID, reason);
}
else return SendClientMessage(playerid, COLOR_RED, "You are not an admin!");
}