Function only runs standing - 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: Function only runs standing (
/showthread.php?tid=660341)
Function only runs standing -
KaliDobrev - 31.10.2018
Hello, I have a problem, when pressing these keys, the function worked fine, but only if the ped is standing, but when entering a vehicle it does not work.
The sense is that it works inside a vehicle since the function is to turn on / stop the engine of these.
pawn Code:
if (RELEASED( KEY_FIRE | KEY_CROUCH ))
{
CallLocalFunction("Engine", "i", playerid);
ShowPlayerMessage(playerid, "funciona", 2);
return 1;
}
pawn Code:
public Engine(playerid)
{
if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
{
new vehicleid = GetPlayerVehicleID(playerid);
if(GLOBAL_VEHICLES[vehicleid][gb_vehicle_TYPE] == VEHICLE_TYPE_WORK)
{
if(TRUCK_VEHICLE[vehicleid][truck_vehicle_LOADING]) return SendClientMessage(playerid, -1, "{999999}Debes esperar a que se cargue el camiуn para arrancar.");
if(TRUCK_VEHICLE[vehicleid][truck_vehicle_UNLOADING]) return SendClientMessage(playerid, -1, "{999999}Debes esperar a que se descargue el camiуn para arrancar.");
}
if(PLAYER_TEMP[playerid][pt_IN_TUNING_GARAGE]) return SendClientMessage(playerid, -1, "{999999}Termina primero.");
KillTimer(PLAYER_TEMP[playerid][pt_TIMERS][7]);
if(GLOBAL_VEHICLES[vehicleid][gb_vehicle_PARAMS_ENGINE])
{
PLAYER_AC_INFO[playerid][CHEAT_VEHICLE_NOFUEL][p_ac_info_IMMUNITY] = gettime() + 15;
GLOBAL_VEHICLES[vehicleid][gb_vehicle_PARAMS_ENGINE] = 0;
UpdateVehicleParams(vehicleid);
if(PLAYER_VEHICLES[vehicleid][player_vehicle_OWNER_ID] == ACCOUNT_INFO[playerid][ac_ID]) Auto_SendPlayerAction(playerid, "ha detenido su vehнculo.");
else Auto_SendPlayerAction(playerid, "ha detenido el vehнculo.");
}
else
{
SendClientMessage(playerid, 0xFFFFFFCC, "Encendiendo...");
PLAYER_TEMP[playerid][pt_TIMERS][7] = SetTimerEx("StartVehicleEngine", 1000, false, "ii", playerid, vehicleid);
}
}
else SendClientMessage(playerid, -1, "{999999}No estбs conduciendo ningъn vehнculo.");
return 1;
}
Re: Function only runs standing -
TheToretto - 31.10.2018
Hello,
check this.
"KEY_CROUCH"'s default key ON FOOT is "C", but inside a vehicle, it changes to H or CAPS LOCK.
So basically keys you can use/detect inside a vehicle are listed in the the last column of that link I gave you.
Re: Function only runs standing -
KaliDobrev - 31.10.2018
Thank you very much, I love it