SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help > Help Archive

 
 
Thread Tools Display Modes
Old 27/02/2009, 11:40 AM   #1
Mrkrabz
High-roller
 
Join Date: Sep 2007
Location: United Kingdom
Posts: 2,082
Reputation: 258
Default Key bind


How can i make a command which will be /engine so we can start the engine, in to a key like CTRL or something?

Here is the command:

pawn Code:
if(strcmp(cmd, "/engine", true) == 0)
    {
        if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
        {
          if(EngineStatus[GetPlayerVehicleID(playerid)] == 0)
            {
                TogglePlayerControllable(playerid,1);
                EngineStatus[GetPlayerVehicleID(playerid)] = 1;
                if(PlayerInfo[playerid][pSex] == 1)
                {
                    PlayerActionMessage(playerid,15.0,"has just started the engine of his vehicle.");
                }
                else
                {
                    PlayerActionMessage(playerid,15.0,"has just started the engine of her vehicle.");
                }
            }
            else
            {
                TogglePlayerControllable(playerid,0);
                EngineStatus[GetPlayerVehicleID(playerid)] = 0;

                if(PlayerInfo[playerid][pSex] == 1)
                {
                    PlayerActionMessage(playerid,15.0,"has just stopped the engine of his vehicle.");
                }
                else
                {
                    PlayerActionMessage(playerid,15.0,"has just stopped the engine of her vehicle.");
                }
            }
        }
        else
        {
          SendClientMessage(playerid,COLOR_LIGHTYELLOW2,"[ERROR:] You are not even in a car!");
        }
        return 1;
    }
Mrkrabz is offline  
Old 27/02/2009, 11:46 AM   #2
zyx
Little Clucker
 
Join Date: Feb 2009
Posts: 44
Reputation: 0
Default Re: Key bind

http://wiki.sa-mp.com/wiki/OnPlayerKeyStateChange
http://wiki.sa-mp.com/wiki/GetPlayerKeys
zyx is offline  
Old 27/02/2009, 11:48 AM   #3
CracK
Huge Clucker
 
CracK's Avatar
 
Join Date: Nov 2007
Posts: 425
Reputation: 2
Default Re: Key bind

pawn Code:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
   if(newkeys == KEY_JUMP) OnPlayerCommandText(playerid,"/engine");
}
KEY_JUMP is ctrl usually if I am not mistaken.
__________________
Custom Enex loader 1.0
map2pwn
CracK is offline  
Old 27/02/2009, 12:05 PM   #4
MenaceX^
High-roller
 
Join Date: Aug 2008
Posts: 3,821
Reputation: 13
Default Re: Key bind

I think you would be asking it in Carlito's Roleplay script.
MenaceX^ is offline  
Old 27/02/2009, 12:07 PM   #5
Y_Less
Beta Tester
 
Y_Less's Avatar
 
Join Date: Jun 2008
Location: 629 - git.io/Y
Posts: 18,148
Reputation: 2540
Default Re: Key bind

Quote:
Originally Posted by CracKman
pawn Code:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
   if(newkeys == KEY_JUMP) OnPlayerCommandText(playerid,"/engine");
}
KEY_JUMP is ctrl usually if I am not mistaken.
Not on my setup, and I suspect not on other people's too. You can change keys, there's no way to guarantee what key they're pressing.
Y_Less is online now  
Old 27/02/2009, 12:29 PM   #6
CracK
Huge Clucker
 
CracK's Avatar
 
Join Date: Nov 2007
Posts: 425
Reputation: 2
Default Re: Key bind

That's why I said usually...
__________________
Custom Enex loader 1.0
map2pwn
CracK is offline  
 

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How can I make a bind? Asaffo Help Archive 2 19/09/2009 08:22 AM
What is Bind? [mad]MLK Help Archive 2 21/08/2009 11:19 PM
Key Bind :S basker Help Archive 2 07/08/2009 11:30 AM


All times are GMT. The time now is 11:32 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.