car spawn
#1

Anyone how to make spawn car with id/model.because i get this fuction

Quote:

//Get the vehicle's name
native GetVehicleName(vehicleid, string[], len = sizeof(string));

//Get the vehicle model's name
native GetVehicleModelName(modelid, string[], len = sizeof(string));

From https://sampforum.blast.hk/showthread.php?tid=577156
Reply
#2

anyone
Reply
#3

What?

Код:
new tmpcar = CreateVehicle()
GetVehicleName(tmpcar)
SendClientMessage()
Reply
#4

how to make id car?
Reply
#5

Код:
        new name[35];
        new tmpcar = CreateVehicle();
	GetVehicleName(tmpcar, name);
	
	new string[45];
	format(string, sizeof string, "~y~%s", name);
	GameTextForPlayer(playerid, string, 5000, 1);
You need to work on learning some scripting, or at least how to follow examples.
Reply
#6

No i mean.how to spawn car with id/modelname using this function because this function work without array car name
Reply
#7

exemple ?
/veh [CAR]
Reply
#8

I think you should write your own function to use the names of cars.
First you need an array like this:
PHP код:
new VehicleNames[212][] =
{
    {
"Landstalker"},
    {
"Bravura"},
    {
"Buffalo"},
    {
"Linerunner"},
    {
"Perrenial"},
    {
"Sentinel"},
    {
"Dumper"},
    {
"Firetruck"},
    {
"Trashmaster"},
    {
"Stretch"},
    {
"Manana"},
    {
"Infernus"},
    {
"Voodoo"},
    {
"Pony"},
    {
"Mule"},
    {
"Cheetah"},
    {
"Ambulance"},
    {
"Leviathan"},
    {
"Moonbeam"},
    {
"Esperanto"},
    {
"Taxi"},
    {
"Washington"},
    {
"Bobcat"},
    {
"Mr Whoopee"},
    {
"BF Injection"},
    {
"Hunter"},
    {
"Premier"},
    {
"Enforcer"},
    {
"Securicar"},
    {
"Banshee"},
    {
"Predator"},
    {
"Bus"},
    {
"Rhino"},
    {
"Barracks"},
    {
"Hotknife"},
    {
"Trailer 1"},
    {
"Previon"},
    {
"Coach"},
    {
"Cabbie"},
    {
"Stallion"},
    {
"Rumpo"},
    {
"RC Bandit"},
    {
"Romero"},
    {
"Packer"},
    {
"Monster"},
    {
"Admiral"},
    {
"Squalo"},
    {
"Seasparrow"},
    {
"Pizzaboy"},
    {
"Tram"},
    {
"Trailer 2"},
    {
"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"},
    {
"Cropdust"},
    {
"Stunt"},
    {
"Tanker"},
    {
"Roadtrain"},
    {
"Nebula"},
    {
"Majestic"},
    {
"Buccaneer"},
    {
"Shamal"},
    {
"Hydra"},
    {
"FCR-900"},
    {
"NRG-500"},
    {
"HPV-1000"},
    {
"Cement Truck"},
    {
"Tow Truck"},
    {
"Fortune"},
    {
"Cadrona"},
    {
"FBI-Truck"},
    {
"Willard"},
    {
"Forklift"},
    {
"Tractor"},
    {
"Combine"},
    {
"Feltzer"},
    {
"Remington"},
    {
"Slamvan"},
    {
"Blade"},
    {
"Freight"},
    {
"Streak"},
    {
"Vortex"},
    {
"Vincent"},
    {
"Bullet"},
    {
"Clover"},
    {
"Sadler"},
    {
"Firetruck LA"},
    {
"Hustler"},
    {
"Intruder"},
    {
"Primo"},
    {
"Cargobob"},
    {
"Tampa"},
    {
"Sunrise"},
    {
"Merit"},
    {
"Utility"},
    {
"Nevada"},
    {
"Yosemite"},
    {
"Windsor"},
    {
"Monster A"},
    {
"Monster B"},
    {
"Uranus"},
    {
"Jester"},
    {
"Sultan"},
    {
"Stratum"},
    {
"Elegy"},
    {
"Raindance"},
    {
"RC Tiger"},
    {
"Flash"},
    {
"Tahoma"},
    {
"Savanna"},
    {
"Bandito"},
    {
"Freight Flat"},
    {
"Streak Carriage"},
    {
"Kart"},
    {
"Mower"},
    {
"Duneride"},
    {
"Sweeper"},
    {
"Broadway"},
    {
"Tornado"},
    {
"AT-400"},
    {
"DFT-30"},
    {
"Huntley"},
    {
"Stafford"},
    {
"BF-400"},
    {
"Newsvan"},
    {
"Tug"},
    {
"Trailer 3"},
    {
"Emperor"},
    {
"Wayfarer"},
    {
"Euros"},
    {
"Hotdog"},
    {
"Club"},
    {
"Freight Carriage"},
    {
"Trailer 3"},
    {
"Andromada"},
    {
"Dodo"},
    {
"RC Cam"},
    {
"Launch"},
    {
"Police Car"},
    {
"Police Car"},
    {
"Police Car"},
    {
"Ranger"},
    {
"Picador"},
    {
"S.W.A.T. Van"},
    {
"Alpha"},
    {
"Phoenix"},
    {
"Glendale"},
    {
"Sadler"},
    {
"Luggage Trailer A"},
    {
"Luggage Trailer B"},
    {
"Stair Trailer"},
    {
"Boxville"},
    {
"Farm Plow"},
    {
"Utility Trailer"}
};
stock GetVehicleModelID(modelname[])
{
new 
modelid//Used for storing the modelid;     
for(new i212i++)
{
    if(!
strcmp(modelname,VehicleNames[i],true))   
    {      
        
modelid 400;
        return 
modelid;  
    }
}
return 
0;

And the command will be: (in case you use ZCMD)
PHP код:
CMD:veh(playerid,params[])
{
    if(!
IsPlayerAdmin(playerid)) return 1//This means: "If the player is not rcon admin return 1"
    
if(isnull(params))  return SendClientMessage(playerid,-1,"ERROR: No car"); //This means: "If the string is null"
    
new c//Used to store the modelid of car
        
if(IsNumeric(params))  strval(params); //This means: "If params is numeric"
        
else GetVehicleModelID(params);
    if(
c<400 || c>611)   return SendClientMessage(playerid,-1,"ERROR: Invalid Car ID");
    new 
Float:pos[3],car;
    
GetPlayerPos(playerid,pos[0],pos[1],pos[2]);
    
car CreateVehicle(c,pos[0],pos[1],pos[2],random(255),random(255),0,-1,1);
    
PutPlayerInVehicle(playerid,car,0);
    
SendClientMessage(playerid,-1,"SPAWNED CAR"); 
    return 
1;

PS: Haven't tested the code, but it should work
EDIT: Changed the ignore case to true in stock GetVehicleModelID
Reply
#9

Quote:
Originally Posted by 10MIN
Посмотреть сообщение
I think you should write your own function to use the names of cars.
If you read the OPs post, he's using an include that does that...



And what he's actually been wanting, now seems like he wants /spawn Elegy to spawn an elegy...
Reply
#10

My code is doing that thing. If I type in game /veh Sultan or /veh 560 (560 is the modelid of sultan) it gives me a sultan.
Also by:
Quote:
Originally Posted by 10MIN
Посмотреть сообщение
I think you should write your own function to use the names of cars
I was reffering to the thing he should write a function to convert from ModelName to ModelID.
PS: Tested it in game 10 minutes ago and it works.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)