Liberty Unleashed

Scripting => Script Help => Topic started by: vovanos on October 21, 2011, 09:54:25 am

Title: car belongs to...
Post by: vovanos on October 21, 2011, 09:54:25 am
I try to create a script

function onClientEnteredVehicle( pPlayer, Vehicle, seat )
{
   if ( pPlayer.Vehicle.Model = 134 )
   {
      if ( pPlayer.Skin = 10 )
      {
         MessagePlayer( "Mafia Car", pPlayer );
      } else {
         MessagePlayer( "This car belongs to the mafia", pPlayer );
         pPlayer.Vehicle.SetEngineState = false;
         pPlayer.Vehicle.Siren = true;
      }
   }
}

I have trouble creating a script, help me please :-[
Title: Re: car belongs to...
Post by: vovanos on October 21, 2011, 11:21:07 am
function onPlayerEnteredVehicle( pPlayer, Vehicle, door_driver )
{
   Message( "[#ff0000]*** [#00cc00]Enter Vehicle" );

   if ( pPlayer.Vehicle.ID = 134 )
   {
   Message( "*** ID 134" );
      if ( pPlayer.Skin = 10 )
      {
         MessagePlayer( "Mafia Car", pPlayer );
      } else {
         MessagePlayer( "This car belongs to the mafia", pPlayer );
         pPlayer.Vehicle.SetEngineState = false;
         pPlayer.Vehicle.Siren = true;
      }
   }
}

-------------------------------------------------------------------------------------------
AN ERROR HAS OCCURED ['ID' is not member of Vehicle]

CALLSTACK
*FUNCTION [onPlayerEnteredVehicle()] Scripts/roleplay/roleplay.nut line [9]

LOCALS
[door_driver] 0
[Vehicle] INSTANCE
[pPlayer] INSTANCE
[this] TABLE
Title: Re: car belongs to...
Post by: VRocker on October 21, 2011, 01:22:33 pm
This is because player.Vehicle isn't set until after the event is called (i think). Why dont you just use Vehicle.ID, since that is passed to the event already.
Title: Re: car belongs to...
Post by: vovanos on October 21, 2011, 02:19:31 pm
Thanks :)
Title: Re: car belongs to...
Post by: Force on October 21, 2011, 03:15:08 pm
Oh and you can't use Vehicle as a parameter name in the event call because 'Vehicle' is reserved by Squirrel.