MMB - 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)
+--- Thread: MMB (
/showthread.php?tid=635283)
MMB -
Cyboorg - 04.06.2017
Hello, how can i add a commands that will be executed when mmb is pressed?
Re: MMB -
Swarn - 04.06.2017
Код:
#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?
Re: MMB -
Beryllium - 05.06.2017
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
Re: MMB -
Sew_Sumi - 05.06.2017
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.