10.06.2012, 00:16
Currently I am revamping a trucking job on my script. With the lack of an OnPlayerAttachTrailer I'm having to use timers as a trailer check, which I'm absolutely horrible at.
The code below is meant to show dialog 43 when the player hooks up a trailer, however, nothing happens. At all. I'm not sure if the timer is being initiated incorrectly, if I'm killing it too early, or if I'm simply coding what happens when the timer runs out wrongly. Whatever it is, I need some help.
Cheers!
The code below is meant to show dialog 43 when the player hooks up a trailer, however, nothing happens. At all. I'm not sure if the timer is being initiated incorrectly, if I'm killing it too early, or if I'm simply coding what happens when the timer runs out wrongly. Whatever it is, I need some help.
pawn Код:
//At the top of my script
forward TC(playerid);
new TrailerCheck[MAX_PLAYERS];
forward LUC(playerid);
new TTLevelUpCheck[MAX_PLAYERS];
//Initiating the timers by command
YCMD:confirmtruck(playerid, params[], help)
{
if(PlayerInfo[playerid][pJob] == 5)
{
new vehicle = GetPlayerVehicleID(playerid);
if(vehicle == 139 || vehicle == 138 || vehicle == 137)
{
TrailerCheck[playerid] = SetTimerEx("TrailerCheck",1000,true,"i",playerid);
TTLevelUpCheck[playerid] = SetTimerEx("TTLevelUpCheck",1000,true,"i",playerid);
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)
{
TrailerCheck[playerid] = SetTimerEx("TrailerCheck",1000,true,"i",playerid);
TTLevelUpCheck[playerid] = SetTimerEx("TTLevelUpCheck",1000,true,"i",playerid);
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)
{
TrailerCheck[playerid] = SetTimerEx("TrailerCheck",1000,true,"i",playerid);
TTLevelUpCheck[playerid] = SetTimerEx("TTLevelUpCheck",1000,true,"i",playerid);
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;
}
//The bottom of my script
public TC(playerid)
{
new vehicleid = GetPlayerVehicleID(playerid);
new trailerid = GetVehicleModel(GetVehicleTrailer(vehicleid));
if(IsPlayerInAnyVehicle(playerid))
{
if(IsTrailerAttachedToVehicle(vehicleid) == 1 && trailerid == 450)//dirttrucks
{
KillTimer(TrailerCheck[playerid]);
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(TrailerCheck[playerid]);
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(TrailerCheck[playerid]);
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;
}
public LUC(playerid)
{
if(PlayerInfo[playerid][pJob] == 5)
{
if(PlayerInfo[playerid][pTTSoilLevel] == 3)
{
KillTimer(TTLevelUpCheck[playerid]);
PlayerInfo[playerid][pTTLevel] = 2;
SendClientMessage(playerid,COLOUR_ORANGE,"Your trucking level has increased, you can now use level 2 trucks!");
}
if(PlayerInfo[playerid][pTTFuelLevel] == 3)
{
KillTimer(TTLevelUpCheck[playerid]);
PlayerInfo[playerid][pTTLevel] = 3;
SendClientMessage(playerid,COLOUR_ORANGE,"Your trucking level has increased, you can now use level 3 trucks!");
}
if(PlayerInfo[playerid][pTTSurplusLevel] == 3)
{
KillTimer(TTLevelUpCheck[playerid]);
PlayerInfo[playerid][pTTLevel] += 1;
SendClientMessage(playerid,COLOUR_ORANGE,"Your trucking level has increased!");
}
}
return 1;
}