Small help plz.
#1

Hi,

Can anyone tell me how do i make that GameTextForPlayer only shows once when the engine turned on? I mean, when the player already has his/her engine turned on and they press the fire button, it sends the GamText again. More and more whenever they press fire key. I couldn't figure out how to make it showing only once when they turn it on.

pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if (GetPlayerVehicleSeat(playerid) == 0)
    {

      if (newkeys & KEY_FIRE)
      {
        new engine, lights, alarm, doors, bonnet, boot, objective;
        new vehicleid = GetPlayerVehicleID(playerid);
     
        if (AVehicleData[vehicleid][Fuel] > 0)
        {
           GetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective);
           SetVehicleParamsEx(vehicleid, 1, lights, alarm, doors, bonnet, boot, objective);
           GameTextForPlayer(playerid, "~w~Engine turned ~g~on", 2000, 1);
           TextDrawHideForPlayer(playerid, APlayerData[playerid][VState]);
        }
       
      }
     
    }
    return 1;
}
Reply
#2

Try this
pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if (GetPlayerVehicleSeat(playerid) == 0)
    {
        if (newkeys & KEY_FIRE)
        {
            new vehicleid = GetPlayerVehicleID(playerid);
            if (AVehicleData[vehicleid][Fuel] > 0)
            {
                new engine, lights, alarm, doors, bonnet, boot, objective;             
                GetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective);

                if (!engine)
                {
                    SetVehicleParamsEx(vehicleid, 1, lights, alarm, doors, bonnet, boot, objective);
                    GameTextForPlayer(playerid, "~w~Engine turned ~g~on", 2000, 1);
                }
            }
        }
    }
    return 1;
}
Reply
#3

Its working but why do i have to enter on vehicle twice? I mean, when i enter the vehicle and press the fire key, it doesn't turn the engine on and when i exit then re-enter, it works. It was working fine before but when i added if(!engine) it started to bug like that, and if i remove if(!engine) it works fine.
Reply
#4

I have no idea, the if(!engine) just means "if engine is off", so should work if the engine is off as far as i can tell.

I don't have gta on this machine so cant test for you sorry.
Reply
#5

It is working fine but the only problem is, the gametext isn't showing at the first time, only the engine is turning on, but if i exit and re enter it is showing. :S

PS: Thanks for helping, i will try to fix it myself.
Reply
#6

I just realized it doesnt return 0, so my code was wrong, try it with this instead.

pawn Код:
if (engine != 1)
Reply
#7

Cool, that one worked. Thanks allot bro.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)