limit for cmds
#1

Guys, i wanna learn how to like make a limit for the cmd
ex: if i used /heal i cant use it till 2minutes pass, can you help me? this is just an example
Quote:

CMD:heal(playerid, params)
{
SetPlayerHealth(playerid, 100);
return 1;
}

btw: this is my vehicle cmd,i want if i didn't enter a value for the color it spawns the car with any color but if i typed the color it spawns with the color
Quote:

CMD:vehicle(playerid, params[])
{
new Float, Float:y, Float:z, Float:a;
new vehicleid, color1, color2;
if(sscanf(params, "iii", vehicleid, color1, color2)) return SendClientMessage(playerid, RED, "ERROR: /v [Vehicle ID] [Color1] [Color2]");
if(vehicleid > 611 || vehicleid < 400) return SendClientMessage (playerid, RED, "ERROR: Vehcile ID Must Be Between 400 & 611");
GetPlayerPos(playerid, x, y ,z);
GetPlayerFacingAngle(playerid, a);
vehicleid = CreateVehicle(vehicleid, x, y, z, a, color1, color2, 60, 0);
PutPlayerInVehicle(playerid, vehicleid, 0);
return 1;
}

Another thing not releated to the scripting , how can i change my name on this forums?!! .__.
Reply
#2

for the command try this

PHP код:
new Healed[MAX_PLAYERS];
public 
OnPlayerConnect(playerid)
{
    
Healed[playerid] = 0;
    return 
1;
}
public 
OnPlayerDisconnect(playeridreason)
{
    
Healed[playerid] = 0;
    return 
1;
}
forward HealAgain(playerid);
public 
HealAgain(playerid)
{
    
Healed[playerid] = 0;
    return 
1;
}
CMD:heal(playeridparams[])
{
    if(
Healed[playerid] != 0) return SendClientMessage(playerid, -1"You have to wait 2 minutes to use this command again!");
    
SetPlayerHealth(playerid100.0);
    
Healed[playerid] = 1;
    
SetTimerEx("HealAgain"1200000"i"playerid);
    return 
1;

Reply
#3

Quote:

C:\Users\Ahmed\Desktop\samp037_svr_R2-1-1_win32\gamemodes\C5School.pwn(926) : error 021: symbol already defined: "checkhh"
C:\Users\Ahmed\Desktop\samp037_svr_R2-1-1_win32\gamemodes\C5School.pwn(927) : error 021: symbol already defined: "checkhh"

the errors are in these lines
Quote:

forward checkhh(playerid);
public checkhh(playerid)

Reply
#4

Do not use timers to such stupidity
PHP код:
new Healed[MAX_PLAYERS];

CMD:heal(playerid){ 
    if(
GetTickCount()-Healed[playerid] >= 2*60*1000) return SendClientMessage(playerid, -1"You have to wait 2 minutes to use this command again!"); 
    
SetPlayerHealth(playerid,100.0);
    
Healed[playerid] = GetTickCount();
    return 
1;

Reply
#5

Quote:
Originally Posted by AbyssMorgan
Посмотреть сообщение
Do not use timers to such stupidity
PHP код:
new Healed[MAX_PLAYERS];
CMD:heal(playerid){ 
    if(
GetTickCount()-Healed[playerid] >= 2*60*1000) return SendClientMessage(playerid, -1"You have to wait 2 minutes to use this command again!"); 
    
SetPlayerHealth(playerid,100.0);
    
Healed[playerid] = GetTickCount();
    return 
1;

Nope, not working..
Reply
#6

ups, wrong directions xD
PHP код:
if(GetTickCount()-Healed[playerid] < 2*60*1000) return SendClientMessage(playerid, -1"You have to wait 2 minutes to use this command again!"); 
Reply
#7

pawn Код:
new HealTime[MAX_PLAYERS];

CMD:heal(playerid, params[])
{
    if((gettime() - HealTime[playerid]) < 120) // 120 = 2 min
    {
        new str[32];
        format(str,sizeof(str),"Wait %d sec",120 - (gettime() - HealTime[playerid]));
        SendClientMessage(playerid,-1,str);
    }
    else
    {
        HealTime[playerid] = gettime();
        SetPlayerHealth(playerid, 100.0);
    }
    return 1;
}

CMD:vehicle(playerid, params[])
{
    new vehicleid, color1, color2;
    if(sscanf(params, "iI(-1)I(-1)", vehicleid, color1, color2)) SendClientMessage(playerid, RED, "ERROR: /v [Vehicle ID] [Color1] [Color2]");
    else if(!(400 <= vehicleid <= 611)) SendClientMessage (playerid, RED, "ERROR: Vehcile ID Must Be Between 400 & 611");
    else
    {
        new Float, Float:y, Float:z, Float:a;
        GetPlayerPos(playerid, x, y ,z);
        GetPlayerFacingAngle(playerid, a);
        vehicleid = CreateVehicle(vehicleid, x, y, z, a, color1, color2, 60, 0);
        PutPlayerInVehicle(playerid, vehicleid, 0);
    }
    return 1;
}
Reply
#8

Quote:
Originally Posted by AbyssMorgan
Посмотреть сообщение
ups, wrong directions xD
PHP код:
if(GetTickCount()-Healed[playerid] < 2*60*1000) return SendClientMessage(playerid, -1"You have to wait 2 minutes to use this command again!"); 
it worked, but what about this?! why it doesn't work
Quote:

CMD:checkhacker(playerid, params[])
{
new toplayerid, hacktimer[MAX_PLAYERS];
if(GetTickCount()-hacktimer[playerid] < 5000) return SendClientMessage(playerid, RED, "Don't Spam This Command!");
if(pInfo[playerid][Admin] <= 0) return SendClientMessage(playerid, RED, "ERROR: You Aren't High Level Enough To Use This Command");
if(sscanf(params, "u", toplayerid)) return SendClientMessage(playerid, -1, "ERROR: /checkhacker [playerid]");

Reply
#9

Guys?! any help
Reply
#10

Use my tutorial thats in my signature. https://sampforum.blast.hk/showthread.php?tid=583234
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)