[FilterScript] OnPlayerPressEnter,OnPlayerPressCAPSLOCK etc...
#1

Код:
#include <a_samp>
forward OnPlayerPressMOUSE1(playerid);
forward OnPlayerPressMOUSE2(playerid);
forward OnPlayerPressMOUSE3(playerid);
forward OnPlayerPressLCTRL(playerid);
forward OnPlayerPressRCTRL(playerid);
forward OnPlayerPressSHIFT(playerid);
forward OnPlayerPressCAPSLOCK(playerid);
forward OnPlayerPressENTER(playerid);
forward OnPlayerPressDELETE(playerid);
forward OnPlayerPressEND(playerid);
forward OnPlayerPressC(playerid);
forward OnPlayerPressQ(playerid);
forward OnPlayerPressW(playerid);
forward OnPlayerPressE(playerid);
forward OnPlayerPressS(playerid);
forward OnPlayerPressH(playerid);
forward OnPlayerPressTAB(playerid);
forward OnPlayerPressALT(playerid);
forward OnPlayerPressSPACE(playerid);
forward OnPlayerPressNUMPAD4(playerid);
forward OnPlayerPressNUMPAD6(playerid);
forward OnPlayerPressNUMPAD8(playerid);
forward OnPlayerPressNUMPADADD(playerid);
new KeysNum[15][1]={
{1},//Tab,LCTRLinveh
{2},//C,Hinveh
{4},//LCTRL,MOUSE1,ALTinveh
{8},//SPACE,Winveh
{16},//ENTER
{32},//SHIFT,RCTRL,Sinveh
{64},//Einveh
{128},//CAPSLOCK,DELETE,MOUSE2,SPACEinveh
{256},//Qinveh
{512},//NUMPAD 1,MOUSE3,NUMPAD +inveh,2inveh
{1024},//ALT
{2048},//NUMPAD 8inveh
{4096},//ENDinveh
{8192},//NUMPAD 4
{16384}//NUMPAD 6
};
forward GetPlayerPressKeys(playerid,id);
forward PlayerKeysNumtoKeys(playerid,id);
public PlayerKeysNumtoKeys(playerid,id)
{
	switch(id)
	{
		case 1:
		{
			if(IsPlayerInAnyVehicle(playerid)){CallRemoteFunction("OnPlayerPressLCTRL","d",playerid);}
			else
			{
                CallRemoteFunction("OnPlayerPressTAB","d",playerid);
			}
		}
		case 2:
		{
			if(IsPlayerInAnyVehicle(playerid)){CallRemoteFunction("OnPlayerPressH","d",playerid);}
            else
			{
                CallRemoteFunction("OnPlayerPressC","d",playerid);
			}
		}
		case 4:
		{
			if(IsPlayerInAnyVehicle(playerid)){CallRemoteFunction("OnPlayerPressALT","d",playerid);}
			else
			{
                CallRemoteFunction("OnPlayerPressLCTRL","d",playerid);
                CallRemoteFunction("OnPlayerPressMOUSE1","d",playerid);
			}
		}
		case 8:
		{
			if(IsPlayerInAnyVehicle(playerid)){CallRemoteFunction("OnPlayerPressW","d",playerid);}
            else
			{
                CallRemoteFunction("OnPlayerPressSPACE","d",playerid);
			}
		}
		case 16:
		{
			CallRemoteFunction("OnPlayerPressENTER","d",playerid);
		}
		case 32:
		{
			if(IsPlayerInAnyVehicle(playerid)){CallRemoteFunction("OnPlayerPressS","d",playerid);}
            else
			{
                CallRemoteFunction("OnPlayerPressSHIFT","d",playerid);
                CallRemoteFunction("OnPlayerPressRCTRL","d",playerid);
			}
		}
		case 64:
		{
			if(IsPlayerInAnyVehicle(playerid)){CallRemoteFunction("OnPlayerPressE","d",playerid);}
		}
		case 128:
		{
			if(IsPlayerInAnyVehicle(playerid)){CallRemoteFunction("OnPlayerPressSPACE","d",playerid);}
            else
			{
                CallRemoteFunction("OnPlayerPressCAPSLOCK","d",playerid);
                CallRemoteFunction("OnPlayerPressDELETE","d",playerid);
                CallRemoteFunction("OnPlayerPressMOUSE2","d",playerid);
			}
		}
		case 256:
		{
			if(IsPlayerInAnyVehicle(playerid)){CallRemoteFunction("OnPlayerPressQ","d",playerid);}
		}
		case 512:
		{
			if(IsPlayerInAnyVehicle(playerid)){CallRemoteFunction("OnPlayerPressNUMPADADD","d",playerid);CallRemoteFunction("OnPlayerPress2","d",playerid);}
            else
			{
                CallRemoteFunction("OnPlayerPressNUMPAD1","d",playerid);
                CallRemoteFunction("OnPlayerPressMOUSE3","d",playerid);
			}
		}
		case 1024:
		{
            CallRemoteFunction("OnPlayerPressALT","d",playerid);
		}
		case 2048:
		{
            if(IsPlayerInAnyVehicle(playerid)){CallRemoteFunction("OnPlayerPressNUMPAD8","d",playerid);}
		}
		case 4096:
		{
            if(IsPlayerInAnyVehicle(playerid)){CallRemoteFunction("OnPlayerPressEND","d",playerid);}
		}
		case 8192:
		{
		    CallRemoteFunction("OnPlayerPressNUMPAD4","d",playerid);
		}
		case 16384:
		{
		    CallRemoteFunction("OnPlayerPressNUMPAD6","d",playerid);
		}
	}
}
public GetPlayerPressKeys(playerid,id)
{
	for(new a=0;a<15;a++)
	{
	    if(id>=KeysNum[a][0]&&KeysNum[a][0]>0)
	    {
	        if(id==KeysNum[a][0]){PlayerKeysNumtoKeys(playerid,KeysNum[a][0]);}
			for(new b=0;b<15;b++)
			{
			    if(id>=KeysNum[a][0]+KeysNum[b][0]&&KeysNum[b][0]>0)
	    		{
	    		    if(a!=b&&id==KeysNum[a][0]+KeysNum[b][0]&&KeysNum[a][0]>KeysNum[b][0]){PlayerKeysNumtoKeys(playerid,KeysNum[a][0]);PlayerKeysNumtoKeys(playerid,KeysNum[b][0]);}
		    		for(new c=0;c<15;c++)
					{
						if(id>=KeysNum[a][0]+KeysNum[b][0]+KeysNum[c][0]&&KeysNum[c][0]>0)
	    				{
	    				    if(a!=b&&b!=c&&id==KeysNum[a][0]+KeysNum[b][0]+KeysNum[c][0]&&KeysNum[a][0]>KeysNum[b][0]&&KeysNum[b][0]>KeysNum[c][0]){PlayerKeysNumtoKeys(playerid,KeysNum[a][0]);PlayerKeysNumtoKeys(playerid,KeysNum[b][0]);PlayerKeysNumtoKeys(playerid,KeysNum[c][0]);}
	    				    for(new d=0;d<15;d++)
							{
							    if(id>=KeysNum[a][0]+KeysNum[b][0]+KeysNum[c][0]+KeysNum[d][0]&&KeysNum[c][0]>0)
	    						{
									if(a!=b&&b!=c&&c!=d&&id==KeysNum[a][0]+KeysNum[b][0]+KeysNum[c][0]+KeysNum[d][0]&&KeysNum[a][0]>KeysNum[b][0]&&KeysNum[b][0]>KeysNum[c][0]&&KeysNum[c][0]>KeysNum[d][0]){PlayerKeysNumtoKeys(playerid,KeysNum[a][0]);PlayerKeysNumtoKeys(playerid,KeysNum[b][0]);PlayerKeysNumtoKeys(playerid,KeysNum[c][0]);PlayerKeysNumtoKeys(playerid,KeysNum[d][0]);}
	    				    		for(new e=0;e<15;e++)
									{
									    if(id>=KeysNum[a][0]+KeysNum[b][0]+KeysNum[c][0]+KeysNum[d][0]+KeysNum[e][0]&&KeysNum[c][0]>0)
	    								{
                                            if(a!=b&&b!=c&&c!=d&&d!=e&&id==KeysNum[a][0]+KeysNum[b][0]+KeysNum[c][0]+KeysNum[d][0]+KeysNum[e][0]&&KeysNum[a][0]>KeysNum[b][0]&&KeysNum[b][0]>KeysNum[c][0]&&KeysNum[c][0]>KeysNum[d][0]&&KeysNum[d][0]>KeysNum[e][0]){PlayerKeysNumtoKeys(playerid,KeysNum[a][0]);PlayerKeysNumtoKeys(playerid,KeysNum[b][0]);PlayerKeysNumtoKeys(playerid,KeysNum[c][0]);PlayerKeysNumtoKeys(playerid,KeysNum[d][0]);PlayerKeysNumtoKeys(playerid,KeysNum[e][0]);}
										}
									}
								}
							}
						}

					}
				}
			}
		}
	}
}

