dcmd_ban(playerid,params[]) { if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, red, "ERROR: You must to be an admin before using this command!"); new tmp[256], tmp2[256], Index; tmp = strtok(params,Index), tmp2 = strtok(params,Index); if(!strlen(params)) return SendClientMessage(playerid, red, "USAGE: /ban [playerid] [reason]"); if(!strlen(tmp2)) return SendClientMessage(playerid, red, "ERROR: You must give a reason!"); new player1, playername[MAX_PLAYER_NAME], adminname[MAX_PLAYER_NAME], string[128]; player1 = strval(tmp); if(IsPlayerConnected(player1) && player1 != INVALID_PLAYER_ID && player1 != playerid) { GetPlayerName(player1, playername, sizeof(playername)); GetPlayerName(playerid, adminname, sizeof(adminname)); format(string,sizeof(string),"%s has been banned by Administrator %s (Reason: %s)",playername,adminname,params[2]); SendClientMessageToAll(red,string); BanEx(player1, string); } else return SendClientMessage(playerid, red, "ERROR: Player is not connected!"); return 1; }
Please use sscanf... makes the job more easy...
|
if( !strlen( tmp ) ) return SendClientMessage( playerid, red, "USAGE: /ban [playerid] [reason]" ); // This is what I've changed
if( !strlen( tmp2 ) ) return SendClientMessage( playerid, red, "ERROR: You must give a reason!" );
Not sure, but:
pawn Код:
|
&& player1 != playerid
If you wont offer any guy help, why the hell should you bullpost about using sscanf?
@ OP Sorry mate, but i can't help as im not into dcmd etc, i just wanted to reply to the guy that replied. |
//#include <sscanf2>
dcmd_ban(playerid, params[])
{
if(!IsPlayerAdmin(playerid))
{
new targetid, reason[128];
if(sscanf(params, "us[128]", targetid, reason)) return SendClientMessage(playerid, red, "USAGE: /ban [playerid] [reason]");
else if(IsPlayerConnected(targetid)) return SendClientMessage(playerid, red, "ERROR: Player is not connected!");
{
new playername[MAX_PLAYER_NAME], targetname[MAX_PLAYER_NAME], string[128];
GetPlayerName(playerid, playername, sizeof(playername));
GetPlayerName(targetid, targetname, sizeof(targetname));
format(string,sizeof(string),"%s has been banned by Administrator %s (Reason: %s)",targetname, playername, reason);
SendClientMessageToAll(red,string);
BanEx(targetid, reason);
}
}
else return SendClientMessage(playerid, red, "ERROR: You must to be an admin before using this command!");
}