SA-MP Forums Archive
when player enter vehicle? I need a small function. +1 rep for help - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: when player enter vehicle? I need a small function. +1 rep for help (/showthread.php?tid=308137)



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

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


Re: when player enter vehicle? I need a small function. +1 rep for help - Artie_Scorpion - 02.01.2012

answer me!!!


Re: when player enter vehicle? I need a small function. +1 rep for help - Basssiiie - 02.01.2012

Код:
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.


Re: when player enter vehicle? I need a small function. +1 rep for help - NeverKnow - 02.01.2012

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;
}



Re: when player enter vehicle? I need a small function. +1 rep for help - DarkKillerWithPride<3 - 02.01.2012

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..


Re: when player enter vehicle? I need a small function. +1 rep for help - Basssiiie - 02.01.2012

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.


Re: when player enter vehicle? I need a small function. +1 rep for help - Artie_Scorpion - 02.01.2012

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


Re: when player enter vehicle? I need a small function. +1 rep for help - Artie_Scorpion - 02.01.2012

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..... ?


Re: when player enter vehicle? I need a small function. +1 rep for help - Basssiiie - 02.01.2012

Код:
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.