public OnPlayerUpdate(playerid)
{
    new Keys,ud,lr;
    GetPlayerKeys(playerid,Keys,ud,lr);
    if(!IsPlayerNPC(playerid)&&Keys!=ud&&Keys!=lr)
    {
    	//printf("%d) keys : %d ud : %d lr : %d",playerid,Keys,ud,lr);
    	GetPlayerPressKeys(playerid,Keys);
    }
	return 1;
}
public OnPlayerPressMOUSE1(playerid){return 1;}
public OnPlayerPressMOUSE2(playerid){return 1;}
public OnPlayerPressMOUSE3(playerid){return 1;}
public OnPlayerPressLCTRL(playerid){return 1;}
public OnPlayerPressRCTRL(playerid){return 1;}
public OnPlayerPressSHIFT(playerid){return 1;}
public OnPlayerPressCAPSLOCK(playerid){return 1;}
public OnPlayerPressENTER(playerid){return 1;}
public OnPlayerPressDELETE(playerid){return 1;}
public OnPlayerPressEND(playerid){return 1;}
public OnPlayerPressC(playerid){return 1;}
public OnPlayerPressQ(playerid){return 1;}
public OnPlayerPressW(playerid){return 1;}
public OnPlayerPressE(playerid){return 1;}
public OnPlayerPressS(playerid){return 1;}
public OnPlayerPressH(playerid){return 1;}
public OnPlayerPressTAB(playerid){return 1;}
public OnPlayerPressALT(playerid){return 1;}
public OnPlayerPressSPACE(playerid){return 1;}
public OnPlayerPressNUMPAD4(playerid){return 1;}
public OnPlayerPressNUMPAD6(playerid){return 1;}
public OnPlayerPressNUMPAD8(playerid){return 1;}
public OnPlayerPressNUMPADADD(playerid){return 1;}
the CallRemoteFunction can call your GAMEMODE functions.
you can put only forward and public in your gamemode with this filtersciprt.
by me(gameid:MO_HATE)
Reply
#2

