Vehicle doesn't change/What's a good way?
#6

Quote:
Originally Posted by The__
Посмотреть сообщение
the code was basically similiar to this, Lordzy:

pawn Код:
if(newkeys & KEY_LEFT)
{
         // Swap vehicle to the left.
 return 1;
}
else if(newkeys & KEY_RIGHT)
{
//Swap to the right
return 1;
}
But the thing is the vehicle would never recreate within the code, I used a debug/send player a message if the key was hit, it worked, but the vehicle was never created.
If the debug message worked, then it should've worked with the vehicle too. Perhaps it could be in case if the vehicle limit exceeded. You can try something like this though:

pawn Код:
if(newkeys & KEY_LEFT) {

    if(v_showroom_timer != -1) return 0; //In case if the timer is on; mainly to avoid spam.
    //I'm not going to suddenly create another vehicle, but giving it some time.
    v_showroom_timer = SetTimerEx("LCreateVehicle", 200, false, "d", GetVehicleModel(showroom_car_id)-1);
    DestroyVehicle(showroom_car_id); //showroom_car_id = example vehicle ID
}
else if(newkeys & KEY_RIGHT) {

    if(v_showroom_timer != -1) return 0; //In case if the timer is on; mainly to avoid spam.
    v_showroom_timer = SetTimerEx("LCreateVehicle", 200, false, "d", GetVehicleModel(showroom_car_id)+1);
    DestroyVehicle(showroom_car_id);
}

public LCreateVehicle(modelid) {

    if(modelid < 400)
        modelid = 611;
    else if(modelid > 611)
        modelid = 400;
    showroom_car_id = CreateVehicle(modelid, x_pos, y_pos, z_pos, rotation, col1, col2, -1);
    v_showroom_timer = -1; //Resetting the variable then.
    return 1;
}
Reply


Messages In This Thread
Vehicle doesn't change/What's a good way? - by The__ - 31.08.2014, 16:07
Re: Vehicle doesn't change/What's a good way? - by JasperM - 31.08.2014, 16:11
Re: Vehicle doesn't change/What's a good way? - by meitaredri - 31.08.2014, 16:38
Re: Vehicle doesn't change/What's a good way? - by Lordzy - 31.08.2014, 16:40
Re: Vehicle doesn't change/What's a good way? - by The__ - 31.08.2014, 16:43
Re: Vehicle doesn't change/What's a good way? - by Lordzy - 31.08.2014, 17:05
Re: Vehicle doesn't change/What's a good way? - by Clad - 31.08.2014, 17:07

Forum Jump:


Users browsing this thread: 1 Guest(s)