Small help plz. -
iOxide - 03.01.2014
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;
}
Re: Small help plz. -
iggy1 - 03.01.2014
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;
}
Re: Small help plz. -
iOxide - 03.01.2014
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.
Re: Small help plz. -
iggy1 - 03.01.2014
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.
Re: Small help plz. -
iOxide - 03.01.2014
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.
Re: Small help plz. -
iggy1 - 03.01.2014
I just realized it doesnt return 0, so my code was wrong, try it with this instead.
Re: Small help plz. -
iOxide - 03.01.2014
Cool, that one worked. Thanks allot bro.