Quote:
Originally Posted by Mencent
I think an option is to use a timer. There are many other solutions, but try this:
PHP Code:
//global variable:
new TruckTimer[MAX_PLAYERS];
//when you enter the truck:
TruckTimer[playerid] = SetTimerEx("OnPlayerAttachTrailer",1000,1,"i",playerid);
//when you left the truck:
KillTimer(TruckTimer[playerid]);
TruckTimer[playerid] = 0;
forward OnPlayerAttachTrailer(playerid);
public OnPlayerAttachTrailer(playerid)
{
new vehicleid = GetPlayerVehicleID(playerid);
if(!IsTrailerAttachedToVehicle(vehicleid))return 1;
if(pInfo[playerid][pLevel] > 2)
{
if(GetPVarInt(playerid,"TRUCK_MERCH") == 1)
{
new Tipe[20],trailerid = GetVehicleTrailer(vehicleid);
switch(GetVehicleModel(trailerid))
{
case 435: Tipe = "Cereal";
}
SetPlayerCheckpoint(playerid, -2457.8601,2291.7852,5.0990, 7);
SetPVarInt(playerid, "TRUCK_MERCH", 2);
DeletePVar(playerid, "TRUCK_GO");
c_clvl2_e1_b = false;
SendClientMessage(playerid, -1, "Go to the checkpoint");
RemovePlayerMapIcon(playerid, CEREAL_DEPOSIT);
SetPVarInt(playerid, "TRUCK_GOING", 2);
return 1;
}
}
return 1;
}
|
Code:
warning 219: local variable "vehicleid" shadows a variable at a preceding level
warning 219: local variable "trailerid" shadows a variable at a preceding level