HEAL COMMAND
#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 Код:
dcmd(HEAL, 4, cmdtext);
pawn Код:
dcmd_HEAL(playerid, cmdtext[]) {
    #pragma unused cmdtext
     SetPlayerHealth( playerid, 100 );
     return 1;
BUT I WANT PEOPLE TO USE IT ONCE IN EVERY 5 MINS
HOPE I MAKE SENCE AND THANKS
Reply
#2

in this case, you can do something more efficient than using a ugly timer.
When it comes to stuff like this, the best you can do is work with Timestamps

example:
Код:
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;
}
5*60 are 5 minutes, 10 minutes would of course be 10*60
Reply
#3

Quote:
Originally Posted by kaos999
Посмотреть сообщение
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 Код:
dcmd(HEAL, 4, cmdtext);
pawn Код:
dcmd_HEAL(playerid, cmdtext[]) {
    #pragma unused cmdtext
     SetPlayerHealth( playerid, 100 );
     return 1;
BUT I WANT PEOPLE TO USE IT ONCE IN EVERY 5 MINS
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);
	}
}
Its not tested D
I think its good.. but not the best
Reply
#4

lol i dont get that at all and i got erros i think need a step to step guide please
Reply
#5

common some one help me please
Reply
#6

bump
Reply
#7

pawn Код:
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;
}
Reply
#8

pawn Код:
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
what do i do now??
Reply
#9

BUMP!
Reply
#10

Did you just copied this script from another gamemode?
pawn Код:
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;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)