Count down Timer fails
#1

it only works for id 0 but not all ids. for id 1 i type in /work the message showing for id 1
and sometimes it spams.
Code:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    if(gMissionInt[playerid] == 1)
    {
        LastOrCurrentVeh[playerid] = vehicleid;
    }
	return 1;
}
Code:
public OnPlayerExitVehicle(playerid, vehicleid)
{
    if(gMissionInt[playerid] == 1)
    {
        LastOrCurrentVeh[playerid] = vehicleid;
    }
	return 1;
}
In command
Code:
gMissionInt[playerid] = 1;
truckchecktime = SetTimerEx("TruckCheck", 1000, true, "i", playerid);
Code:
forward TruckCheck(playerid);
public TruckCheck(playerid)
{
    new str[128];
    if (!IsPlayerInAnyVehicle(playerid) || !IsTrailerAttachedToVehicle(LastOrCurrentVeh[playerid])) {
            truckTime[playerid]++;
            format(str, sizeof(str), "Get back in your truck! ~n~or~n~Reconnect your trailer! ~n~(%d)", 30 - truckTime[playerid]);
            GameTextForPlayer(playerid, str, 1000, 3);
            PlayerPlaySound(playerid,1056,0.0,0.0,0.0);
            if (truckTime[playerid] >= 30) {
                KillTimer(truckchecktime);
                StopPlayerJob(playerid);
                SendClientMessage(playerid, COLOR_LIGHTGREEN, "You failed the mission!");
                truckTime[playerid] = 0;
            }
            return 1;
    }
    return 0;
}
Reply
#2

Quote:
Originally Posted by DerickClark
In command

gMissionInt[playerid] = 1;
truckchecktime = SetTimerEx("TruckCheck", 1000, true, "i", playerid);
Most likely error is on commands. Only call id 0 in timer.
Reply
#3

whats the right timer for that code? and yes its only called for id 0.
Reply
#4

Quote:
Originally Posted by DerickClark
View Post
whats the right timer for that code? and yes its only called for id 0.
Submitted code is valid but you have not given the instruction code where the timer is. Most likely there is error.

Such ridiculous errors occur often due to fatigue, when a programmer ceases to understand simple things.
Tip: Take a break to rest.
Reply
#5

Quote:
Originally Posted by Logofero
View Post
Submitted code is valid but you have not given the instruction code where the timer is. Most likely there is error.

Such ridiculous errors occur often due to fatigue, when a programmer ceases to understand simple things.
Tip: Take a break to rest.
.. This all of the code..
Reply
#6

I have it
PHP Code:
CMD:mission(playeridparams[]) {
    
gMissionInt[playerid] = 1;
    
truckchecktime SetTimerEx("TruckCheck"1000true"i"playerid);
    return 
1;

Reply
#7

Quote:
Originally Posted by Logofero
View Post
I have it
PHP Code:
CMD:mission(playeridparams[]) {
    
gMissionInt[playerid] = 1;
    
truckchecktime SetTimerEx("TruckCheck"1000true"i"playerid);
    return 
1;

i did that, didn't work.
Reply
#8

And fixed it
PHP Code:
forward TruckCheck(playerid);
public 
TruckCheck(playerid)
{
    new 
str[128];
    new 
vehicleid GetPlayerVehicleID(playerid);
    if (!
vehicleid || !IsTrailerAttachedToVehicle(vehicleid)) {
            
truckTime[playerid]++;
            
format(strsizeof(str), "Get back in your truck! ~n~or~n~Reconnect your trailer! ~n~(%d)"30 truckTime[playerid]);
            
GameTextForPlayer(playeridstr10003);
            
PlayerPlaySound(playerid,1056,0.0,0.0,0.0);
            if (
truckTime[playerid] >= 30) {
                
KillTimer(truckchecktime);
                
StopPlayerJob(playerid);
                
SendClientMessage(playeridCOLOR_LIGHTGREEN"You failed the mission!");
                
truckTime[playerid] = 0;
            }
            return 
1;
    }
    return 
0;

Reply
#9

When the mission fails, it reset it.
Reply
#10

I lend the topic a bit, where's the bit that actually makes the timer to count down?. Need to learn that so I ask it here as it's same function...
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)