Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* @KEY BIND INGAME - SAMP
- @BY DARKZEROX
- */
- #include <a_samp>
- #define NO_MESSAGE "no message"
- new KeyBindActif[MAX_PLAYERS];
- new string[500];
- new gString[500];
- new ItemKey[MAX_PLAYERS];
- new Nom[25];
- enum KeyBind
- {
- Message[250],
- Key
- }
- new KBT[MAX_PLAYERS][5][KeyBind];
- public OnFilterScriptInit()
- {
- print("\n--------------------------------------");
- print("[Ouverture du Key Bind]");
- print("--------------------------------------\n");
- return 1;
- }
- public OnPlayerCommandText(playerid, cmdtext[])
- {
- if (strcmp("/key", cmdtext, true, 10) == 0)
- {
- DialogueKeyBind(playerid);
- return 1;
- }
- return 1;
- }
- public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
- {
- if(dialogid == 1)
- {
- if(!response) return 1;
- if(KeyBindActif[playerid] == 0)
- {
- KeyBindActif[playerid] = 1;
- DialogueKeyBind(playerid);
- return 1;
- }
- if(listitem == 0) return 1;
- ItemKey[playerid] = listitem;
- if(KBT[playerid][listitem][Key] == 0)
- ShowPlayerDialog(playerid,2, DIALOG_STYLE_INPUT, "{33AA33}KeyBind","Enter the desired message", "Next", "Cancel");
- else
- ShowPlayerDialog(playerid,2, DIALOG_STYLE_INPUT, "{33AA33}KeyBind","Enter the desired message", "Next", "Cancel");
- return 1;
- }
- if(dialogid == 2)
- {
- strmid(KBT[playerid][ItemKey[playerid]][Message],inputtext, 0, strlen(inputtext), 250);
- if(ItemKey[playerid] == 1)
- KBT[playerid][ItemKey[playerid]][Key] = 2;
- if(ItemKey[playerid] == 2)
- KBT[playerid][ItemKey[playerid]][Key] = 4;
- if(ItemKey[playerid] == 3)
- KBT[playerid][ItemKey[playerid]][Key] = 6;
- if(ItemKey[playerid] == 4)
- KBT[playerid][ItemKey[playerid]][Key] = 8;
- DialogueKeyBind(playerid);
- return 1;
- }
- return 1;
- }
- stock DialogueKeyBind(playerid)
- {
- if(KeyBindActif[playerid] == 0)
- {
- ShowPlayerDialog(playerid,1, DIALOG_STYLE_LIST, "{33AA33}KeyBind","Click to activate the keybind", "Ok", "Cancel");
- return 1;
- }
- else
- {
- gString = "";
- string = "";
- for(new i = 0; i < 6; i++)
- {
- if(KBT[playerid][i][Key] == 0)
- format(string, 64, NO_MESSAGE);
- else
- format(string, 64, "{FF0000}Key : %d\tMessage : %s",KBT[playerid][i][Key],KBT[playerid][i][Message]);
- format(gString, sizeof(gString), "%s%s\n", gString, string);
- ShowPlayerDialog(playerid,1, DIALOG_STYLE_LIST, "{33AA33}KeyBind",gString, "Next", "Cancel");
- }
- return 1;
- }
- return 1;
- }
- public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
- {
- if (newkeys == 512)
- {
- if (!IsPlayerInAnyVehicle(playerid))
- {
- if(KBT[playerid][1][Message] != 0)
- {
- GetPlayerName(playerid,Nom, sizeof(Nom));
- format(string, 64, "%s : %s",Nom,KBT[playerid][1][Message]);
- SendClientMessageToAll(-1,string);
- }
- }
- }
- if (newkeys == 8192)
- {
- if (!IsPlayerInAnyVehicle(playerid))
- {
- if(KBT[playerid][2][Message] != 0)
- {
- GetPlayerName(playerid,Nom, sizeof(Nom));
- format(string, 64, "%s : %s",Nom,KBT[playerid][2][Message]);
- SendClientMessageToAll(-1,string);
- }
- }
- }
- if (newkeys == 16384)
- {
- if (!IsPlayerInAnyVehicle(playerid))
- {
- if(KBT[playerid][3][Message] != 0)
- {
- GetPlayerName(playerid,Nom, sizeof(Nom));
- format(string, 64, "%s : %s",Nom,KBT[playerid][3][Message]);
- SendClientMessageToAll(-1,string);
- }
- }
- }
- if (newkeys == 2048)
- {
- if (!IsPlayerInAnyVehicle(playerid))
- {
- if(KBT[playerid][4][Message] != 0)
- {
- GetPlayerName(playerid,Nom, sizeof(Nom));
- format(string, 64, "%s : %s",Nom,KBT[playerid][4][Message]);
- SendClientMessageToAll(-1,string);
- }
- }
- }
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement