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

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?
Reply
#2

Textdraws I think
Reply
#3

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
Reply
#4

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.
Reply
#5

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.
Reply
#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
#7

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


Forum Jump:


Users browsing this thread: 1 Guest(s)