[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
#2

Something I do not see a link to a file.
Reply
#3

Quote:
Originally Posted by DreveN
Посмотреть сообщение
Something I do not see a link to a file.
See the "Installation" header.
Reply
#4

Thank you for the credits
Reply
#5

Quote:
Originally Posted by Jakku
Посмотреть сообщение
Thank you for the credits
No problem!
Reply
#6

How To Create A /veh Command For This Script?
I'm noob in Scripting, Need Help! :S
Reply
#7

Quote:
Originally Posted by martin3644
Посмотреть сообщение
How To Create A /veh Command For This Script?
I'm noob in Scripting, Need Help! :S
pawn Код:
#define MAX_VEHICLE_GROUPS 100

new
    VehicleGroups[MAX_VEHICLE_GROUPS] = -1;

CMD:veh(playerid, params[]) {
   
    if(IsPlayerAdmin(playerid)) //Works for RCON admin!
    {
        new
            VehicleModelID,
            VehicleColorPrimary,
            VehicleColorSecondary,
            VehicleGroup[32],
            UseThisID = -1
        ;
       
        if(sscanf(params, "iiis[32]", VehicleModelID, VehicleColorPrimary, VehicleColorSecondary, VehicleGroup))
            return SendClientMessage(playerid, 0xFFFFFFFF, "/veh [Model ID] [Primary Colour] [Secondary Colour] [Vehicle Group]");
           
        for(new g; g < sizeof(VehicleGroups); g++)
        {
            if(VehicleGroups[g] == -1)
                return UseThisID = g;
        }
       
        VehicleGroups[g] = CreateDynamicVehicleGroup(VehicleGroup);
        AddDynamicVehicle(VehicleGroups[g], VehicleModelID, VehicleColorPrimary, VehicleColorSecondary);
        UseThisID = -1;
    }
    return true;
}
Something like this would PROBABLY work. (I have not compiled nor tested it)
Reply
#8

Quote:
Originally Posted by martin3644
Посмотреть сообщение
How To Create A /veh Command For This Script?
I'm noob in Scripting, Need Help! :S
Do you mean a way to show the dialog? Because I implemented the function "ShowVehicleSpawnDialog(playerid)".
Reply
#9

How to Actived this Script
Quote:

#define MAX_VEHICLE_GROUPS 100

new
VehicleGroups[MAX_VEHICLE_GROUPS] = -1;

CMD:veh(playerid, params[]) {

if(IsPlayerAdmin(playerid)) //Works for RCON admin!
{
new
VehicleModelID,
VehicleColorPrimary,
VehicleColorSecondary,
VehicleGroup[32],
UseThisID = -1
;

if(sscanf(params, "iiis[32]", VehicleModelID, VehicleColorPrimary, VehicleColorSecondary, VehicleGroup))
return SendClientMessage(playerid, 0xFFFFFFFF, "/veh [Model ID] [Primary Colour] [Secondary Colour] [Vehicle Group]");

for(new g; g < sizeof(VehicleGroups); g++)
{
if(VehicleGroups[g] == -1)
return UseThisID = g;
}

VehicleGroups[g] = CreateDynamicVehicleGroup(VehicleGroup);
AddDynamicVehicle(VehicleGroups[g], VehicleModelID, VehicleColorPrimary, VehicleColorSecondary);
UseThisID = -1;
}
return true;
}

is Not Work Please I am Noob Scripter Please Help Me, I Complie that is Error, For Jochemd Chek PM from me Plase Help me
Reply
#10

Quote:
Originally Posted by Jochemd
Посмотреть сообщение
Do you mean a way to show the dialog? Because I implemented the function "ShowVehicleSpawnDialog(playerid)".
How to Actived Dude Help Me
Reply
#11

Quote:
Originally Posted by korzk7
Посмотреть сообщение
How to Actived this Script


is Not Work Please I am Noob Scripter Please Help Me, I Complie that is Error, For Jochemd Chek PM from me Plase Help me
That script won't even work I think. It's not that complex as that guy says.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)