• Welcome to Vice City Multiplayer.
 

[CP] Vehicle array

Started by Ettans, February 20, 2010, 03:41:37 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Ettans

Here's an array with vehicle names, it's in order so you can use it to get the vehicles model from the name. You can use it to spawn vehicles by typing their name, instead of the model ID etc. You can find the array at the bottom of the post, simply put it near the top of your gamemode, among other defines and variables.


The array:


new vArray[107][] =
{
       {"Landstalker"},
       {"Idaho"},
{"Stinger"},
{"Linerunner"},
{"Perennial"},
{"Sentinel"},
{"Rio"},
{"Firetruck"},
{"Trashmaster"},
{"Stretch"},
{"Manana"},
{"Infernus"},
{"Voodoo"},
{"Pony"},
{"Mule"},
{"Cheetah"},
{"Ambulance"},
{"FBI Washington"},
{"Moonbeam"},
{"Esperanto"},
{"Taxi"},
{"Washington"},
{"Bobcat"},
{"Mr Whoopee"},
{"BF Injection"},
{"Hunter"},
{"Police"},
{"Enforcer"},
{"Securicar"},
{"Banshee"},
{"Predator"},
{"Bus"},
{"Rhino"},
{"Barracks"},
{"Cuban Hermes"},
{"Helicopter"}, // WARNING: Crashes the client if exited
{"Angel"},
{"Coach"},
{"Cabbie"},
{"Stallion"},
{"Rumpo"},
{"RC Bandit"},
{"Romero's Hearse"},
{"Packer"},
{"Sentinel XS"},
{"Admiral"},
{"Squalo"},
{"Sea Sparrow"},
{"Pizza Boy"},
{"Gang Burrito"},
{" "}, // UNKNOWN ID
{" "}, // UNKNOWN ID
{"Speeder"},
{"Reefer"},
{"Tropic"},
{"Flatbed"},
{"Yankee"},
{"Caddy"},
{"Zebra Cab"},
{"Top Fun"},
{"Skimmer"},
{"PCJ 600"},
{"Faggio"},
{"Freeway"},
{"RC Baron"}, // WARNING: Crashes the client if exited
{"RC Raider"}, // WARNING: Crashes the client if exited
{"Glendale"},
{"Oceanic"},
{"Sanchez"},
{"Sparrow"},
{"Patriot"},
{"Love Fist"},
{"Coast Guard"},
{"Dinghy"},
{"Hermes"},
{"Sabre"},
{"Sabre Turbo"},
{"Phoenix"},
{"Walton"},
{"Regina"},
{"Comet"},
{"Deluxo"},
{"Burrito"},
{"Spand Express"},
{"Marquis"},
{"Baggage Handler"},
{"Kaufman Cab"},
{"Maverick"},
{"VCN Maverick"},
{"Rancher"},
{"FBI Rancher"},
{"Virgo"},
{"Greenwood"},
{"Cuban Jetmax"},
{"Hotring Racer 1"},
{"Sandking"},
{"Blista Compact"},
{"Police Maverick"},
{"Benson"},
{"Boxville"},
{"Mesa Grande"},
{"RC Goblin"},
{"Hotring Racer 2"},
{"Hotring Racer 3"},
{"Bloodring Banger 1"},
{"Bloodring Bander 2"},
{"FBI Cheetah"}
};



Example command: !vehicle
Description: Type !vehicle <name> to spawn the vehicle.


/*

new cmd[256],
   string[128],
   idx,
   cmd = strtok(cmdtext, idx);

*/

// Add to OnPlayerText callback and make sure you have the variables shown above present already.

if(strcmp(cmd,"!vehicle",true) == 0)
{
   new Float:x,
       Float:y,
       Float:z,
Float:angle,
vDat,
       pveh[MAX_PLAYERS] = 0;

   vDat = vModelFromName(cmdtext[9]);
   GetPlayerPos(playerid,x,y,z);
   GetPlayerFacingAngle(playerid,angle);

   if(vDat < 130 || vDat > 236)
   {
       SendClientMessage(playerid,COLOR_GREY,"Invalid model ID or name!");
       return 0;
   }

   pveh[playerid] = CreateVehicle(vDat,x,y,z,angle,-1,-1,100);
   PutPlayerInVehicle(playerid,pveh[playerid]);
   format(string,sizeof(string),"Spawned a %s",vArray[vDat - 130]);
   SendClientMessage(playerid,COLOR_GREEN,string);
   return 0;
}



Additional function: vModelFromName
Description: Gets the vehicle model ID from the name, using the array.


vModelFromName(vName[])
{
   for(new i = 0; i < 109; i++)
       if(strfind(vArray[i],vName,true) != -1 )
           return i+130;
   return -1;
}



Pastebin link of array: http://pastebin.com/f3afd52cf
Pastebin link of vModelFromName: http://pastebin.com/f5851c541
Pastebin link of example command: http://pastebin.com/f30444fc6

Jancis_LV

Something for me dont work, nothing happens just shows: Spawned a PCJ-600!
Latvian Vice City server
78.84.47.75:5192

Ettans


-TriX-



www.life-urban.co.cc

BCKLUP

#4
The !vehicle command(+ the vehicle arrays) compiled with only 2 errors:

C:\DOCUME~1\REMOTE~1\Desktop\ETC\GTASTU~1\Servers\vcmpserv\GAMEMO~1\pmdm.pwn(2555) : warning 202: number of arguments does not match definition
C:\DOCUME~1\REMOTE~1\Desktop\ETC\GTASTU~1\Servers\vcmpserv\GAMEMO~1\pmdm.pwn(2557) : error 017: undefined symbol "vArray"
Pawn compiler 3.0.3367 Copyright (c) 1997-2005, ITB CompuPhase


1 Error.


I was sure i put the Vehicle arrays.

EDIT: Solved the "undefined symbol "vArray"" error by puttin the array at the very top of my script with the random messages are
now what's left is a error ill Try if it work.

IT DIDN'T WORK

thijn

What did not worked?
What did you tried?

make sure you enter the ID correct
so only IDs from 130 till 236


Ettans

Please post the line that didn't work. By the way, you don't have to only use ID's, you can also just use !vehicle sanchez for example, that's the whole point, getting model ID from name.

Jancis_LV

There is problem with CreateVehicle, script is OK
Latvian Vice City server
78.84.47.75:5192

Ettans

Changed it around, as I scripted it in another version. Please post any bugs you may get, including the exact line (not the number of the line).  :)

Robd

it compiles but when I use the command the car doesnt spawn and it gives me a message on console
"SCRIPT: Bad paramater count (32 != 7):
Hello, this is Robd from the past.
If you are seeing this I have either posted something stupid, forgotten something, started a stupid topic, or a combination of the three.

Please forgive us for this mistake.

Regards, management