when player enter vehicle? I need a small function. +1 rep for help
#1

i need function when player sit in every vehicle then writes "Welcome to vehicle"... Expect with G button.
Reply
#2

answer me!!!
Reply
#3

Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
    if(newstate == PLAYER_STATE_DRIVER && oldstate != PLAYER_STATE_DRIVER) // Player enters the vehicle as driver
    {
        SendClientMessage(playerid, WHATEVERCOLORHERE, "Welcome in the vehicle, dear sir. :)");
    }
    return 1;
}
Piece of cake.
Reply
#4

Here you go I help you

Код:
///put on OnPlayerEnterVehicle
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{		
        if(ispassenger == 0)
        {
                GameTextForPlayer(playerid, "~y~Welcome to ~r~vehicle", 5000, 4);
        }
        return 1;
}
Reply
#5

dude... Don't double post or bump before 24hrs next have you tried:

pawn Код:
// OnPlayerEnterVehicle
GetPlayerVehicleSeat(playerid) == 2)
{
    SendClientMessage(playerid,color,"Welcome To The Vehicle...");
    return 1;
}
etc..
Reply
#6

Don't use OnPlayerEnterVehicle, use OnPlayerStateChange like in my post. OnPlayerEnterVehicle is called when the player presses the 'enter vehicle' key and a vehicle is nearby (so the player walks towards the vehicle), even before the player is actually entering the vehicle! If the player stops entering the vehicle, by for example walking away, the message will still show without the player actually entering the vehicle. That's why you should use OnPlayerStateChange and not OnPlayerEnterVehicle.
Reply
#7

Quote:
Originally Posted by DarkKillerWithPride<3
Посмотреть сообщение
dude... Don't double post or bump before 24hrs next have you tried:

pawn Код:
// OnPlayerEnterVehicle
GetPlayerVehicleSeat(playerid) == 2)
{
    SendClientMessage(playerid,color,"Welcome To The Vehicle...");
    return 1;
}
etc..
big error
Reply
#8

Quote:
Originally Posted by NeverKnow
Посмотреть сообщение
Here you go I help you

Код:
///put on OnPlayerEnterVehicle
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{		
        if(ispassenger == 0)
        {
                GameTextForPlayer(playerid, "~y~Welcome to ~r~vehicle", 5000, 4);
        }
        return 1;
}
This is my function

Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
    if( oldstate == PLAYER_STATE_ONFOOT && newstate == PLAYER_STATE_DRIVER )
    {
        //If they got into a car from being on foot.
        if( GetVehicleModel(GetPlayerVehicleID( playerid )) == 428 )
        {
            if( GetPlayerSkin(playerid) != 27 )
            {
                 //If their skin is not 27

                //Remove them and send message.
                RemovePlayerFromVehicle( playerid );
                SendClientMessage( playerid,0xFF000000, "Noredami vairuoti si transporta turite buti elektriku" ); //-1
            }
        }
    }
    return 1;
}
Can you add your function into this code and fix some returns at code end..... ?
Reply
#9

Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
	if( oldstate == PLAYER_STATE_ONFOOT && newstate == PLAYER_STATE_DRIVER )
	{
		//If they got into a car from being on foot.
		if( GetVehicleModel(GetPlayerVehicleID( playerid )) == 428 )
		{
			if( GetPlayerSkin(playerid) != 27 )
			{
				//If their skin is not 27
				//Remove them and send message.
				RemovePlayerFromVehicle( playerid );
				SendClientMessage( playerid,0xFF000000, "Noredami vairuoti si transporta turite buti elektriku" ); //-1
				return 1;
			}
			else
			{
				SendClientMessage(playerid, 0xFF000000, "Welcome in the vehicle, dear sir. :)");
				return 1;
			}
		}
	}
	return 1;
}
That should work.
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)