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.

Here's the script so far, which may helps you understand what I want to do.
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;
}