12.08.2017, 07:18
Hello, I have this script for the vehicle spawn, but I can't spawn more than one vehicle, because this script deletes the previous vehicle... Does somebody know the solution for this problem?
This is the script:
This is the script:
Quote:
#include <a_samp> #include <sscanf2> #include <zcmd> new vehicle_spawn[MAX_PLAYERS]; // Create a variable to give only a vehicle to the user new NameVehicles[][] = // Name the all vehicles { "Landstalker", "Bravura", "Buffalo", "Linerunner", "Perrenial", "Sentinel", "Dumper", "Firetruck", "Trashmaster", "Stretch", "Manana", "Infernus", "Voodoo", "Pony", "Mule", "Cheetah", "Ambulance", "Leviathan", "Moonbeam", "Esperanto", "Taxi", "Washington", "Bobcat", "Whoopee", "BF Injection", "Hunter", "Premier", "Enforcer", "Securicar", "Banshee", "Predator", "Bus", "Rhino", "Barracks", "Hotknife", "Trailer", "Previon", "Coach", "Cabbie", "Stallion", "Rumpo", "RC Bandit", "Romero", "Packer", "Monster", "Admiral", "Squalo", "Seasparrow", "Pizzaboy", "Tram", "Trailer", "Turismo", "Speeder", "Reefer", "Tropic", "Flatbed", "Yankee", "Caddy", "Solair", "Berkley's RC Van", "Skimmer", "PCJ-600", "Faggio", "Freeway", "RC Baron", "RC Raider", "Glendale", "Oceanic","Sanchez", "Sparrow", "Patriot", "Quad", "Coastguard", "Dinghy", "Hermes", "Sabre", "Rustler", "ZR-350", "Walton", "Regina", "Comet", "BMX", "Burrito", "Camper", "Marquis", "Baggage", "Dozer", "Maverick", "News Chopper", "Rancher", "FBI Rancher", "Virgo", "Greenwood", "Jetmax", "Hotring", "Sandking", "Blista Compact", "Police Maverick", "Boxville", "Benson", "Mesa", "RC Goblin", "Hotring Racer A", "Hotring Racer B", "Bloodring Banger", "Rancher", "Super GT", "Elegant", "Journey", "Bike", "Mountain Bike", "Beagle", "Cropduster", "Stunt", "Tanker", "Roadtrain", "Nebula", "Majestic", "Buccaneer", "Shamal", "Hydra", "FCR-900", "NRG-500", "HPV1000", "Cement Truck", "Tow Truck", "Fortune", "Cadrona", "FBI Truck", "Willard", "Forklift", "Tractor", "Combine", "Feltzer", "Remington", "Slamvan", "Blade", "Freight", "Streak", "Vortex", "Vincent", "Bullet", "Clover", "Sadler", "Firetruck", "Hustler", "Intruder", "Primo", "Cargobob", "Tampa", "Sunrise", "Merit", "Utility", "Nevada", "Yosemite", "Windsor", "Monster", "Monster", "Uranus", "Jester", "Sultan", "Stratium", "Elegy", "Raindance", "RC Tiger", "Flash", "Tahoma", "Savanna", "Bandito", "Freight Flat", "Streak Carriage", "Kart", "Mower", "Dune", "Sweeper", "Broadway", "Tornado", "AT-400", "DFT-30", "Huntley", "Stafford", "BF-400", "News Van", "Tug", "Trailer", "Emperor", "Wayfarer", "Euros", "Hotdog", "Club", "Freight Box", "Trailer", "Andromada", "Dodo", "RC Cam", "Launch", "Police Car", "Police Car", "Police Car", "Police Ranger", "Picador", "S.W.A.T", "Alpha", "Phoenix", "Glendale", "Sadler", "Luggage", "Luggage", "Stairs", "Boxville", "Tiller", "Utility Trailer" }; stock CreateVehicleEx(playerid, modelid) // With this feature we can create vehicles in all our indent usage CreateVehicleEx(playerid, modelid); { new Floatos[4]; // Create float 4 slots to obtain pos_x, pos_y, pos_z and GetVehicleZangle If you are in a vehicle the user. if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER) // obtain getplayerstate (if this driver).. { GetVehiclePos(GetPlayerVehicleID(playerid), pos[0], pos[1], pos[2]); // Obtain position in the floats. GetVehicleZAngle(GetPlayerVehicleID(playerid), pos[3]); // obtan angle vehicle. DestroyVehicle(GetPlayerVehicleID(playerid)); // Destroy last vehicle created and continue function. } else // if not this driver.. { GetPlayerPos(playerid, pos[0], pos[1], pos[2]); // obtain position in the floats. GetPlayerFacingAngle(playerid, pos[3]); // obtain angle playerid and continue function.. } if(vehicle_spawn[playerid] != 0) DestroyVehicle(vehicle_spawn[playerid]); // if variable is greater than 0 destroy the last vehicle created. vehicle_spawn[playerid] = CreateVehicle(modelid, pos[0], pos[1], pos[2], pos[3], -1, -1, 60); // Create vehicle in pos obtain the floats. LinkVehicleToInterior(vehicle_spawn[playerid], GetPlayerInterior(playerid)); // Changes inside the vehicle to which the user is located. SetVehicleVirtualWorld(vehicle_spawn[playerid], GetPlayerVirtualWorld(playerid)); // Change the world the vehicle spawn to which you will find a player PutPlayerInVehicle(playerid, vehicle_spawn[playerid], 0); // The playerid enters the vehicle and driver. SetVehicleZAngle(vehicle_spawn[playerid], pos[3]); // Set angle te obtain float. return true; } command(veh, playerid, params[]) { if(IsNumeric(params)) // if is numeric params. { if(sscanf(params, "i", params[0])) return SendClientMessage(playerid, -1, "usage: /veh <name/modelid>."); if(params[0] < 400 || params[0] > 611) return SendClientMessage(playerid, -1, "modelid invalid, usage: /veh <modelid 400-611>."); CreateVehicleEx(playerid, params[0]); } else // not is numeric { new name_vehicle[30], i_create_vehicle; if(sscanf(params, "s[30]", name_vehicle)) return SendClientMessage(playerid, -1, "usage: /veh <name/modelid>."); i_create_vehicle = GetModelVehicle(name_vehicle); if(i_create_vehicle < 400 || i_create_vehicle > 611) return SendClientMessage(playerid, -1, "name invalid, usage: /veh <name correct>."); CreateVehicleEx(playerid, i_create_vehicle); } return true; } stock IsNumeric(const string[]) // function comprobate is numeric { for (new i = 0, j = strlen(string); i < j; i++) { if (string[i] > '9' || string[i] < '0') return 0; } return true; } stock GetModelVehicle(vname[]) // fuction getmodelvehicle in the names { for(new i = 0; i < 211; i++) { if(strfind(NameVehicles[i], vname, true) != -1) return i + 400; } return false; } |