[Include] Dynamic Vehicle Spawn Menu
#1

Dynamic Vehicles
Good evening!

Today, I am going to release a script I have been working on for a hour of 4 in total. I've had horrible bugs which I couldn't find a solution for, but now - I (think) I have fixed them all.


Vehicle Groups

This script makes you able to dynamically add vehicles to a spawn menu in (a) group(s), let me explain it with a script.

pawn Код:
public OnGameModeInit()
{
    new vehiclegroup[2]; // Since we need the groupid to add vehicle later, we store it.
    vehiclegroup[0] = CreateDynamicVehicleGroup("Cars"); // Create the group "Cars"
    vehiclegroup[1] = CreateDynamicVehicleGroup("Bikes"); // Create the group "Bikes"
    return 0;
}
This stock creates a dynamic vehicle group called "Cars" and a group called "Bikes". Ingame, it will show a dialog, with all the group names, depending on how much you have added.

For a list of functions with their arguments, check down the topic.



You have to manually create a command to show the dialog (a function is included).


Adding vehicles to group

I have explained you earlier how to save the group id, which is necessary for adding vehicles. With the stock called "AddDynamicVehicle" we can add vehicles to the groups.
pawn Код:
public OnGameModeInit()
{
    new vehiclegroup[2];
    vehiclegroup[0] = CreateDynamicVehicleGroup("Cars");
    vehiclegroup[1] = CreateDynamicVehicleGroup("Bikes");
    AddDynamicVehicle(vehiclegroup[0],426,1,1); // Add the vehicle "Premier (ID 426)" to the group "Cars" with the first color white, and the second color also white.
    AddDynamicVehicle(vehiclegroup[1],522,5,1); // Add the vehicle "NRG-500 (ID 522)" to the group "Bikes" with the first color pink, and the second color white.
    return 0;
}
When you press the group "Cars" ingame, you will get the list with vehicles which the group contain. In this case, it will show "Premier".


Installation

- Get the include from Pastebin (R2)
- Save this in your /pawno/includes folder as "DynamicVehicles" and use "#include <DynamicVehicles>" after including a_samp to include this script
- You can now use the functions.
Important note: Don't forget to call _OnDialogResponse in your script's OnDialogResponse!!!

pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    _OnDialogResponse(playerid, dialogid, response, listitem, inputtext);
    return 1;
}

List of functions

pawn Код:
stock CreateDynamicVehicleGroup(groupname[32]) // returns the Group ID (aka the amount of groups created)
stock AddDynamicVehicle(groupid,modelid,color1 = -1,color2 = -1) // returns the amount of dynamic vehicles added
(define) ShowVehicleSpawnDialog(playerid) // Use this in any function to show the vehicle spawn dialog

Credits

You are free to edit this script as you would like, but don't remove the credits at the top, and I would seriously appreciate it if you would put my name in your server-credits.
Jochemd - Script Creator
Jakku - Helped me testing and thinking a bit.

I hope I can help people with this include. Feel free to ask questions in this topic or report any bug (if there) because I will try to keep this script as bugless as possible.


Changelog
Код:
R1 - First release
R2 - Made some strings higher, fixed a bug where the dialogs shouldn't show and removed unnecessary arrays from the enums. Also, uploaded an example filterscript.
© 2012 - Jochemd
Reply


Messages In This Thread
Dynamic Vehicle Spawn Menu - by Jochemd - 03.01.2012, 16:25
Re: Dynamic Vehicle Spawn Menu - by DreveN - 03.01.2012, 16:33
Re: Dynamic Vehicle Spawn Menu - by Jochemd - 03.01.2012, 16:34
Re: Dynamic Vehicle Spawn Menu - by Jakku - 03.01.2012, 16:46
Re: Dynamic Vehicle Spawn Menu - by Jochemd - 04.01.2012, 08:48
Re: Dynamic Vehicle Spawn Menu - by martin3644 - 11.02.2012, 16:21
Re: Dynamic Vehicle Spawn Menu - by 2KY - 11.02.2012, 16:37
Re: Dynamic Vehicle Spawn Menu - by Jochemd - 13.02.2012, 15:19
Re: Dynamic Vehicle Spawn Menu - by korzk7 - 08.04.2012, 10:33
Re: Dynamic Vehicle Spawn Menu - by korzk7 - 08.04.2012, 10:38
Re: Dynamic Vehicle Spawn Menu - by Jochemd - 08.04.2012, 10:44

Forum Jump:


Users browsing this thread: 1 Guest(s)