22.04.2012, 19:31
On a trucking job I'm working on, I'm having to show a dialog when a player hooks up his trailer. In the case of the code below, if more than one player is doing the job then the timers do not kill correctly. The command below starts the timer.
And I'm attempting to kill it once the timer finds that a player has attached a trailer, which works, but as stated earlier only for the first person to type the above command. Other players will get the dialog when they hook up but the timer does not kill and the dialog continues to reappear and reappear.
I have tried following Ivex's post here: https://sampforum.blast.hk/showthread.php?tid=166479 and nothing changed. Any ideas?
pawn Код:
YCMD:confirmtruck(playerid, params[], help)
{
if(PlayerInfo[playerid][pJob] == 5)
{
TTTimer1 = SetTimerEx("TrailerCheck",1000,true,"i",playerid);
TTTimer2 = SetTimerEx("TTLevelUpCheck",1000,true,"i",playerid);
new vehicle = GetPlayerVehicleID(playerid);
if(vehicle == 139 || vehicle == 138 || vehicle == 137)
{
PlayerInfo[playerid][pIsWorking] = 1;
Ccp[playerid] = 16;
SetPlayerCheckpoint(playerid,52.5144,-270.2235,1.6817,5.0);
SendClientMessage(playerid,COLOUR_ORANGE,"Pick up a load at the factory in Blue Berry Acres.");
TogglePlayerControllable(playerid,1);
}
else if(vehicle == 88 || vehicle == 87 || vehicle == 86)
{
PlayerInfo[playerid][pIsWorking] = 1;
Ccp[playerid] = 17;
SetPlayerCheckpoint(playerid,-1029.0247,-654.1725,32.0078, 5.0);
SendClientMessage(playerid,COLOUR_ORANGE,"Pick up your fuel at Red County Oil Processing.");
TogglePlayerControllable(playerid,1);
}
else if(vehicle == 85 || vehicle == 84 || vehicle == 83)
{
PlayerInfo[playerid][pIsWorking] = 1;
Ccp[playerid] = 18;
SetPlayerCheckpoint(playerid,2794.7849,-1602.4868,10.9287, 5.0);
SendClientMessage(playerid,COLOUR_ORANGE,"Pick up your surplus at the Sprunk Factory..");
TogglePlayerControllable(playerid,1);
}
else
{
SendClientMessage(playerid,COLOUR_RED,"Enter an available truck first!");
}
}
else
{
SendClientMessage(playerid,COLOUR_RED,"Truckers only!");
}
return 1;
}
pawn Код:
public TrailerCheck(playerid)
{
new vehicleid = GetPlayerVehicleID(playerid);
new trailerid = GetVehicleModel(GetVehicleTrailer(vehicleid));
if(IsPlayerInAnyVehicle(playerid))
{
if(IsTrailerAttachedToVehicle(vehicleid) == 1 && trailerid == 450)//dirttrucks
{
KillTimer(TTTimer1);
ShowPlayerDialog(playerid,42,DIALOG_STYLE_LIST,"Available Destinations","Blueberry to Flint County Farm\nBlueberry to the Cemetary\nBlueberry to the Stadium","Select","Cancel");
}
else if(IsTrailerAttachedToVehicle(vehicleid) == 1 && trailerid == 584)//fueltrucks
{
KillTimer(TTTimer1);
ShowPlayerDialog(playerid,43,DIALOG_STYLE_LIST,"Available Destinations","Red County to Flint County\nRed County to Vinewood\nRed County to Idlewood","Select","Cancel");
}
else if(IsTrailerAttachedToVehicle(vehicleid) == 1 && trailerid == 435)//surplustrucks
{
KillTimer(TTTimer1);
ShowPlayerDialog(playerid,44,DIALOG_STYLE_LIST,"Available Destinations","East Beach to Flint County\nEach Beach to Vinewood\nEast Beach to Idlewood","Select","Cancel");
}
}
return 1;
}