SA-MP Forums Archive
How to make a key instead of typing /enter+/exit? - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: How to make a key instead of typing /enter+/exit? (/showthread.php?tid=190792)



How to make a key instead of typing /enter+/exit? - Ehab1911 - 16.11.2010

Hello, I want to know how to make the Enter key to enter and exit places instead of typing /enter and /exit. Plus how can I make a command to toggle Key, and Enter / Exit. Like

/toggleenter on/off

if player types

/toggleenter

a text says:

" This will toggle the Enter key instead of typing /enter and /exit, type /toggleenter on to toggle the Enter Key "

Regards, Ehab Isaac.


Re: How to make a key instead of typing /enter+/exit? - sansko - 16.11.2010

use on player keystate change


Re: How to make a key instead of typing /enter+/exit? - JaTochNietDan - 16.11.2010

You would make use of OnPlayerKeyStateChange, for example:

pawn Код:
public OnPlayerKeyStateChange(playerid,newkeys,oldkeys)
{
    if(newkeys & keyid) // You need to find the keyID for the key that you want to be pressed to do this
    {
        OnPlayerCommandText(playerid,"/enter");
        // Alternatively you could paste the contents of the "/enter" command here.
    }
}
As for the /toggleenter, you just need to implement a simple variable that's either true or false, then implementing it in a /toggleenter command and in the OnPlayerKeyState function.


Re: How to make a key instead of typing /enter+/exit? - Ehab1911 - 16.11.2010

Quote:
Originally Posted by JaTochNietDan
Посмотреть сообщение
You would make use of OnPlayerKeyStateChange, for example:

pawn Код:
public OnPlayerKeyStateChange(playerid,newkeys,oldkeys)
{
    if(newkeys & keyid) // You need to find the keyID for the key that you want to be pressed to do this
    {
        OnPlayerCommandText(playerid,"/enter");
        // Alternatively you could paste the contents of the "/enter" command here.
    }
}
As for the /toggleenter, you just need to implement a simple variable that's either true or false, then implementing it in a /toggleenter command and in the OnPlayerKeyState function.

Oh, hmm will this be for all entrances and exiting places?



Ah I have put them now, but there are 2 Errors:

Код:
C:\Users\Ehab Isaac\Documents\My Received Files\sarp.pwn(11510) : error 017: undefined symbol "newkeys"
C:\Users\Ehab Isaac\Documents\My Received Files\sarp.pwn(11514) : error 017: undefined symbol "newkeys"
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


2 Errors.



Re: How to make a key instead of typing /enter+/exit? - JaTochNietDan - 16.11.2010

If you have the same code in there as /enter, then it should work exactly as /enter does.

Of course you'll need to make a seperate key for /exit, or use the same key and check if the player is already in a place or not.


Re: How to make a key instead of typing /enter+/exit? - Ehab1911 - 16.11.2010

Aha, Alright. hmm but now I have 2 Errors:

Код:
C:\Users\Ehab Isaac\Documents\My Received Files\sarp.pwn(11510) : error 017: undefined symbol "newkeys"
C:\Users\Ehab Isaac\Documents\My Received Files\sarp.pwn(11514) : error 017: undefined symbol "newkeys"
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


2 Errors.
what should I do :S?


Re: How to make a key instead of typing /enter+/exit? - JaTochNietDan - 16.11.2010

Read the comments, you need to find the keyID of the key that you want to activate the code when pressed.

For example, 1 is the keyID for the fire button (KEY_FIRE)


Re: How to make a key instead of typing /enter+/exit? - Ehab1911 - 16.11.2010

Oh so I put instead of KeyID (KEY_ACTION) ?


Ok I've replaced them

but 2 warnings:

Код:
C:\Users\Ehab Isaac\Documents\My Received Files\sarp.pwn(11510) : warning 206: redundant test: constant expression is non-zero
C:\Users\Ehab Isaac\Documents\My Received Files\sarp.pwn(11514) : warning 206: redundant test: constant expression is non-zero
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


2 Warnings.
what should i do :S?


Re: How to make a key instead of typing /enter+/exit? - JaTochNietDan - 16.11.2010

Quote:
Originally Posted by Ehab1911
Посмотреть сообщение
Oh so I put instead of KeyID (KEY_ACTION) ?
Yes, if that is the key you wish to use.


Re: How to make a key instead of typing /enter+/exit? - Flyfishes - 16.11.2010

Yes, you do!