help pls
#1

i made timer for using command, they have to wait 3 seconds to use the command again but i wanna disable it for admins bec there is slap cmd and i wanna spam it but i can't bec i have to wait 3 secs so i want to disable it for admins only

code :

PHP код:
new lastcommand[MAX_PLAYERS];
public 
OnPlayerDisconnect(playeridreason)
{  
    
lastcommand[playerid]=0//reset command cooldown time
    
return 1;
}
public 
OnPlayerCommandPerformed(playeridcmdtext[], success)
{
    if(!
success)
    {
        new 
string[128];
        
format(stringsizeof(string), "{FF6600}[DBot]: {FFFFFF}Command {FF0000}%s{FFFFFF} not found, Type {FF6600}/cmds {FFFFFF}to see server commands"cmdtext);
        
SendClientMessage(playeridCOLOR_WHITEstring);
    }
    else if(
success)
    {
        
lastcommand[playerid]=gettime();
    }
    return 
1;
}
public 
OnPlayerCommandReceived(playeridcmdtext[]) //command cooldown
{
    if(
lastcommand[playerid] != && gettime()-lastcommand[playerid] < 3)
    {
        
SendClientMessage(playeridCOLOR_RED"Please wait {AFAFAF}3 {FF0000}seconds before using any command again!");
        return 
0;
    }
    return 
1;

Reply
#2

Just add

Код:
if(IsPlayerAdmin(playerid))
Reply
#3

Quote:
Originally Posted by DonaldDuck
Посмотреть сообщение
Just add

Код:
if(IsPlayerAdmin(playerid))
ik this but idk where to put it LOL
Reply
#4

Put below of your cmd
Reply
#5

Quote:
Originally Posted by DonaldDuck
Посмотреть сообщение
just put down below of your command.
here is the command code and it got IsPlayerAdmin already

code :

PHP код:
CMD:slap(playeridparams[])
{
    if(!
IsPlayerAdmin(playerid)) return SendClientMessage(playeridCOLOR_RED"You're not allowed to use this command");
    new 
pname[MAX_PLAYER_NAME], oname[MAX_PLAYER_NAME], otheridstring[128], Float:PPos[3];
    if(
sscanf(params"u"otherid)) return SendClientMessage(playeridCOLOR_WHITE"{FF6600}Usage: {FFFFFF}/slap [playerid/name]");
    else if(!
IsPlayerConnected(otherid)) return SendClientMessage(playeridCOLOR_RED"Player isn't connected");
    else
    {
        
GetPlayerName(playeridpnamesizeof(pname));
        
GetPlayerName(otheridonamesizeof(oname));
        
GetPlayerPos(otheridPPos[0], PPos[1], PPos[2]);
        
SetPlayerPos(otheridPPos[0], PPos[1], PPos[2]+4);
        
format(stringsizeof(string), "*{33ccff}[Administrator] - %s {FFFFFF}slapped {%06x}%s"pnameGetPlayerColor(playerid) >>> 8oname);
        
SendClientMessageToAll(COLOR_WHITEstring);
        
format(stringsizeof(string), "You've slapped {%06x}%s{FFFFFF}(%d)"GetPlayerColor(playerid) >>> 8onameplayerid);
        
SendClientMessage(playeridCOLOR_WHITEstring);
    }
    return 
1;

Reply
#6

Quote:
Originally Posted by DeStRoY232
Посмотреть сообщение
here is the command code and it got IsPlayerAdmin already

code :

PHP код:
CMD:slap(playeridparams[])
{
    if(!
IsPlayerAdmin(playerid)) return SendClientMessage(playeridCOLOR_RED"You're not allowed to use this command");
    new 
pname[MAX_PLAYER_NAME], oname[MAX_PLAYER_NAME], otheridstring[128], Float:PPos[3];
    if(
sscanf(params"u"otherid)) return SendClientMessage(playeridCOLOR_WHITE"{FF6600}Usage: {FFFFFF}/slap [playerid/name]");
    else if(!
IsPlayerConnected(otherid)) return SendClientMessage(playeridCOLOR_RED"Player isn't connected");
    else
    {
        
GetPlayerName(playeridpnamesizeof(pname));
        
GetPlayerName(otheridonamesizeof(oname));
        
GetPlayerPos(otheridPPos[0], PPos[1], PPos[2]);
        
SetPlayerPos(otheridPPos[0], PPos[1], PPos[2]+4);
        
format(stringsizeof(string), "*{33ccff}[Administrator] - %s {FFFFFF}slapped {%06x}%s"pnameGetPlayerColor(playerid) >>> 8oname);
        
SendClientMessageToAll(COLOR_WHITEstring);
        
format(stringsizeof(string), "You've slapped {%06x}%s{FFFFFF}(%d)"GetPlayerColor(playerid) >>> 8onameplayerid);
        
SendClientMessage(playeridCOLOR_WHITEstring);
    }
    return 
1;

Yes thats it.


Here the disable timer for admin
Код:
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; 
}
Reply
#7

Quote:
Originally Posted by DonaldDuck
Посмотреть сообщение
Yes thats it.
but it's preventing me to spam the command bro bec command cooldown is for all players but i wanna disable it for admin commands
Reply
#8

PHP код:
format(stringsizeof(string), "*{33ccff}[Administrator] - %s {FFFFFF}slapped {%06x}%s"pnameGetPlayerColor(playerid) >>> 8oname); 
If I am not wrong, then this command is allowing administrators to use this command.
Reply
#9

PHP код:
if(!IsPlayerAdmin(playerid)) return SendClientMessage(playeridCOLOR_RED"You're not allowed to use this command"); 
This line is used for /asay, just I want clarify that how can you write that "You're not allowed to use this command"
Reply
#10

Quote:
Originally Posted by FrezQ
Посмотреть сообщение
PHP код:
if(!IsPlayerAdmin(playerid)) return SendClientMessage(playeridCOLOR_RED"You're not allowed to use this command"); 
This line is used for /asay, just I want clarify that how can you write that "You're not allowed to use this command"
if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_RED, "You're not allowed to use this command")

can be used like this too

PHP код:
CMD:test(playeridparams[])
{
   If(
IsPlayerAdmin(playerid))
   {
      
GivePlayerWeapon(playerid24200)
   }
   else if(!
IsPlayerAdmin(playerid))
   {
       
SendClientMessage(playeridCOLOR_WHITE"You're not allowed to use this command");
   } 
   return 
1;

Quote:
Originally Posted by lackmail
Посмотреть сообщение
Код:
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; 
}
thanks man +rep

-Locked
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)