SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 12/02/2018, 04:38 AM   #1
FelipeBlanco
Big Clucker
 
Join Date: Oct 2015
Posts: 71
Reputation: 1
Default [HELP] Help about OnUnoccupiedVehicleUpdate

Hi, my problem is when a passenger is pause and driver pulls the vehicle, OnUnoccupiedVehicleUpdate isn't called.
I want to make the vehicle stoped when driver pulls the vehicle, but this does not happen because the passenger is paused.
HTML Code:
new UNON = 1;
public OnUnoccupiedVehicleUpdate(vehicleid, playerid, passenger_seat, Float:new_x, Float:new_y, Float:new_z)
{
	if(UNON == 1)
	{
		new Float:PosX,Float:PosY,Float:PosZ,Float:PosA;
		GetVehiclePos(vehicleid, PosX, PosY, PosZ);
		GetVehicleZAngle(vehicleid, PosA);
		new Float:Distancia = GetDistanceBetweenPoints(new_x, Float:new_y, Float:new_z, PosX, PosY, PosZ);
		if(Distancia > 20.0)
		{
			SetVehiclePos(vehicleid, PosX, PosY, PosZ);
			SetVehicleZAngle(vehicleid, PosA);
			return ;
		}
	}
	else
	{
		static Float:distance,Float:pos_x,Float:pos_y,Float:pos_z,Float:angle;

		GetVehiclePos(vehicleid, pos_x, pos_y, pos_z);
		GetVehicleZAngle(vehicleid, angle);
		distance = VectorSize(pos_x - new_x, pos_y - new_y, pos_z - new_z);
		if(distance > 10 && pos_z > -70.0)
		{
			SetVehiclePos(vehicleid, pos_x, pos_y, pos_z);
			SetVehicleZAngle(vehicleid, angle);
		}
	}
}
My code

Sorry for my english, thanks
FelipeBlanco is offline   Reply With Quote
Old 12/02/2018, 07:01 AM   #2
RogueDrifter
High-roller
 
RogueDrifter's Avatar
 
Join Date: Dec 2017
Location: SA-MP Drifting world.
Posts: 1,148
Reputation: 345
Default Re: [HELP] Help about OnUnoccupiedVehicleUpdate

Im confused as hell! You need to explain exactly what youre trying to achieve, what do you mean by vehicle stop when driver pulls???
__________________

[Github]:Link [Gists]:Link [Forum]:Link [Server]:Link [Discord]:Link


RogueDrifter is offline   Reply With Quote
Old 12/02/2018, 09:11 AM   #3
PepsiCola23
Gangsta
 
Join Date: May 2015
Posts: 684
Reputation: 3
Default Re: [HELP] Help about OnUnoccupiedVehicleUpdate

"This callback is called when a player's client updates/syncs the position of a vehicle they're not driving. This can happen outside of the vehicle or when the player is a passenger of a vehicle that has no driver."

http://wiki.sa-mp.com/wiki/OnUnoccupiedVehicleUpdate
PepsiCola23 is offline   Reply With Quote
Old 12/02/2018, 09:31 AM   #4
Mugala
Gangsta
 
Mugala's Avatar
 
Join Date: Nov 2012
Location: behind u
Posts: 645
Reputation: 30
Default Re: [HELP] Help about OnUnoccupiedVehicleUpdate

this callback will not be called, like PepsiCola23 said.
you can use variables for vehicle's position to be updated later.
__________________
here to help

Last edited by Mugala; 12/02/2018 at 09:30 PM.
Mugala is offline   Reply With Quote
Old 12/02/2018, 02:32 PM   #5
NaS
High-roller
 
NaS's Avatar
 
Join Date: Mar 2008
Posts: 1,585
Reputation: 466
Default Re: [HELP] Help about OnUnoccupiedVehicleUpdate

You could force the player out of the vehicle by respawning it and putting it back to where it was before (you can save the damage status and health as well). Important is to actually respawn it, RemovePlayerFromVehicle will not work if the player is paused.

This will make it unoccupied and the callback will work, but if the paused player returns he will not be in that vehicle anymore. You could place him back into it if the seat hasn't been taken by someone else.

It may look weird though for others, but it's worth a try I think.
NaS is offline   Reply With Quote
Old 12/02/2018, 06:10 PM   #6
FelipeBlanco
Big Clucker
 
Join Date: Oct 2015
Posts: 71
Reputation: 1
Default Re: [HELP] Help about OnUnoccupiedVehicleUpdate

Quote:
Originally Posted by RogueDrifter View Post
Im confused as hell! You need to explain exactly what youre trying to achieve, what do you mean by vehicle stop when driver pulls
when the driver leaves the vehicle, the vehicle stops, but the callback isn`t called when passenger is paused
FelipeBlanco is offline   Reply With Quote
Old 12/02/2018, 06:55 PM   #7
PepsiCola23
Gangsta
 
Join Date: May 2015
Posts: 684
Reputation: 3
Default Re: [HELP] Help about OnUnoccupiedVehicleUpdate

Quote:
Originally Posted by Mugala View Post
this callback will not be called like PepsiCola23 said.
you can use variables for vehicle's position to be updated later.
So you say samp wiki is wrong?
PepsiCola23 is offline   Reply With Quote
Old 12/02/2018, 07:51 PM   #8
Mugala
Gangsta
 
Mugala's Avatar
 
Join Date: Nov 2012
Location: behind u
Posts: 645
Reputation: 30
Default Re: [HELP] Help about OnUnoccupiedVehicleUpdate

no I mean that u're right.
__________________
here to help
Mugala is offline   Reply With Quote
Old 12/02/2018, 07:56 PM   #9
PepsiCola23
Gangsta
 
Join Date: May 2015
Posts: 684
Reputation: 3
Default Re: [HELP] Help about OnUnoccupiedVehicleUpdate

You just said “will NOT be called like PepsiCola23 said”
PepsiCola23 is offline   Reply With Quote
Old 12/02/2018, 09:07 PM   #10
Sew_Sumi
Banned
 
Join Date: Jun 2008
Location: Azerbaijan
Posts: 6,469
Reputation: 525
Default Re: [HELP] Help about OnUnoccupiedVehicleUpdate

That callback fires so much for every vehicle that streams in... This is probably not a good idea.
Sew_Sumi is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
OnUnoccupiedVehicleUpdate SpaceRP Scripting Help 0 10/02/2017 05:35 PM
Bug (OnUnoccupiedVehicleUpdate) McLuhan Bug Reports 1 22/02/2015 07:22 PM
OnUnoccupiedVehicleUpdate Banditukas Scripting Help 1 13/08/2014 06:34 PM
OnUnoccupiedVehicleUpdate Banditukas Scripting Help 4 13/08/2014 02:25 PM
OnUnoccupiedVehicleUpdate Banditukas Scripting Help 1 13/08/2014 08:28 AM


All times are GMT. The time now is 03:17 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.