new lastcommand[MAX_PLAYERS];
public OnPlayerDisconnect(playerid, reason)
{
lastcommand[playerid]=0; //reset command cooldown time
return 1;
}
public OnPlayerCommandPerformed(playerid, cmdtext[], success)
{
if(!success)
{
new string[128];
format(string, sizeof(string), "{FF6600}[DBot]: {FFFFFF}Command {FF0000}%s{FFFFFF} not found, Type {FF6600}/cmds {FFFFFF}to see server commands", cmdtext);
SendClientMessage(playerid, COLOR_WHITE, string);
}
else if(success)
{
lastcommand[playerid]=gettime();
}
return 1;
}
public OnPlayerCommandReceived(playerid, cmdtext[]) //command cooldown
{
if(lastcommand[playerid] != 0 && gettime()-lastcommand[playerid] < 3)
{
SendClientMessage(playerid, COLOR_RED, "Please wait {AFAFAF}3 {FF0000}seconds before using any command again!");
return 0;
}
return 1;
}
if(IsPlayerAdmin(playerid))
CMD:slap(playerid, params[])
{
if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_RED, "You're not allowed to use this command");
new pname[MAX_PLAYER_NAME], oname[MAX_PLAYER_NAME], otherid, string[128], Float:PPos[3];
if(sscanf(params, "u", otherid)) return SendClientMessage(playerid, COLOR_WHITE, "{FF6600}Usage: {FFFFFF}/slap [playerid/name]");
else if(!IsPlayerConnected(otherid)) return SendClientMessage(playerid, COLOR_RED, "Player isn't connected");
else
{
GetPlayerName(playerid, pname, sizeof(pname));
GetPlayerName(otherid, oname, sizeof(oname));
GetPlayerPos(otherid, PPos[0], PPos[1], PPos[2]);
SetPlayerPos(otherid, PPos[0], PPos[1], PPos[2]+4);
format(string, sizeof(string), "*{33ccff}[Administrator] - %s {FFFFFF}slapped {%06x}%s", pname, GetPlayerColor(playerid) >>> 8, oname);
SendClientMessageToAll(COLOR_WHITE, string);
format(string, sizeof(string), "You've slapped {%06x}%s{FFFFFF}(%d)", GetPlayerColor(playerid) >>> 8, oname, playerid);
SendClientMessage(playerid, COLOR_WHITE, string);
}
return 1;
}
here is the command code and it got IsPlayerAdmin already
code : PHP код:
|
public OnPlayerCommandPerformed(playerid, cmdtext[], success) { if(!success) { new string[128]; format(string, sizeof(string), "{FF6600}[DBot]: {FFFFFF}Command {FF0000}%s{FFFFFF} not found, Type {FF6600}/cmds {FFFFFF}to see server commands", cmdtext); SendClientMessage(playerid, COLOR_WHITE, string); } else if(success && !IsPlayerAdmin(playerid)) { lastcommand[playerid]=gettime(); } return 1; }
format(string, sizeof(string), "*{33ccff}[Administrator] - %s {FFFFFF}slapped {%06x}%s", pname, GetPlayerColor(playerid) >>> 8, oname);
if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_RED, "You're not allowed to use this command");
PHP код:
|
CMD:test(playerid, params[])
{
If(IsPlayerAdmin(playerid))
{
GivePlayerWeapon(playerid, 24, 200)
}
else if(!IsPlayerAdmin(playerid))
{
SendClientMessage(playerid, COLOR_WHITE, "You're not allowed to use this command");
}
return 1;
}
Код:
public OnPlayerCommandPerformed(playerid, cmdtext[], success) { if(!success) { new string[128]; format(string, sizeof(string), "{FF6600}[DBot]: {FFFFFF}Command {FF0000}%s{FFFFFF} not found, Type {FF6600}/cmds {FFFFFF}to see server commands", cmdtext); SendClientMessage(playerid, COLOR_WHITE, string); } else if(success && !IsPlayerAdmin(playerid)) { lastcommand[playerid]=gettime(); } return 1; } |