[SNIPPET]Basic Vehicle Passengers Freeview

Started by !, Oct 10, 2017, 07:23 AM

Previous topic - Next topic

!

Basic Vehicle Passengers Freeview


Note:
  • This system only works for the vehicle passengers not for the vehicle driver & will work only if there is a driver present in vehicle otherwise it will revoke for all passengers.
  • Change the 'MaxOccupants' if required cause I am not much sure about max occupants for vehicles like bus but I think 9 is max for vcmp vehicles since some of the users will ask why you have set 'MaxOccupants' to 8 instead of 9 so for their kind information the vehicle.GetOccupant(_integer) starts from 0 in vcmp.

Events Used:
onPlayerEnterVehicle( player, vehicle, door )
onPlayerExitVehicle( player, vehicle )

Functions Used:
player.SpectateTarget
vehicle.GetOccupant(_integer[max-8])

Snippet:
/* <?php */
function 
onPlayerEnterVehicleplayervehicledoor )
{
   if ( 
vehicle.Driver != null )
   {
      if ( 
vehicle.Driver.ID != player.ID player.SpectateTarget vehicle.Driver;
      else
      {
         
local MaxOccupants 8;
         for( 
local i 1<= MaxOccupantsi++ )
         {
          
local Occupant vehicle.GetOccupant);
            if ( 
Occupant != null && Occupant.SpectateTarget == null Occupant.SpectateTarget player;
         }
      }
   }
}
   
function 
onPlayerExitVehicleplayervehicle )
{
   if ( 
player.SpectateTarget != null player.SpectateTarget null/* Its not necessary to use this line */
   
if ( vehicle.Driver == null )
   {
      
local MaxOccupants 8;
      for( 
local i 1<= MaxOccupantsi++ )
      {
         
local Occupant vehicle.GetOccupant);
         if ( 
Occupant != null && Occupant.SpectateTarget != null Occupant.SpectateTarget null;
      }
   }
}

Video:
https://youtu.be/3SpyvfmOTMw

[more]

Discord: zeus#5155

D4rkR420R

Nice work! Giving the ability to look freely gives them an opportunity to view at a great position!

Sebastian


MatheuS

How come I never thought of that?

Good job!
if( !sucess ) tryAgain();
Thanks to the VCMP community. It was the happiest period of my life.

=RK=MarineForce

MY Script i am small scripter.

function onPlayerExitVehicle( player, vehicle )
{
MessagePlayer(" You are Exit The Vehicle ID: "+vehicle.ID+"",player);
}

function onPlayerEnterVehicle( player, vehicle, door )
{
MessagePlayer(" You are Enter The Vehicle ID: "+vehicle.ID+"",player);
}

=RK=MarineForce


!


Discord: zeus#5155

=RK=MarineForce

No Problem >!!!!!!!! :D

And Thankx For OnPlayerExitvehicles

Mohamed Boubekri

@! Brother zeus You Can Do That's For For Driver Cars

If You Can't / Its oK,

About That's Niice Work, But i Want For the Driver Vehicles

If You Can Do Sent Me Here Thanks.
| What now ? | Not yet ! |
Morrocan:- [ 🇲🇦 ].

D4rkR420R

Quote from: Mohamed on Nov 27, 2017, 09:24 PM@! Brother zeus You Can Do That's For For Driver Cars

If You Can't / Its oK,

About That's Niice Work, But i Want For the Driver Vehicles

If You Can Do Sent Me Here Thanks.

It isn't possible to spectate yourself, or in this case, the driver. Attempt to spectate yourself in your server & you'll see. We usually spectate ourselves on purpose to disable spectating mode.