if(strcmp(cmd, "/slap", true) == 0) {
if(PlayerInfo[playerid][Level] >= 2) {
new tmp[256];
tmp = strtok(cmdtext, idx);
if(!strlen(tmp)) {
SendClientMessage(playerid, red, "USAGE: /slap [playerid] [reason]");
return 1; }
new player1;
player1 = strval(tmp);
if(!IsPlayerConnected(player1) || player1 == INVALID_PLAYER_ID || (PlayerInfo[player1][Level] == ServerInfo[MaxAdminLevel]) ) {
SendClientMessage(playerid,red,"ERROR: Player is not connected or is yourself");
return 1; }
tmp = strtok(cmdtext, idx);
GetPlayerName(player1, playername, sizeof(playername)); GetPlayerName(playerid, adminname, sizeof(adminname));
format(string,256,"You have been slapped by Administrator %s %s ",adminname,cmdtext[7]); SendClientMessage(player1,red,string);
format(string,256,"You have slapped %s %s ",playername,cmdtext[7]); SendClientMessage(playerid,blue,string);
new Float:Health, Float:x, Float:y, Float:z; GetPlayerHealth(player1,Health); SetPlayerHealth(player1,Health-25); GetPlayerPos(player1,x,y,z); SetPlayerPos(player1,x,y,z+5); PlayerPlaySound(playerid,1190,0.0,0.0,0.0); PlayerPlaySound(player1,1190,0.0,0.0,0.0);
} else {
SendClientMessage(playerid,red,"ERROR: You need to be level 2 to use this command"); }
return 1; }
. The both make handling commands with parameters pretty simple.
dcmd_slap(playerid, params[])
{
new slapid;
new string[128];
new reason[128];
if(sscanf(params, "uz", slapid, reason)) return SendClientMessage(playerid,red,"Error: /slap <playerid/name> Reason.");
if(!IsPlayerConnected(slapid) || slapid == INVALID_PLAYER_ID || slapid == playerid) return SendClientMessage(playerid,red,"Error: Player is not connected or it is yourself.");
format(string,sizeof(string),"Admin: %s(id: %d) has slapped %s(id: %d) Reason: %s.",UserUD[playerid][accname],playerid,UserUD[slapid][accname],slapid,reason);
SendClientMessageToAll(adminaction,string);
new Float:x,
Float:y,
Float:z;
GetPlayerPos(slapid, x,y,z);
SetPlayerPos(slapid, x, y, z+8);
PlayerPlaySound(slapid, 1190, 0,0,0);
}
return 1;
}
|
With dcmd + scanff
Copyed this from my admin script. pawn Код:
|
I'm going to try if it works.
... (165) : error 010: invalid function or declaration
(301) : warning 203: symbol is never used: "dcmd_slap"