Author Topic: car belongs to...  (Read 4513 times)

vovanos

  • Newbie
  • *
  • Posts: 21
  • Karma: +0/-5
    • View Profile
car belongs to...
« 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 :-[
« Last Edit: October 21, 2011, 09:59:02 am by vovanos »

vovanos

  • Newbie
  • *
  • Posts: 21
  • Karma: +0/-5
    • View Profile
Re: car belongs to...
« Reply #1 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

VRocker

  • Liberty Unleashed Developer
  • Administrator
  • Full Member
  • ******
  • Posts: 342
  • Karma: +43/-15
    • View Profile
    • Madnight Software
Re: car belongs to...
« Reply #2 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.


vovanos

  • Newbie
  • *
  • Posts: 21
  • Karma: +0/-5
    • View Profile
Re: car belongs to...
« Reply #3 on: October 21, 2011, 02:19:31 pm »
Thanks :)

Force

  • Developer
  • Full Member
  • *****
  • Posts: 204
  • Karma: +6/-2
    • View Profile
Re: car belongs to...
« Reply #4 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.
Quote
[Tue - 20:09:35] <&VRocker> CRAP!
[Tue - 20:09:43] <&VRocker> i think i just followed through...
Quote
[Sat - 22:11:56] <~Smapy> [R3V]breSt12 killed [R3V]Jack_Bauer. (Splat)

 

© Liberty Unleashed Team.