Vice City: Multiplayer

Server Development => Scripting and Server Management => Snippet Showroom => Topic started by: ! on Oct 10, 2017, 07:23 AM

Title: [SNIPPET]Basic Vehicle Passengers Freeview
Post by: ! on Oct 10, 2017, 07:23 AM
Basic Vehicle Passengers Freeview


Note:

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]
Title: Re: [SNIPPET]Basic Vehicle Passengers Freeview
Post by: D4rkR420R on Oct 10, 2017, 01:17 PM
Nice work! Giving the ability to look freely gives them an opportunity to view at a great position!
Title: Re: [SNIPPET]Basic Vehicle Passengers Freeview
Post by: Sebastian on Oct 13, 2017, 06:17 PM
Good idea. I might use it too :)
Title: Re: [SNIPPET]Basic Vehicle Passengers Freeview
Post by: MatheuS on Oct 13, 2017, 06:55 PM
How come I never thought of that?

Good job!
Title: Re: [SNIPPET]Basic Vehicle Passengers Freeview
Post by: =RK=MarineForce on Nov 19, 2017, 11:17 AM
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);
}
Title: Re: [SNIPPET]Basic Vehicle Passengers Freeview
Post by: =RK=MarineForce on Nov 19, 2017, 11:19 AM
AND Good lUCK nice scripting zeus
Title: Re: [SNIPPET]Basic Vehicle Passengers Freeview
Post by: ! on Nov 19, 2017, 11:44 AM
Quote from: =RK=MarineForce on Nov 19, 2017, 11:19 AMnice scripting zeus
Nice scripting or idea? ???
Anyway thanks guys.
Title: Re: [SNIPPET]Basic Vehicle Passengers Freeview
Post by: =RK=MarineForce on Nov 19, 2017, 11:56 AM
No Problem >!!!!!!!! :D

And Thankx For OnPlayerExitvehicles
Title: Re: [SNIPPET]Basic Vehicle Passengers Freeview
Post by: Mohamed Boubekri 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.
Title: Re: [SNIPPET]Basic Vehicle Passengers Freeview
Post by: D4rkR420R on Nov 28, 2017, 05:49 AM
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.
Title: Re: [SNIPPET]Basic Vehicle Passengers Freeview
Post by: MEGAMIND on Nov 11, 2024, 03:02 PM
Quote from: Mohamed Boubekri 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.
Quote from: D4rkR420R on Nov 28, 2017, 05:49 AM
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.

onentervehicle
if (vehicle.Driver != null)
{
    if (vehicle.Driver.ID != player.ID)
    {
        player.SpectateTarget = vehicle.Driver;
        vehicle.Driver.SpectateTarget = player; // Driver also spectates the player
    }
    else
    {
        local MaxOccupants = 8;
        for (local i = 1; i <= MaxOccupants; i++)
        {
            local Occupant = vehicle.GetOccupant(i);
            if (Occupant != null && Occupant.SpectateTarget == null)
                Occupant.SpectateTarget = player;
        }
    }
}



onexitvehicle
if (player.SpectateTarget != null)
    player.SpectateTarget = null; /* It's not necessary to use this line */
if (vehicle.Driver == null)
{
    local MaxOccupants = 8;
    for (local i = 1; i <= MaxOccupants; i++)
    {
        local Occupant = vehicle.GetOccupant(i);
        if (Occupant != null)
        {
            // Clear the spectate target for all occupants
            if (Occupant.SpectateTarget != null)
                Occupant.SpectateTarget = null;
        }
    }
}
else
{
    // If vehicle has a driver, make sure the driver stops spectating as well
    if (vehicle.Driver.SpectateTarget != null)
        vehicle.Driver.SpectateTarget = null;
}
u can if u have a passenger at a side