SA-MP Forums Archive
Vehicle doesn't change/What's a good way? - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Vehicle doesn't change/What's a good way? (/showthread.php?tid=534829)



Vehicle doesn't change/What's a good way? - The__ - 31.08.2014

I'm trying to find a new way to create a vehicle dealership, it being custom, I thought of using NUMPAD 4 and 6 to swap vehicles, but when I do that, it only uses NUMPAD 4, and 6 doesn't work + the vehicle doesn't recreate (I apparently deleted the code last night too.)

So, in your opinion, what's a great way to for a vehicle dealership? Dialogs? Or what?


Re: Vehicle doesn't change/What's a good way? - JasperM - 31.08.2014

Textdraws I think


Re: Vehicle doesn't change/What's a good way? - meitaredri - 31.08.2014

Use "CreateSelectionMenu(playerid);"

I think it's the best thing to do it's come up with 0.3x I think +Rep if I helped


Re: Vehicle doesn't change/What's a good way? - Lordzy - 31.08.2014

I'm not sure why you cannot detect NUMPAD 6, without viewing your code I cannot really predict the issue. However, keypads are defined well here : https://sampwiki.blast.hk/wiki/Keys

Your idea is actually better than dialogs but there's a chance where functions could get spammed if you're not keeping any spam limits. In case if the player keeps on pressing 4 or 6 always, the creation and re-creation of the vehicle could spam which would lead the server to lag. IMHO, your current idea is better. But also mentioning that you should look up with the timing where the callback is getting called or else it could lead the server to lag.


Re: Vehicle doesn't change/What's a good way? - The__ - 31.08.2014

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.


Re: Vehicle doesn't change/What's a good way? - Lordzy - 31.08.2014

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;
}



Re: Vehicle doesn't change/What's a good way? - Clad - 31.08.2014

Why don't you use ClickableTextdraw ? It will be awsome.