27.03.2011, 12:16
I suggest you to use Zcmd + Sscanf2:
Kick:
Ban:
Somewhere in your script:
Kick:
pawn Код:
CMD:kick( playerid, params[ ] )
{
new ID, string[128], reason[66];
if( !IsPlayerAdmin( playerid ) ) return 0;
if(sscanf(params, "uS(No Reason Given)[65]", ID, reason)) return SendClientMessage(playerid, -1, "USAGE: /kick [PlayerID] [reason]");
if(IsPlayerConnected(ID) && ID != INVALID_PLAYER_ID && ID != playerid)
{
format(string,sizeof(string), "You are kicked by Administrator \"%s\" Reason: %s", pName(playerid),reason);
SendClientMessage(ID , -1, string);
format(string, sizeof(string), "You have kicked \"%s\" Reason: %s", pName(ID), reason);
SendClientMessage(playerid, -1 , string);
format(string, sizeof(string), "Administrator \"%s\" has kicked \"%s\" Reason: %s",pName(playerid),pName(ID),reason);
SendClientMessageToAll( -1 , string );
TogglePlayerControllable(ID, false);
Kick(ID);
printf(string);
}
else return SendClientMessage(playerid, -1, "Player is not connected or is yourself");
return 1;
}
pawn Код:
CMD:ban( playerid, params[ ] )
{
new ID, string[128], reason[66];
if( !IsPlayerAdmin( playerid ) ) return 0;
if(sscanf(params, "uS(No Reason Given)[65]", ID, reason)) return SendClientMessage(playerid, -1, "USAGE: /ban [PlayerID] [reason]");
if(IsPlayerConnected(ID) && ID != INVALID_PLAYER_ID && ID != playerid)
{
format(string,sizeof(string), "You are Banned by Administrator \"%s\" Reason: %s", pName(playerid),reason);
SendClientMessage(ID , -1, string);
format(string, sizeof(string), "You have Banned \"%s\" Reason: %s", pName(ID), reason);
SendClientMessage(playerid, -1 , string);
format(string, sizeof(string), "Administrator \"%s\" has Banned \"%s\" Reason: %s",pName(playerid),pName(ID),reason);
SendClientMessageToAll( -1 , string );
TogglePlayerControllable(ID, false);
Ban(ID);
printf(string);
}
else return SendClientMessage(playerid, -1, "Player is not connected or is yourself");
return 1;
}
pawn Код:
stock pName(playerid)
{
new Name[MAX_PLAYER_NAME];
GetPlayerName(playerid, Name, sizeof(Name));
return Name;
}