how to turn the vehicle on with nump8
#1

Код:
CMD:engine(playerid, params[])
Reply
#2

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.
Reply
#3

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))
Reply
#4

Maybe he wants a /engine command, if so, @langit please show us your vehicles enum or whatever you're storing your vehicle data in.
Reply
#5

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...
Reply
#6

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(playeridnewkeysoldkeys)
{
        if ((
newkeys KEY_NO) && !(oldkeys KEY_NO))
        {
                 if(
IsPlayerInAnyVehicle(playerid// checks if the player is in a vehicle
                 
{
                         new 
enginelightsalarmdoorsbonnetbootobjectivevehicleid GetPlayerVehicleID(playerid);
    
// we create some variables, these ones will store vehicle data. After we get the id of the vehicle                      
                         
GetVehicleParamsEx(vehicleidenginelightsalarmdoorsbonnetbootobjective); //we store vehicles data inside the variables we created
                          
if(engine == 0engine 1//if: the engine is off we turn it on
                          
else if(engine == 1engine 0// viceversa
                          
SetVehicleParamsEx(vehicleidenginelightsalarmdoorsbonnetbootobjective); we update vehicles data
                  
}
          }
          return 
1;

Reply
#7

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,"");
			}
		}
	}
Reply
#8

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(playeridnewkeysoldkeys)
{
        if ((
newkeys KEY_NO) && !(oldkeys KEY_NO))
        {
                 if(
IsPlayerInAnyVehicle(playerid// checks if the player is in a vehicle
                 
{
                         new 
enginelightsalarmdoorsbonnetbootobjectivevehicleid GetPlayerVehicleID(playerid);
    
// we create some variables, these ones will store vehicle data. After we get the id of the vehicle                      
                         
GetVehicleParamsEx(vehicleidenginelightsalarmdoorsbonnetbootobjective); //we store vehicles data inside the variables we created
                          
if(engine == 0engine 1//if: the engine is off we turn it on
                          
else if(engine == 1engine 0// viceversa
                          
SetVehicleParamsEx(vehicleidenginelightsalarmdoorsbonnetbootobjective); 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
Reply
#9

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.
Reply
#10

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
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)