[Include] [INC] Random Vehicle Spawner - v0.1
#1

RandomVehicleSpawner by Matthias - v 0.1

_________________________________________________

1. Introduction

I haven't seen any random vehicle spawner around here, and some peopled added me on msn requesting it, so I thought I'd just release it. If you have a large (roleplay/freeroam) gamemode, it might be cool to have random vehicles around the town. It basically spawns vehicles from the same class on a place. This makes sure you don't have a plane spawning where it should be a normal vehicle.

2. The function

rVehicleSpawner::AddVehicle(vehicleID, Float, Float:y, Float:z, Float:angle, color1, color2, vehicle_class)

vehicleID - This is the starting vehicle. After respawn it'll change to something randomly.
Float - X Coordinate
Float:y - Y Coordinate
Float:z - Z Coordinate
Float:angle - Angle
color1 - First vehicle color
color2 - Second vehicle color
vehicle_class - Class to randomly pic a vehicle from, this can be:

CLASS_NORMAL
CLASS_SPORTS
CLASS_BIKES
CLASS_PLANES
CLASS_HELICOPTERS

Note: Unlike AddStaticVehicle, this function can be used anywhere in your script.

Example of the function:

pawn Code:
rVehicleSpawner::AddVehicle(400, 1368.9396, 2245.4050, 10.8203, 90.0, 156, 156, CLASS_NORMAL);
rVehicleSpawner::AddVehicle(411, 1368.4725, 2250.0930, 10.8203, 90.0, 158, 158, CLASS_SPORTS);
rVehicleSpawner::AddVehicle(488, 1368.4625, 2255.3494, 10.8203, 90.0, 157, 157, CLASS_BIKES);
rVehicleSpawner::AddVehicle(460, 1368.0641, 2260.8308, 10.8203, 90.0, 155, 155, CLASS_PLANES);
rVehicleSpawner::AddVehicle(417, 1368.0641, 2265.8308, 10.8203, 90.0, 160, 160, CLASS_HELICOPTERS);
You can easily make more classes or edit them. Just open the .inc file and add/edit the arrays, then go to OnVehicleSpawn and add your new class to the switch() statement.

3. How to install

1. Download the include file and put it in pawno/include/
2. Add rVehicleSpawner::OnVehicleSpawn( vehicleid ) to OnVehicleSpawn in your filterscript or gamemode.
3. Use the function!

I've included an example filterscript with two commands. Just download the example FS, compile it, and run it on your server. /tpme teleports you to the random vehicles and /respawn respawns the vehicle, and it should spawn a random one from that class.

4. Download

* rVehicleSpawner.pwn (Pastebin)
* rVehicleSpawn.inc (Pastebin)
* rVehicleSpawner.pwn (UploadFFS)
* rVehicleSpawner.inc (UploadFFS)

5. Changelog

v 0.1 - 28/03/10

* Initial release

6. Credits

Everything has been made by me. You are not allowed to edit and republish this without my permission. Feel free to edit it and use it on your server though.

If you find any bugs, reply in this topic please.

~Matthias
Reply
#2

Using it thanks
Reply
#3

Very nice!
Reply
#4

Nice very useful when setting multiple cars in rp servers.
Reply
#5

Thanks
Reply
#6

Gonna go try it out later, sounds like a good thing.

Thanks for sharing.
Reply
#7

Thanks guys
Reply
#8

Not bad m8, keep up the good work
Reply
#9

Interesting...
Reply
#10

Thanks ;p
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)