#1

Hello, how can i add a commands that will be executed when mmb is pressed?
Reply
#2

Код:
#define PRESSED(%0) (((newkeys & (%0)) == (%0)) && ((oldkeys & (%0)) != (%0)))
Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
	if(PRESSED(KEY_LOOK_BEHIND))
	{
	    // execute command
	}
    return 1;
}
Something like this?
Reply
#3

Quote:
Originally Posted by Swarn
Посмотреть сообщение
Код:
#define PRESSED(%0) (((newkeys & (%0)) == (%0)) && ((oldkeys & (%0)) != (%0)))
Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
	if(PRESSED(KEY_LOOK_BEHIND))
	{
	    // execute command
	}
    return 1;
}
Something like this?
Why did you define "PRESSED"?

He can use it as simple.

Example:

Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if(newkeys & /*<Insert your key here>*/)
    {
		//<Insert your action/code here>
    }
    return 1;
}
Read more about keys here

https://sampwiki.blast.hk/wiki/Keys
Reply
#4

I'd avoid Berylliums suggestion, and use the next version down in the wiki.

Код:
if ((newkeys & KEY_FIRE) && !(oldkeys & KEY_FIRE))
This is why the second poster defined PRESSED.

Using Berylliums method, you could flood the server everytime someone looks behind them, as with the above, and PRESSED situation it fires once.

With Berylliums, it'll spam, and will be likely to cause acklimit errors. Especially being that that key, is a common one to be using.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)