Looks nice go in to test it....
Reply
#3

look good,
will test

BTW nice & GJ
Reply
#4

not bad Great
!!!!!!!!!!
Reply
#5

did anyone tested this?
Reply
#6

Quote from wiki.sa-mp.com:

Quote:

This callback is called whenever a player presses or releases one of the watched keys (see GetPlayerKeys). The keys which are watched are not all keyboard keys, but just San Andreas assigned function keys, this means that, for example, you can't detect when someone presses the "A" key, but can detect when they press their sprint key (which may, or may not, be assigned to "A").

Now read it until you understand why your code is incorrect.
Reply
#7

What he's trying to say is, the server isn't detecting what key is being pressed, the server is detecting when a player presses the Jump key, sprint key, etc. Which means if I were to change my sprint key to SHIFT and my jump key to INSERT, then when I press SHIFT your script will think I pressed SPACE BAR
Reply
#8

Quote:
Originally Posted by Joe Staff
Посмотреть сообщение
What he's trying to say is, the server isn't detecting what key is being pressed, the server is detecting when a player presses the Jump key, sprint key, etc. Which means if I were to change my sprint key to SHIFT and my jump key to INSERT, then when I press SHIFT your script will think I pressed SPACE BAR
oh..
so can sa:mp team fix this?
Reply
#9

sorry for double posting but:
i've tested your include,and here the results:
Код:
Include         -Result
Left CTRL      - Mouse1
Right CTRL    - Right CTRL
Left Shift       - Right CTRL
Enter            - Enter
F                  - Enter
Right Shift     - Nothing
Delete           - Mouse2
CapsLock      - Mouse2
Right Enter    - nothing
Q                  - Nothing
E                   -  Nothing
W                  -  Nothing
S                   -  Nothing
Right Alt         - Nothing
Left Alt           - Alt
NUMPAD1       - Mouse3
NUMPAD4       - NUMPAD4
NUMPAD6       - NUMPAD6
\                    - TAB
TAB               - TAB
Mouse1          - Mouse1
Mouse2          - Mouse2
Mouse3          - Mouse3
Space            - Space
End                - Nothing
C                   - C
NUMPAD0        - Mouse1
thats all
you should fix them.
GL
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)