Author Topic: CreateVehicle  (Read 4513 times)

Kevin

  • Newbie
  • *
  • Posts: 32
  • Karma: +9/-35
    • View Profile
    • www.edgarcain.zz.mu
CreateVehicle
« on: November 16, 2016, 03:02:02 am »
Server crashed when creating vehicle, help version 0.17
Code: [Select]
function onPlayerCommand( pPlayer, szCommand, szText )
{
if ( szCommand == "veh" )
{
CreateVehicle( VEH_INFERNUS, pPlayer.Pos, pPlayer.Angle, -1, -1 );
}
 
return 1;
}
 
Kevin  ;)

Motley

  • Full Member
  • ***
  • Posts: 253
  • Karma: +32/-34
    • View Profile
Re: CreateVehicle
« Reply #1 on: November 16, 2016, 03:44:58 am »
Hey Kevin, Welcome back to LU  :).

I just want to add in the server package there is a vehicle command already there  ;)

I hope this is helpful. If you only want that one vehicle I can script it for you  :), Just reply back with what you want.
Code: [Select]
function onPlayerCommand( pPlayer, szCmd, szParams )
{
if ( szCmd == "mypos" )
{
local v = pPlayer.Pos;
Message( pPlayer.Name + " is currently at " + v.x + ", " + v.y + ", " + v.z );
}

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 );
CreateVehicle( ID, Vector( v.x + 5, v.y, v.z ), pPlayer.Angle );
}
}
}

else if ( szCmd == "health" )
{
if ( !szParams ) MessagePlayer( "Your Health: " + pPlayer.Health, pPlayer );
else
{
local pTemp = split( szParams, " " ), p = GetPlayer( pTemp[ 0 ] );
if ( p )
{
if ( p.Spawned ) MessagePlayer( pPlayer.Name + "'s Health: " + p.Health, pPlayer );
else MessagePlayer( "This person isn't spawned nub!", pPlayer );
}
else MessagePlayer( "Can't find anyone with that id/nick", pPlayer );
}
}

else if ( szCmd == "armour" )
{
if ( !szParams ) MessagePlayer( "Your Armour: " + pPlayer.Armour, pPlayer );
else
{
local pTemp = split( szParams, " " ), p = GetPlayer( pTemp[ 0 ] );
if ( p )
{
if ( p.Spawned ) MessagePlayer( pPlayer.Name + "'s Armour: " + p.Armour, pPlayer );
else MessagePlayer( "This person isn't spawned nub!", pPlayer );
}
else MessagePlayer( "Can't find anyone with that id/nick", pPlayer );
}
}

else if ( szCmd == "goto" )
{
if ( !szParams ) MessagePlayer( "Error - Need to specify a target player.", pPlayer );
else
{
local pTemp = split( szParams, " " ), p = GetPlayer( pTemp[ 0 ] );
if ( p )
{
if ( p.Spawned )
{
Message( "Taking " + pPlayer.Name + " to " + p.Name, Colour( 0, 255, 0 ) );
pPlayer.Pos = p.Pos;
pPlayer.Pos.y += 5;
pPlayer.Pos.z += 2;
}
else MessagePlayer( "This person isn't spawned nub!", pPlayer );
}
else MessagePlayer( "Can't find anyone with that id/nick", pPlayer );
}
}

else if ( szCmd == "bring" )
{
if ( !szParams ) MessagePlayer( "Error - Need to specify a target player.", pPlayer );
else
{
local pTemp = split( szParams, " " ), p = GetPlayer( pTemp[ 0 ] );
if ( p )
{
if ( p.Spawned )
{
Message( "Taking " + p.Name + " to " + pPlayer.Name, Colour( 0, 255, 0 ) );
p.Pos = pPlayer.Pos;
p.Pos.y += 5;
p.Pos.z += 2;
}
else MessagePlayer( "This person isn't spawned nub!", pPlayer );
}
else MessagePlayer( "Can't find anyone with that id/nick", pPlayer );
}
}

return 1;
}

function GetPlayer( target )
{
target = target.tostring();

if ( IsNum( target ) )
{
target = target.tointeger();

if ( FindPlayer( target ) ) return FindPlayer( target );
else return null;
}
else if ( FindPlayer( target ) ) return FindPlayer( target );
else return null;
}


Kevin

  • Newbie
  • *
  • Posts: 32
  • Karma: +9/-35
    • View Profile
    • www.edgarcain.zz.mu
Re: CreateVehicle
« Reply #2 on: November 16, 2016, 01:51:10 pm »
Oo thank you, I see that I changed some things
Kevin  ;)

JamesConway

  • Newbie
  • *
  • Posts: 39
  • Karma: +9/-3
    • View Profile
Re: CreateVehicle
« Reply #3 on: November 16, 2016, 02:21:31 pm »
Oo thank you, I see that I changed some things
You managed to fix it? And how did you fixed it if you did?

Kevin

  • Newbie
  • *
  • Posts: 32
  • Karma: +9/-35
    • View Profile
    • www.edgarcain.zz.mu
Re: CreateVehicle
« Reply #4 on: November 16, 2016, 04:38:40 pm »

Keep crashing server, you can better pass me the version server windows version.0.17  :'( :'( :'( :'( :'(
Kevin  ;)

Rhytz

  • Newbie
  • *
  • Posts: 30
  • Karma: +13/-7
    • View Profile
    • Rhytz's Website
Re: CreateVehicle
« Reply #5 on: November 16, 2016, 05:54:08 pm »
I've tested your code and it works just fine. Maybe some other script is causing trouble in combination with this one?
Meet everyone on the Liberty Unleashed Discord || Check out my website/portal!

Kevin

  • Newbie
  • *
  • Posts: 32
  • Karma: +9/-35
    • View Profile
    • www.edgarcain.zz.mu
Re: CreateVehicle
« Reply #6 on: November 16, 2016, 06:24:35 pm »

After creating vehicle the server suddenly closes
Kevin  ;)

JamesConway

  • Newbie
  • *
  • Posts: 39
  • Karma: +9/-3
    • View Profile
Re: CreateVehicle
« Reply #7 on: November 17, 2016, 11:20:55 am »
Any errors in the script log of the server?

 

© Liberty Unleashed Team.