Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


  Show Posts
Pages: [1]
1  Scripting / Script Help / Re: Tracking a vehicle and remove it on command on: January 06, 2016, 07:39:26 pm
It works like magic!  ;D Thank you very much for your help! 8)
2  Scripting / Script Help / Re: Tracking a vehicle and remove it on command on: January 06, 2016, 05:28:56 am
I tested it again, no more error messages. But it doesn't remove the vehicle :(
3  Scripting / Script Help / Re: Tracking a vehicle and remove it on command on: January 04, 2016, 11:50:23 pm
Thank you for you help. I tested it:

Error on line 28 -> local tmp = FindVehicle(id);

Code: [Select]

AN ERROR HAS OCCURED [parameter 2 has an invalid type 'instance' ; expected: 'in
teger|float|bool|string']

CALLSTACK
*FUNCTION [onPlayerCommand()] Scripts/Limit/Main.nut line [28]

LOCALS
[id] 2
[vehicle] INSTANCE
[text] 90
[command] "spawncar"
[player] INSTANCE
[this] TABLE

4  Scripting / Script Help / Tracking a vehicle and remove it on command on: January 04, 2016, 11:33:54 am
Hi!

I want to create a script which limits the number of spawned vehicles per player to two and removes the firstly spawned one, if the player spawns another one. I "think" I'm on the half way to finish it, but I stucked at the most important point.

My question is the following:
Is it possible to track a player-spawned vehicle and remove it on command? Even if the player is not in the vehicle.

I'm a newbie to Squirrel. If someone can help me with this, it would be awesome. If not, then I'll have to give up for a while with this. :P

Here's the script so far, which may helps you understand what I want to do.

Code: [Select]
local vh1 = 0;
local vh2 = 0;


function onPlayerCommand( pPlayer, szCmd, szParams )
{
if ( szCmd == "spawncar" )
{
if ( szParams )
{
local pTemp = split( szParams, " " ), ID = 90;
if ( IsNum( pTemp[ 0 ] ) ) ID = pTemp[ 0 ].tointeger();

if ( ( ID >= 90 ) && ( ID <= 150 ) )
{


if ( ( vh1 == 0 ) && ( vh2 == 0 ) )
{
local v = pPlayer.Pos;
MessagePlayer( "Spawning a vehicle with model ID " + ID + "...", pPlayer );

local vh01 = CreateVehicle( ID, Vector( v.x + 5, v.y, v.z ), pPlayer.Angle );
print( pPlayer.Name + ": vh01 " + vh01.Pos );

vh01.OneTime = true;

vh1 = 1;

print( pPlayer.Name + ": vh1 = 1, vh2 = 0" );
}

else if ( ( vh1 == 1 ) && ( vh2 == 0 ) )
{
local v = pPlayer.Pos;
MessagePlayer( "Spawning a vehicle with model ID " + ID + "...", pPlayer );

local vh02 = CreateVehicle( ID, Vector( v.x + 5, v.y, v.z ), pPlayer.Angle );
print( pPlayer.Name + ": vh02 " + vh02.Pos );

vh02.OneTime = true;

vh2 = 2;

print( pPlayer.Name + ": vh1 = 1, vh2 = 2" );
}

else if ( ( vh1 == 1 ) && ( vh2 == 2 ) )
{
local v = pPlayer.Pos;
MessagePlayer( "Spawning a vehicle with model ID " + ID + "...", pPlayer );

local vh01 = CreateVehicle( ID, Vector( v.x + 5, v.y, v.z ), pPlayer.Angle );
print( pPlayer.Name + ": vh01 " + vh01.Pos );

vh01.OneTime = true;

vh2 = 1;
vh1 = 2;

print( pPlayer.Name + ": vh1 = 2, vh2 = 1" );
}

else if ( ( vh1 == 2 ) && ( vh2 == 1 ) )
{
local v = pPlayer.Pos;
MessagePlayer( "Spawning a vehicle with model ID " + ID + "...", pPlayer );

local vh02 = CreateVehicle( ID, Vector( v.x + 5, v.y, v.z ), pPlayer.Angle );
print( pPlayer.Name + ": vh02 " + vh02.Pos );

vh02.OneTime = true;

vh2 = 2;
vh1 = 1;

print( pPlayer.Name + ": vh1 = 1, vh2 = 2" );
}
}
}
}
return 1;
}



Pages: [1]
© Liberty Unleashed Team.