12.11.2017, 17:32
Код:
CMD:engine(playerid, params[])
CMD:engine(playerid, params[])
Maybe he wants a /engine command, if so, @langit please show us your vehicles enum or whatever you're storing your vehicle data in.
|
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
if ((newkeys & KEY_NO) && !(oldkeys & KEY_NO))
{
if(IsPlayerInAnyVehicle(playerid) // checks if the player is in a vehicle
{
new engine, lights, alarm, doors, bonnet, boot, objective, vehicleid = GetPlayerVehicleID(playerid);
// we create some variables, these ones will store vehicle data. After we get the id of the vehicle
GetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective); //we store vehicles data inside the variables we created
if(engine == 0) engine = 1; //if: the engine is off we turn it on
else if(engine == 1) engine = 0; // viceversa
SetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective); we update vehicles data
}
}
return 1;
}
This is not how you ask for help.
What you need to look at is OnPlayerKeyStateChange, and that's what you need to be using for this. |
{ if (GetPlayerVehicleSeat(playerid) == 0) { if (newkeys & KEY_ANALOG_UP) { return cmd_engine(playerid,""); } } }
SA:MP can only detect GTA SA keys like KEY_FIRE or KEY_SPRINT
If you want to use NumPad8 then you should set on of your GTA sa controls to NumPad8. I will show you how to do that script. The engine will turn on and off when you press N PHP код:
|
it may be easy for you, but I am still learning. I use this code, but I get warning: (17455): warning 217: loose indentation.
and this is the code Код:
{ if (GetPlayerVehicleSeat(playerid) == 0) { if (newkeys & KEY_ANALOG_UP) { return cmd_engine(playerid,""); } } } |