timer problems
#1

Hey guys Iv just been working on a trucking system. Iv pretty much done, everything was going well. Then I found a big problem that I dont know how to fix. When My mates driving the truck, if I jack him then he jacks the truck back. My chat is spammed majorly with text thats being created with timers.
The timers iv got are:
forward IsTrailer(playerid);//attach trailer
public IsTrailer(playerid)//
Which checks if a trailer is connected to the truck and if it is it does another timer
which is:

forward IsTrailerOff(playerid);//detach trailer
public IsTrailerOff(playerid)

which checks if the trailer is disconected..

It seems to be a problem probably with the timing not getting killed when being jacked? Otherwise i really dont know! Any information would be extremly helpful!
Reply
#2

pawn Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
    if(newstate == PLAYER_STATE_ONFOOT && oldstate == PLAYER_STATE_DRIVER)
    {
        KillTimer(....
    }
    return 1;
}
Reply
#3

Yeah i tried that and it worked good but is there a way I can make it only work for when you exit the trucks?
this would be the if statement:
Код:
if(GetPlayerVehicleID(playerid) == JobInfo[JOB_TRUCKER][jCars][0] || GetPlayerVehicleID(playerid) == JobInfo[JOB_TRUCKER][jCars][1] || GetPlayerVehicleID(playerid) == JobInfo[JOB_TRUCKER][jCars][2] || GetPlayerVehicleID(playerid) == JobInfo[JOB_TRUCKER][jCars][3] || GetPlayerVehicleID(playerid) == JobInfo[JOB_TRUCKER][jCars][4])
Where would I check this?
and the timers are:

KillTimer(TruckTimer[playerid]);
KillTimer(TrailerTimer[playerid]);
Reply
#4

Just a guess but:
pawn Код:
public OnPlayerExitVehicle(playerid, vehicleid)
{
    if(vehicleid == JobInfo[JOB_TRUCKER][jCars][0] || vehicleid == JobInfo[JOB_TRUCKER][jCars][1] || vehicleid == JobInfo[JOB_TRUCKER][jCars][2] || vehicleid == JobInfo[JOB_TRUCKER][jCars][3] || vehicleid == JobInfo[JOB_TRUCKER][jCars][4])
    {
        KillTimer(TruckTimer[playerid]);
        KillTimer(TrailerTimer[playerid]);
    }
    return 1;
}
Reply
#5

Funny iv done that exact thing, I also did
Код:
if(newstate == PLAYER_STATE_ONFOOT && oldstate == PLAYER_STATE_DRIVER)	
	{
		if(GetPlayerVehicleID(playerid) == JobInfo[JOB_TRUCKER][jCars][0] || GetPlayerVehicleID(playerid) == JobInfo[JOB_TRUCKER][jCars][1] || GetPlayerVehicleID(playerid) == JobInfo[JOB_TRUCKER][jCars][2] || GetPlayerVehicleID(playerid) == JobInfo[JOB_TRUCKER][jCars][3] || GetPlayerVehicleID(playerid) == JobInfo[JOB_TRUCKER][jCars][4]) 
		{
			KillTimer(TruckTimer[playerid]);
			KillTimer(TrailerTimer[playerid]);
			GameTextForPlayer(playerid, "~r~Truck jacked!", 3500, 3);
			PlayerInfo[playerid][pDeliverTruck] = -1;
			TruckPackages[GetPlayerVehicleID(playerid)] = -1;
			PlayerInfo[playerid][pTPackages] = 0;

		}
	}
Its just not working, It worked fine here until I added the check for if the car was a truck. I think this is where the problem lies. I just need to figure out how to check it properly...
Reply


Forum Jump:


Users browsing this thread: 4 Guest(s)