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 onPlayerEnterVehicle( player, vehicle, door )
{
if ( vehicle.Driver != null )
{
if ( vehicle.Driver.ID != player.ID ) player.SpectateTarget = vehicle.Driver;
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;
}
}
}
}
function onPlayerExitVehicle( player, vehicle )
{
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; i <= MaxOccupants; i++ )
{
local Occupant = vehicle.GetOccupant( i );
if ( Occupant != null && Occupant.SpectateTarget != null ) Occupant.SpectateTarget = null;
}
}
}
Video:https://youtu.be/3SpyvfmOTMw
[more]
Nice work! Giving the ability to look freely gives them an opportunity to view at a great position!
Good idea. I might use it too :)
How come I never thought of that?
Good job!
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);
}
AND Good lUCK nice scripting zeus
Quote from: =RK=MarineForce on Nov 19, 2017, 11:19 AMnice scripting zeus
Nice scripting or idea? ???
Anyway thanks guys.
No Problem >!!!!!!!! :D
And Thankx For OnPlayerExitvehicles
@! 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: 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.
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 AMQuote 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