Vice City Multiplayer

VC:MP => mIRC/pawn Scripting => ShowRoom (pawn) => Topic started by: Ettans on February 20, 2010, 03:41:37 PM

Title: [CP] Vehicle array
Post by: Ettans on February 20, 2010, 03:41:37 PM
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
Title: Re: Vehicle array
Post by: Jancis_LV on February 20, 2010, 03:55:53 PM
Something for me dont work, nothing happens just shows: Spawned a PCJ-600!
Title: Re: Vehicle array
Post by: Ettans on February 20, 2010, 04:03:47 PM
Try with this command: http://pastebin.com/f30444fc6
Title: Re: Vehicle array
Post by: -TriX- on February 20, 2010, 05:02:07 PM
Good Work Man  ;D
Title: Re: [CP] Vehicle array
Post by: BCKLUP on March 15, 2010, 11:12:15 AM
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
Title: Re: [CP] Vehicle array
Post by: thijn on March 15, 2010, 12:45:16 PM
What did not worked?
What did you tried?

make sure you enter the ID correct
so only IDs from 130 till 236
Title: Re: [CP] Vehicle array
Post by: Ettans on March 15, 2010, 02:59:16 PM
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.
Title: Re: [CP] Vehicle array
Post by: Jancis_LV on March 15, 2010, 04:37:37 PM
There is problem with CreateVehicle, script is OK
Title: Re: [CP] Vehicle array
Post by: Ettans on March 15, 2010, 05:50:52 PM
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).  :)
Title: Re: [CP] Vehicle array
Post by: Robd on February 06, 2011, 04:58:40 AM
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):