help .. onplayerentervehicle problem
#1

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..
Reply
#2

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

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;
                    }
    }
}
Reply
#4

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
Reply
#5

FIXED
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)