dcmd(HEAL, 4, cmdtext);
dcmd_HEAL(playerid, cmdtext[]) {
#pragma unused cmdtext
SetPlayerHealth( playerid, 100 );
return 1;
new UNIX_heal[MAX_PLAYERS]; dcmd_heal(playerid, cmdtext[]) { if(gettime() - UNIX_heal[playerid] > 5*60) return SendClientMessage(playerid,-1,"You have to wait 5 minutes!"); UNIX_heal[playerid] = gettime(); //... the code when 5 mins are over return 1; }
HELLO EVERONE I NEED HELP WITH CREATING A TIMER ON A COMMAND
FOR EXAMPLE WHEN SOME TYPES /HEALME THERE LIFE WILL HEAL TO 100 AND THEN AFTER 5 MINS THEY MAY USE IT AGIAN INSTEAD OF ABUSING pawn Код:
pawn Код:
HOPE I MAKE SENCE AND THANKS |
dcmd_HEAL(playerid, cmdtext[]) { #pragma unused cmdtext SetPlayerHealth( playerid, 100 ); if(!fexist("heal.txt")) return SendClientMessage(playerid, red, "Wait 5 mins befor use again!");//if not have the file fremove("heal.txt"); //remove file if exist SetTimer("heal", 5*60000, 0); //set timer with 5mins return 1; } forward heal (playerid); //forward for recreate file public heal (playerid)//recreate 'heal.txt' { if(!fexist("heal.txt")) { new File:create = fopen("heal.txt", io_write); if(create) fclose(create); } }
new UsedHealth[MAX_PLAYERS];
dcmd_HEAL(playerid, cmdtext[])
{
if(UsedHealth[playerid] == 0){
#pragma unused cmdtext
SetPlayerHealth( playerid, 100 );
UsedHealth[playerid] = 1;
SetTimerEx("HealAgain", 5*60000, false, "i", playerid);
}
else {
SendClientMessage(playerid, 0xFFFFFFFF, "Wait 5 mins befor use again!");
}
return 1;
}
forward HealAgain (i);
public HealAgain (i)
{
UsedHealth[i] = 0;
return 1;
}
warning 217: loose indentation
C:\Documents and Settings\Administrator\Desktop\SA SERVER\OFFICAL SERVER\gamemodes\xlgwolds.pwn(989) : warning 217: loose indentation
C:\Documents and Settings\Administrator\Desktop\SA SERVER\OFFICAL SERVER\gamemodes\xlgwolds.pwn(2140) : error 017: undefined symbol "dcm"
C:\Documents and Settings\Administrator\Desktop\SA SERVER\OFFICAL SERVER\gamemodes\xlgwolds.pwn(2145) : warning 225: unreachable code
C:\Documents and Settings\Administrator\Desktop\SA SERVER\OFFICAL SERVER\gamemodes\xlgwolds.pwn(2145) : warning 217: loose indentation
C:\Documents and Settings\Administrator\Desktop\SA SERVER\OFFICAL SERVER\gamemodes\xlgwolds.pwn(2146) : error 017: undefined symbol "dcmd_HEAL"
C:\Documents and Settings\Administrator\Desktop\SA SERVER\OFFICAL SERVER\gamemodes\xlgwolds.pwn(2148) : error 017: undefined symbol "UsedHealth"
C:\Documents and Settings\Administrator\Desktop\SA SERVER\OFFICAL SERVER\gamemodes\xlgwolds.pwn(2148) : warning 215: expression has no effect
C:\Documents and Settings\Administrator\Desktop\SA SERVER\OFFICAL SERVER\gamemodes\xlgwolds.pwn(2148) : error 001: expected token: ";", but found "]"
C:\Documents and Settings\Administrator\Desktop\SA SERVER\OFFICAL SERVER\gamemodes\xlgwolds.pwn(2148) : error 029: invalid expression, assumed zero
C:\Documents and Settings\Administrator\Desktop\SA SERVER\OFFICAL SERVER\gamemodes\xlgwolds.pwn(2148) : fatal error 107: too many error messages on one line
new UsedHealth[MAX_PLAYERS];
if(strcmp(cmdtext, "/heal", true) == 0)
{
if(UsedHealth[playerid] == 0){
SetPlayerHealth( playerid, 100 );
UsedHealth[playerid] = 1;
SetTimerEx("HealAgain", 5*60000, false, "i", playerid);
}
else {
SendClientMessage(playerid, 0xFFFFFFFF, "Wait 5 mins befor use again!");
}
return 1;
}
forward HealAgain (i);
public HealAgain (i)
{
UsedHealth[i] = 0;
return 1;
}