SA-MP Forums Archive
Before the player enters the car - 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: Before the player enters the car (/showthread.php?tid=379846)



Before the player enters the car - PaulDinam - 23.09.2012

i wanna check something if the player want to enter the car as a driver i did something like that:
if(IsAnFbiCar(newcar))
{
if(PlayerInfo[playerid][pLeader] == 2||PlayerInfo[playerid][pMember] == 2)
{
SendClientMessage(playerid, COLOR_WHITE,"Welcome to FBI vehicle.");
}
else
{
RemovePlayerFromVehicle(playerid);
TogglePlayerControllable(playerid, 1);
SendClientMessage(playerid, COLOR_WHITE,"You don't have keys of this vehicle.");
}
}

but it's not good, how can i add a check after they press ENTER or F.


Re: Before the player enters the car - xMCx - 23.09.2012

try to add this
pawn Код:
if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)



Re: Before the player enters the car - PaulDinam - 23.09.2012

same thing


Re: Before the player enters the car - Riddy - 23.09.2012

Try this:

pawn Код:
if(IsAnFbiCar(newcar))
{
    if(!ispassenger)
    {
        if(PlayerInfo[playerid][pLeader] == 2||PlayerInfo[playerid][pMember] == 2)
        {
            SendClientMessage(playerid, COLOR_WHITE,"Welcome to FBI vehicle.");
        }
        else
        {
            RemovePlayerFromVehicle(playerid);
            TogglePlayerControllable(playerid, 1);
            SendClientMessage(playerid, COLOR_WHITE,"You don't have keys of this vehicle.");
        }
    }
}
This should go under, OnPlayerEnterVehicle


Re: Before the player enters the car - PaulDinam - 23.09.2012

but I don't want when player enter's the vehicle.
before he enter it will like slap him


Re: Before the player enters the car - clarencecuzz - 23.09.2012

pawn Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    if(ispassenger == 0)
    {
        if(IsAnFbiCar(vehicleid))
        {
            if(PlayerInfo[playerid][pLeader] == 2||PlayerInfo[playerid][pMember] == 2)
            {
                SendClientMessage(playerid, COLOR_WHITE,"Welcome to FBI vehicle.");
            }
            else
            {
                new Float:X, Float:Y, Float:Z;
                GetPlayerPos(playerid, X, Y, Z);
                SetPlayerPos(playerid, X, Y, Z+3);
                SendClientMessage(playerid, COLOR_WHITE,"You don't have keys of this vehicle.");
            }
        }
    }
    return 1;
}

//Also add this just in case the other callback fails due to lagg
public OnPlayerStateChange(playerid, newstate, oldstate)
{
    if(newstate == PLAYER_STATE_DRIVER)
    {
        if(IsAnFbiCar(GetPlayerVehicleID(playerid)))
        {
            if(PlayerInfo[playerid][pLeader] == 2||PlayerInfo[playerid][pMember] == 2)
            {
                SendClientMessage(playerid, COLOR_WHITE,"Welcome to FBI vehicle.");
            }
            else
            {
                RemovePlayerFromVehicle(playerid);
                SendClientMessage(playerid, COLOR_WHITE,"You don't have keys of this vehicle.");
            }
        }
    }
    return 1;
}



Re: Before the player enters the car - mamorunl - 23.09.2012

You can just return 0 in OnPlayerEnterVehicle to stop him.. iirc


Re: Before the player enters the car - clarencecuzz - 23.09.2012

Quote:
Originally Posted by mamorunl
Посмотреть сообщение
You can just return 0 in OnPlayerEnterVehicle to stop him.. iirc
No you can't. OnPlayerEnterVehicle does not return a value.


Re: Before the player enters the car - PaulDinam - 23.09.2012

try IBP-RP, find an LSPD car when you press ENTER it's slaps you before you enter the car!
how can I do this?


Re: Before the player enters the car - clarencecuzz - 23.09.2012

I've just told you...
pawn Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    if(ispassenger == 0)
    {
        if(IsAnFbiCar(vehicleid))
        {
            if(PlayerInfo[playerid][pLeader] == 2||PlayerInfo[playerid][pMember] == 2)
            {
                SendClientMessage(playerid, COLOR_WHITE,"Welcome to FBI vehicle.");
            }
            else
            {
                new Float:X, Float:Y, Float:Z;
                GetPlayerPos(playerid, X, Y, Z);
                SetPlayerPos(playerid, X, Y, Z+3);
                SendClientMessage(playerid, COLOR_WHITE,"You don't have keys of this vehicle.");
            }
        }
    }
    return 1;
}