GetPlayerVehicleID Help
#1

Ok, so before I begin, keep in mind that ive done 0 scripting since 2012 lol. Im just coming back into it. That being said,

Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
	if(GetPlayerVehicleID(playerid) == 81)
	{
	SendClientMessage(playerid, COLOR_YELLOW, "Your Tail Number is EA-6833");
	}
Im trying to test a theory with this. Basically when you enter the specified Dodo (ID 81) the server should send a message telling you that this is your tail number. Simple right? Apparently not for me. When i enter the vehicle, nothing happens. Im not really sure what im missing here. any SERIOUS, help would be appreciated. Thank you.
Reply
#2

You need the vehicle model, not the ID.
PHP код:
if(GetVehicleModel(vehicleid) == 81
You don't need GetVehicleID neither since it's already there.
Enjoy and welcome back.

Edit; My bad, I didn't read clearly.
Use vehicleid, since OnPlayerEnterVehicle is when you press enter and start running to the door.
If you'd like to see the message when you are inside the vehicle, use OnPlayerStateChange.
PHP код:
if(vehicleid == 81
Reply
#3

Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
	if(GetVehicleModel(vehicleid == 81)
	{
	SendClientMessage(playerid, COLOR_YELLOW, "Your Tail Number is EA-6833");
	}
Btw dont you when the message sent to the player when hes in the vehicle?

https://sampwiki.blast.hk/wiki/OnPlayerEnterVehicle is called when a player is starts entering a vehicle,you should use
https://sampwiki.blast.hk/wiki/OnPlayerStateChange
Reply
#4

That specified vehicle may or may not have vehicle ID 81 so you have to store its vehicle ID in a global variable when creating the vehicle. After that, all have left is to compare it and you actually have the vehicle ID as parameter:
pawn Код:
// global:
new gDodo;

// creating the vehicle:
gDodo = CreateVehicle(..); // or by AddStaticVehicle(Ex)

// OnPlayerEnterVehicle:
if (vehicleid == gDodo)
{
    // send message..
}
@Above users: The model ID of "Dodo" is 593.

EDIT: Just to clarify the problem, the player is NOT in vehicle yet so GetPlayerVehicleID returns 0.
OnPlayerEnterVehicle is called when the player is starting the animation to enter the vehicle. You might use OnPlayerStateChange if you prefer.
Reply
#5

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
@Above users: The model ID of "Dodo" is 593.
Yeah noticed it right before you posted.
Reply
#6

Nevertheless, thank you all for the help, it was completely successful, and I couldnt be more grateful
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)