SA-MP Forums Archive
Certain vehicle - 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: Certain vehicle (/showthread.php?tid=437029)



Certain vehicle - Hand-Scripter - 13.05.2013

Hello, I have a question. Is there a way to let a player get a message when he enters a certain vehicle.

Example: A checkpoint will be shown when a player enters any crossmotor. When he enters any other vehicle the message will not show up.

Is this possible? Since IsPlayerInVehicle doesn't seem to support it.


Re: Certain vehicle - MP2 - 13.05.2013

GetVehicleModel/GetPlayerVehicleID/OnPlayerStateChange.


Re: Certain vehicle - Hand-Scripter - 13.05.2013

Thank you, MP2.


Re: Certain vehicle - -CaRRoT - 13.05.2013

What MP2 said is true - But you'll need to make a variable for that "certain car" unless you want it to work for all the vehicles with the same model.


Re: Certain vehicle - Phil_Cutcliffe - 13.05.2013

Here is an example for you..

Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
	new vehicle = GetPlayerVehicleID(playerid);
    if(newstate == PLAYER_STATE_DRIVER)
	{
	    if(GetVehicleModel(vehicle) == modelnumberhere)
	    {
	        SendClientMessage(playerid, COLOR_WHITE "Your message here");
			return 1;
	    }
EDIT:

Please note: Like the guy said above.. This will make it so anyone who enters ANY VEHICLE with ONLY THIS MODEL NUMBER will get the message. For example if you set the model number to 900 and the vehicle was a jeep.. Everyone who enters any jeep will get the message.

+Rep me if I helped you


Re: Certain vehicle - Hand-Scripter - 14.05.2013

Yeah, that doesn't really matter since the vehicle is the only one in-game. Phil I can't since my minus rep.


Re: Certain vehicle - MP2 - 14.05.2013

If you want a single vehicle (let's call them 'special vehicles'):

pawn Код:
new SpecVehID_catalinaBuffalo; // For example

public OnGameModeInit()
{
    SpecVehID_catalinaBuffalo = CreateVehicle(...);
    return 1;
}

public OnPlayerStateChange(playerid, newstate, oldstate)
{
    if(newstate == PLAYER_STATE_DRIVER)
    {
        new vehicleid = GetPlayerVehicleID(playerid);

        if(vehicleid == SpecVehID_catalinaBuffalo)
        {
            // They entered catalina's buffalo
        }
}
    return 1;
}
For multiple vehicles you should use an array.