21.01.2011, 02:12
I really would like to go a step forward and a major update with my script convering strcmp and strok commands to the most efficent way.
Can anybody convert this, for example? It will work as a base.
A guide to convert commands and use sscanf as their parameters is deeply appreciated
Regards,
Can anybody convert this, for example? It will work as a base.
pawn Код:
if(strcmp("/kick", cmd, true) == 0)
{
if(PlayerInfo[playerid][pAdminLevel] >= 1)
{
tmp = strtok(cmdtext,idx);
if(!strlen(tmp))
{
return SendClientMessage(playerid,COLOR_LIGHTRED,"USAGE: /kick [id] [reason]");
}
new id = strval(tmp);
new pid = playerid;
new reason[128];
reason = strrest(cmdtext, idx);
if (!strlen(reason)) return SendClientMessage(playerid,COLOR_LIGHTRED,"USAGE: /kick [id] [reason]");
if(!IsPlayerConnected(id))
{
return SendClientMessage(playerid,COLOR_GRAY,"AdmCmd This player is not online!");
}
PlayHintSoundAtPos(playerid);
new globalmsg[100];
new adminid[MAX_PLAYERS], victimid[MAX_PLAYERS];
GetPlayerName(pid, adminid, sizeof(victimid));
GetPlayerName(id, victimid, sizeof(victimid));
format(globalmsg,sizeof(globalmsg),"AdmWarn: Administrator %s has kicked player %s [%s]",adminid,victimid,reason);
SendClientMessageToAll(COLOR_LIGHTBLUE,globalmsg);
Kick(id);
return 1;
}
else
{
SendClientMessage(playerid,COLOR_GRAY,"You don't have authorization.");
return 1;
}
}
Regards,