How can I change that key ?
#1

How can I make also u can type in the command : /engine and only type on "2"

Код:
CMD:engine(playerid, params[])
	{
	    new string[128];
		new engine,lights,alarm,doors,bonnet,boot,objective,vehicleid;
		vehicleid = GetPlayerVehicleID(playerid);
		if(GetVehicleModel(vehicleid) == 481 || GetVehicleModel(vehicleid) == 509 || GetVehicleModel(vehicleid) == 510) return SendClientMessageEx(playerid,COLOR_WHITE,"This command can't be used in this vehicle.");
		GetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,boot,objective);
		if(engine == VEHICLE_PARAMS_ON)
		{
			SetVehicleEngine(vehicleid, playerid);
		}
		else if((engine == VEHICLE_PARAMS_OFF || engine == VEHICLE_PARAMS_UNSET))
		{
			SendClientMessageEx(playerid, COLOR_WHITE, "Vehicle engine starting, please wait...");
	        format(string, sizeof(string), "%s is attempting to turn the car on.", GetPlayerNameEx(playerid));
     		ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
			SetTimerEx("SetVehicleEngine", 1000, 0, "dd",  vehicleid, playerid);
			return 1;
		}
	}
Reply
#2

Use :-
pawn Код:
#define PRESSED(%0) \
    (((newkeys & (%0)) == (%0)) && ((oldkeys & (%0)) != (%0)))
   
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if (PRESSED(KEY_ANALOG_DOWN))
    {
        new string[128];
        new engine,lights,alarm,doors,bonnet,boot,objective,vehicleid;
        vehicleid = GetPlayerVehicleID(playerid);
        if(GetVehicleModel(vehicleid) == 481 || GetVehicleModel(vehicleid) == 509 || GetVehicleModel(vehicleid) == 510) return SendClientMessageEx(playerid,COLOR_WHITE,"This command can't be used in this vehicle.");
        GetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,boot,objective);
        if(engine == VEHICLE_PARAMS_ON)
        {
            SetVehicleEngine(vehicleid, playerid);
        }
        else if((engine == VEHICLE_PARAMS_OFF || engine == VEHICLE_PARAMS_UNSET))
        {
            SendClientMessageEx(playerid, COLOR_WHITE, "Vehicle engine starting, please wait...");
            format(string, sizeof(string), "%s is attempting to turn the car on.", GetPlayerNameEx(playerid));
            ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
            SetTimerEx("SetVehicleEngine", 1000, 0, "dd",  vehicleid, playerid);
            return 1;
        }
    }
    return 1;
}
Reply
#3

pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if (newkeys & KEY_SUBMISSION))
    {
         return cmd_engine(playerid);
    }
    return 1;
}
Reply
#4

Quote:
Originally Posted by Rajat_Pawar
Посмотреть сообщение
pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if (newkeys & KEY_SUBMISSION))
    {
         return cmd_engine(playerid, params);
    }
    return 1;
}
Wheres the 2? here ? Lol
Reply
#5

Quote:
Originally Posted by yaron0600
Посмотреть сообщение
Wheres the 2? here ? Lol
Tried My Function?
Reply
#6

Quote:
Originally Posted by yaron0600
Посмотреть сообщение
Wheres the 2? here ? Lol
2 is the KEY_SUBMISSION key. (also the same as MMB)
Reply
#7

Quote:
Originally Posted by SimpalK
Посмотреть сообщение
Use :-
pawn Код:
#define PRESSED(%0) \
    (((newkeys & (%0)) == (%0)) && ((oldkeys & (%0)) != (%0)))
   
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if (PRESSED(KEY_ANALOG_DOWN))
    {
        new string[128];
        new engine,lights,alarm,doors,bonnet,boot,objective,vehicleid;
        vehicleid = GetPlayerVehicleID(playerid);
        if(GetVehicleModel(vehicleid) == 481 || GetVehicleModel(vehicleid) == 509 || GetVehicleModel(vehicleid) == 510) return SendClientMessageEx(playerid,COLOR_WHITE,"This command can't be used in this vehicle.");
        GetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,boot,objective);
        if(engine == VEHICLE_PARAMS_ON)
        {
            SetVehicleEngine(vehicleid, playerid);
        }
        else if((engine == VEHICLE_PARAMS_OFF || engine == VEHICLE_PARAMS_UNSET))
        {
            SendClientMessageEx(playerid, COLOR_WHITE, "Vehicle engine starting, please wait...");
            format(string, sizeof(string), "%s is attempting to turn the car on.", GetPlayerNameEx(playerid));
            ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
            SetTimerEx("SetVehicleEngine", 1000, 0, "dd",  vehicleid, playerid);
            return 1;
        }
    }
    return 1;
}
But where the also cmd : /engine and where here the "2" ? ? ?
Reply
#8

Quote:
Originally Posted by ******
Посмотреть сообщение
No it isn't. The KEY_SUBMISSION key is whatever key the player has mapped to that function. There is NO WAY to specify exact keys.
Obviously, I meant that. Sure, no one can predict what the control keys layout of the player is going to be.
Reply
#9

Quote:
Originally Posted by ******
Посмотреть сообщение
Then say that instead of spreading mis-information.
While I agree with the majority of the posts you make, I think you're pressing the issue way too far. The default KEY_SUBMISSION is 2. When someone asks for code which will do some action when number 2 is pressed, it is by no means an unfair assumption that the player will be using the default layout which the majority of players use. By making this assumption, Rajat was in no way spreading misinformation.

If someone needs some form of specialized help (such as having an odd layout), they should mention the circumstances surrounding the issue (such as my number 2 key is actually mapped to ______). Every time someone gets helped on these forums, assumptions are made about the player, their script, and what they are attempting to achieve because topics have become more and more vague.

Besides, when Rajat explained that the number 2 key was KEY_SUBMISSION, if the OP lacks the necessary cognitive abilities to deduce that his uber l337 southpaw legacy controller layout may use a different key for the action KEY_SUBMISSION, he probably wouldn't have been able to register for the forums in the first place.
Reply
#10

Quote:
Originally Posted by RevolutionaryGaming
Посмотреть сообщение
I think you're pressing the issue way too far.
******, I replied casually, that's it. End of topic.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)