Can't kill a timer.
#1

Hello, I've tried everything but it seems like I can't find a way to stop a timer. Basically its about when you go in a small shelter and take a pickup, the exit is getting blocked and a 3d text label spawns, saying the command /riddle as then are the instructions on how to escape the house, after the person enters the pickup a timer starts where his health is getting lowered by 1 every 1 second untill he dies, unless he manages to say the command he will eventually die. The problem is after the player writes the command, even though I've written the KillTimer thing it doesn't stop, below is the code any help is appreciated as I ran out of ideas.
PHP код:
 new lowhp[MAX_PLAYERS];
new 
Text3D:riddle;
new 
destroy;
new 
door1// pickup
new door2//door to move
forward message(playerid);
    if (
strcmp("/shorter"cmdtexttrue10) == 0)
    {
    if (
IsPlayerInRangeOfPoint(playerid7.0, -1497.6346,-2251.0876,1.9605))
    {
    
SendClientMessage(playeridCOLOR_GREEN"Seems like you will live... for now.");
    
DestroyObject(destroy);
    
Delete3DTextLabel(riddle);
    
KillTimer(message(playerid));
    return 
1;
    }
}
public 
OnPlayerPickUpPickup(playeridpickupid)
{
    if(
pickupid == door1)
    
DestroyObject(door2);
    
destroy CreateObject(2957,-1497.3000488281, -2251.89990234382.7999999523163336.19207763672349.6766967773427.749084472656);
    
SendClientMessage(playeridCOLOR_WHITE"Look behind yourself");
    
riddle Create3DTextLabel("/riddle"COLOR_ORANGE, -1497.6346,-2251.0876,1.96051000);
    
lowhp[playerid] = SetTimerEx("message"1000true"i"playerid);
    return 
1;
}
public 
message(playerid)
{
    new 
Float:Healther;
    
GetPlayerHealth(playeridHealther);
    
SetPlayerHealth(playeridHealther-1);
    return 
1;

Reply
#2

Код:
KillTimer(message(playerid));
You are calling a public function that returns 1 so it kills the timer with ID 1. The correct is:
Код:
KillTimer(lowhp[playerid]); 
lowhp[playerid] = -1;
resetting afterwards just in case (to avoid killing other timers with the "old" timerid).
Reply
#3

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
Код:
KillTimer(message(playerid));
You are calling a public function that returns 1 so it kills the timer with ID 1. The correct is:
Код:
KillTimer(lowhp[playerid]); 
lowhp[playerid] = -1;
resetting afterwards just in case (to avoid killing other timers with the "old" timerid).
I can't thank you enough, it works flawlessly.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)