SA-MP Forums Archive
help .. onplayerentervehicle problem - 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: help .. onplayerentervehicle problem (/showthread.php?tid=423966)



help .. onplayerentervehicle problem - Anak - 20.03.2013

hello i want that when a player enters in these vehicles: BOTveh1, BOTveh2, BOTveh3. as passenger "g" he will have like this

pawn Код:
if(BoughtTicket[playerid] == 0)
                    {
                    SendClientMessage(playerid, COLOR_RED,"Buy plane ticket from terminal.");
                    new Float:x, Float:y, Float:z;
                    GetPlayerPos(playerid, x, y, z);
                    SetPlayerPos(playerid, x, y, z+1);
                    }
                    else
                    {
                    SendClientMessage(playerid, COLOR_YELLOW,"[Anak's Airways]: Welcome on flight sir - Your ticket is used.");
                    SendClientMessage(playerid, COLOR_WHITE,"Please exit plane when you reach your destination.");
                    BoughtTicket[playerid] = 0;
                    }

i used this but it not work...

pawn Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
   
    new vehicle;
    vehicle = GetPlayerVehicleID(playerid);
    if(vehicle == BOTveh1 || vehicle == BOTveh2 || vehicle == BOTveh3 && ispassenger == 0)
    {
                   if(BoughtTicket[playerid] == 0)
                    {
                    SendClientMessage(playerid, COLOR_RED,"Buy plane ticket from terminal.");
                    new Float:x, Float:y, Float:z;
                    GetPlayerPos(playerid, x, y, z);
                    SetPlayerPos(playerid, x, y, z+1);
                    }
                    else
                    {
                    SendClientMessage(playerid, COLOR_YELLOW,"[Anak's Airways]: Welcome on flight sir - Your ticket is used.");
                    SendClientMessage(playerid, COLOR_WHITE,"Please exit plane when you reach your destination.");
                    BoughtTicket[playerid] = 0;
                    }
    }
}
anyone can help..


Re: help .. onplayerentervehicle problem - Anak - 20.03.2013

i have to put this also ?
pawn Код:
public OnPlayerConnect( playerid )
{
BoughtTicket[playerid] = 0;
return 1;
}
?


Re: help .. onplayerentervehicle problem - Gamer_007 - 20.03.2013

Quote:
Originally Posted by Anak
Посмотреть сообщение
i have to put this also ?
pawn Код:
public OnPlayerConnect( playerid )
{
BoughtTicket[playerid] = 0;
return 1;
}
?
yep and btw u need to correct this code

pawn Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
   
    new vehicle;
    vehicle = GetPlayerVehicleID(playerid);
    if(vehicle == BOTveh1 || vehicle == BOTveh2 || vehicle == BOTveh3 && ispassenger == 0)
    {
                   if(BoughtTicket[playerid] == 0)
                    {
                    SendClientMessage(playerid, COLOR_RED,"Buy plane ticket from terminal.");
                    new Float:x, Float:y, Float:z;
                    GetPlayerPos(playerid, x, y, z);
                    SetPlayerPos(playerid, x, y, z+1);
                    }
                    else
                    {
                    SendClientMessage(playerid, COLOR_YELLOW,"[Anak's Airways]: Welcome on flight sir - Your ticket is used.");
                    SendClientMessage(playerid, COLOR_WHITE,"Please exit plane when you reach your destination.");
                    BoughtTicket[playerid] = 1;
                    }
    }
}



Re: help .. onplayerentervehicle problem - shady001 - 20.03.2013

I would use OnPlayerStateChange and check if PLAYER_STATE_PASSENGER and if not RemovePlayerFromVehicle

Because The onplayerentervehicle is called every time a player hits the G button(or the F button) , and if he hits it 2 times he can't enter the vehicle because first time BoughtTicket[playerid] will be set to 1 and when he pres the second time G it will set his position and will not be able to enter the vehicle and it will have to buy another ticket


Re: help .. onplayerentervehicle problem - Anak - 20.03.2013

FIXED