how to turn the vehicle on with nump8 -
langit - 12.11.2017
Код:
CMD:engine(playerid, params[])
Re: how to turn the vehicle on with nump8 -
Sew_Sumi - 12.11.2017
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.
Re: how to turn the vehicle on with nump8 -
thefirestate - 12.11.2017
OnPlayerKeyStateChange and this
https://sampwiki.blast.hk/wiki/Keys everything else should be common sense on how to do it(hint: default numpad8 is KEY_ANALOG_UP(onfoot) and VEHICLE_TURRETUP(in a vehicle))
Re: how to turn the vehicle on with nump8 -
Erioni - 12.11.2017
Maybe he wants a /engine command, if so, @langit please show us your vehicles enum or whatever you're storing your vehicle data in.
Re: how to turn the vehicle on with nump8 -
Sew_Sumi - 12.11.2017
Quote:
Originally Posted by Erioni
Maybe he wants a /engine command, if so, @langit please show us your vehicles enum or whatever you're storing your vehicle data in.
|
He's handed out the command for engine, so that someone can make an OnPlayerKeyStateChange 'helper' for him to get it working.
Asking for more code, is simply going to encourage the copy-paster...
Re: how to turn the vehicle on with nump8 -
Lucases - 12.11.2017
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 код:
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;
}
Re: how to turn the vehicle on with nump8 -
langit - 13.11.2017
Quote:
Originally Posted by Sew_Sumi
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.
|
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,"");
}
}
}
Re: how to turn the vehicle on with nump8 -
langit - 13.11.2017
Quote:
Originally Posted by Lucases
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 код:
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;
}
|
why i want to use nump8? because if I use KEY N Y it will conflict with other ang
Re: how to turn the vehicle on with nump8 -
Dayrion - 13.11.2017
Quote:
Originally Posted by langit
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,"");
}
}
}
|
Yes i'm pretty sure it's easy for him to do what you want but he learned how to make it, he learned by asking some good questions. So yes, he's totally right. This not how you ask for some help.
You have to understand by yourself instead of copy/past a bunch of code with some hope it will work even you don't know why and how.
Re: how to turn the vehicle on with nump8 -
TitoRayne - 13.11.2017
Quote:
Originally Posted by langit
why i want to use nump8? because if I use KEY N Y it will conflict with other ang
|
Why dont u try the given code? it will work tho lol