Author Topic: /spawncar <name>  (Read 1875 times)

Prada

  • Full Member
  • ***
  • Posts: 142
  • Karma: +15/-18
  • [Mafia Clan] San4eZ
    • View Profile
    • MafiaClan
/spawncar <name>
« on: June 15, 2011, 05:50:21 pm »
Hi all! How to do that instead of ID could inscribe the name of the machine. For example: / Spawncar 105 as needed / spawncar cheetah.

Code: (delphi) [Select]
else if ( szCmd == "spawncar" )
{
if ( szParams )
{
local pTemp = split( szParams, " " ), ID = 90;
if ( IsNum( pTemp[ 0 ] ) ) ID = pTemp[ 0 ].tointeger();

if ( ( ID >= 90 ) && ( ID <= 150 ) )
{
local v = pPlayer.Pos;
MessagePlayer( "Spawning a vehicle with model ID " + ID + "...", pPlayer );
local pVehicle = CreateVehicle( ID, Vector( v.x + 5, v.y, v.z ), pPlayer.Angle );
  if ( pVehicle ) pVehicle.OneTime = true;
}
}
}
« Last Edit: June 15, 2011, 05:55:59 pm by San4ez »

Vortrex

  • Full Member
  • ***
  • Posts: 267
  • Karma: +54/-73
    • View Profile
Re: /spawncar <name>
« Reply #1 on: June 16, 2011, 09:15:32 pm »
This is untested, but it should work (if I didnt put a typo in it):

Code: [Select]
else if ( szCmd == "spawncar" )
{
if (szParams )
{
if ( IsNum( SzParams ) )
{
if ( szParams.tointeger() <= 150 && szParams.tointeger() >= 90 )
{
MessagePlayer( "Spawning a vehicle with model ID " + szParams, pPlayer);
local pVehicle = CreateVehicle( szParams.tointeger(), pPlayer.Pos, pPlayer.Angle );
}
}
else
{
if ( GetVehicleIDFromName( params ) != 0 )
{
MessagePlayer( "Spawning vehicle with model ID " + GetVehicleIDFromName( szParams ), pPlayer);
local pVehicle = CreateVehicle( GetVehicleIDFromName( szParams ), pPlayer.Pos, pPlayer.Angle );
}
else
{
MessagePlayer( "Invalid Model Name", pPlayer);
}
}
}
}
« Last Edit: June 16, 2011, 09:20:57 pm by WtF »

Prada

  • Full Member
  • ***
  • Posts: 142
  • Karma: +15/-18
  • [Mafia Clan] San4eZ
    • View Profile
    • MafiaClan
Re: /spawncar <name>
« Reply #2 on: June 17, 2011, 08:46:54 pm »
Thanks for the help in the script were minor errors but to fix it)

 

© Liberty Unleashed Team.