Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <a_samp>
- #include <dini>
- #define VERSION "---BIND System V1 By DreDas---"
- #define PRESSED(%0) \
- (((newkeys & (%0)) == (%0)) && ((oldkeys & (%0)) != (%0)))
- enum keys
- {
- TAB,
- C,
- LMB,
- SPACE,
- ENTER,
- LSHIFT,
- NUM1,
- NUM8,
- NUM2,
- NUM4,
- NUM6,
- Y,
- N,
- H
- }
- #define K_TAB KEY_ACTION
- #define K_C KEY_CROUCH
- #define K_LMB KEY_FIRE
- #define K_SPACE KEY_SPRINT
- #define K_ENTER KEY_SECONDARY_ATTACK
- #define K_LSHIFT KEY_JUMP
- #define K_NUM1 KEY_SUBMISSION
- #define K_NUM8 KEY_ANALOG_UP
- #define K_NUM2 KEY_ANALOG_DOWN
- #define K_NUM4 KEY_ANALOG_LEFT
- #define K_NUM6 KEY_ANALOG_RIGHT
- #define K_Y KEY_YES
- #define K_N KEY_NO
- #define K_H KEY_CTRL_BACK
- new Commands[][] =
- {
- "{FF0000}Unbind",
- "{04C731}Zinute",
- "{04C731}GautiHP",
- "{04C731}GautiArmor"
- };
- new pKey[MAX_PLAYERS][keys];
- new pasirinko[MAX_PLAYERS];
- #define GUI_KEY_LIST 105
- #define GUI_CMDS_LIST 106
- stock pName(playerid)
- {
- new Vardas[MAX_PLAYER_NAME];
- GetPlayerName(playerid,Vardas,MAX_PLAYER_NAME);
- return Vardas;
- }
- public OnFilterScriptInit()
- {
- print("\n--------------------------------------");
- print(" Bind Script By DreDas Loaded ");
- print("--------------------------------------\n");
- return 1;
- }
- public OnFilterScriptExit()
- {
- return 1;
- }
- public OnPlayerConnect(playerid)
- {
- new string[128];
- SendClientMessage(playerid,014789,"Sveikas Atvykęs");
- format(string,sizeof(string),"Bind/%s.txt",pName(playerid));
- if(!dini_Exists(string))
- {
- dini_Create(string);
- dini_IntSet(string,"TAB",pKey[playerid][TAB]);
- dini_IntSet(string,"C",pKey[playerid][C]);
- dini_IntSet(string,"LMB",pKey[playerid][LMB]);
- dini_IntSet(string,"SPACE",pKey[playerid][SPACE]);
- dini_IntSet(string,"ENTER",pKey[playerid][ENTER]);
- dini_IntSet(string,"LSHIFT",pKey[playerid][LSHIFT]);
- dini_IntSet(string,"NUM1",pKey[playerid][NUM1]);
- dini_IntSet(string,"NUM8",pKey[playerid][NUM8]);
- dini_IntSet(string,"NUM2",pKey[playerid][NUM2]);
- dini_IntSet(string,"NUM4",pKey[playerid][NUM4]);
- dini_IntSet(string,"NUM6",pKey[playerid][NUM6]);
- dini_IntSet(string,"Y",pKey[playerid][Y]);
- dini_IntSet(string,"N",pKey[playerid][N]);
- dini_IntSet(string,"H",pKey[playerid][H]);
- }
- else
- {
- pKey[playerid][TAB] = dini_Int(string, "TAB");
- pKey[playerid][C] = dini_Int(string, "C");
- pKey[playerid][LMB] = dini_Int(string, "LMB");
- pKey[playerid][SPACE] = dini_Int(string, "SPACE");
- pKey[playerid][ENTER] = dini_Int(string, "ENTER");
- pKey[playerid][LSHIFT] = dini_Int(string, "LSHIFT");
- pKey[playerid][NUM1] = dini_Int(string, "NUM1");
- pKey[playerid][NUM8] = dini_Int(string, "NUM8");
- pKey[playerid][NUM2] = dini_Int(string, "NUM2");
- pKey[playerid][NUM4] = dini_Int(string, "NUM4");
- pKey[playerid][NUM6] = dini_Int(string, "NUM6");
- pKey[playerid][Y] = dini_Int(string, "Y");
- pKey[playerid][N] = dini_Int(string, "N");
- pKey[playerid][H] = dini_Int(string, "H");
- }
- return 1;
- }
- public OnPlayerDisconnect(playerid, reason)
- {
- SaveInfo(playerid);
- return 1;
- }
- public OnPlayerCommandText(playerid, cmdtext[])
- {
- if(!strcmp(cmdtext, "/bind", true))
- {
- new string[512], string1[600];
- new TAB1[40],C1[40],LMB1[40],SPACE1[40],ENTER1[40],LSHIFT1[40];
- new NUM11[40],NUM81[40],NUM21[40],NUM41[40],NUM61[40],Y1[40],N1[40],H1[40];
- ZaidejoKomandos(playerid,TAB,TAB1);
- ZaidejoKomandos(playerid,C,C1);
- ZaidejoKomandos(playerid,LMB,LMB1);
- ZaidejoKomandos(playerid,SPACE,SPACE1);
- ZaidejoKomandos(playerid,ENTER,ENTER1);
- ZaidejoKomandos(playerid,LSHIFT,LSHIFT1);
- ZaidejoKomandos(playerid,NUM1,NUM11);
- ZaidejoKomandos(playerid,NUM8,NUM81);
- ZaidejoKomandos(playerid,NUM2,NUM21);
- ZaidejoKomandos(playerid,NUM4,NUM41);
- ZaidejoKomandos(playerid,NUM6,NUM61);
- ZaidejoKomandos(playerid,Y,Y1);
- ZaidejoKomandos(playerid,N,N1);
- ZaidejoKomandos(playerid,H,H1);
- format(string,sizeof(string),"1. TAB = %s\n2. C = %s\n3. LMB = %s\n4. SPACE = %s\n5. ENTER = %s\n6. LSHIFT = %s\n7. NUM1 = %s\n",TAB1,C1,LMB1,SPACE1,ENTER1,LSHIFT1,NUM11);
- format(string1,sizeof(string1),"%s8. NUM8 = %s\n9. NUM2 = %s\n10. NUM4 = %s\n11. NUM6 = %s\n12. Y = %s\n13. N = %s\n14. H = %s",string, NUM81,NUM21,NUM41,NUM61,Y1,N1,H1);
- ShowPlayerDialog(playerid, GUI_KEY_LIST, DIALOG_STYLE_LIST, VERSION, string1, "Select", "Close");
- return 1;
- }
- return 0;
- }
- public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
- {
- if(dialogid == GUI_KEY_LIST)
- {
- if(response)
- {
- new VERSION1[128];
- pasirinko[playerid] = listitem;
- format(VERSION1,sizeof(VERSION1),"%s %s", VERSION,KeyName(playerid));
- ShowPlayerDialog(playerid, GUI_CMDS_LIST, DIALOG_STYLE_LIST, VERSION1, Commands1(), "Select", "Close");
- }
- return 1; // We handled a dialog, so return 1. Just like OnPlayerCommandText.
- }
- if(dialogid == GUI_CMDS_LIST)
- {
- if(response)
- {
- BindKey(playerid,pasirinko[playerid],listitem);
- pasirinko[playerid] = 0;
- SaveInfo(playerid);
- }
- return 1;
- }
- return 0; // You MUST return 0 here! Just like OnPlayerCommandText.
- }
- stock Zinute(playerid)
- {
- SendClientMessage(playerid,123456,"Labas");
- }
- stock GautiHP(playerid)
- {
- SetPlayerHealth(playerid,100.0);
- SendClientMessage(playerid,123456,"Gavote 100 HP");
- }
- stock GautiArmor(playerid)
- {
- SetPlayerArmour(playerid,100.0);
- SendClientMessage(playerid,123456,"Gavote 100 ARMOUR");
- }
- stock ZaidejoKomandos(playerid,key,key1[40])
- {
- switch(pKey[playerid][key])
- {
- case 0: key1 = "{FF0000} NEPASIRINKTA";
- case 1: key1 = "{04C731}Zinute";
- case 2: key1 = "{04C731}GautiHP";
- case 3: key1 = "{04C731}GautiArmor";
- }
- return key1;
- }
- stock BindKey(playerid,key,command)
- {
- pKey[playerid][key] = command;
- }
- stock KeyName(playerid)
- {
- new name[40];
- switch(pasirinko[playerid])
- {
- case 0: name = "TAB";
- case 1: name = "C";
- case 2: name = "LMB";
- case 3: name = "SPACE";
- case 4: name = "ENTER";
- case 5: name = "LSHIFT";
- case 6: name = "NUM1";
- case 7: name = "NUM8";
- case 8: name = "NUM2";
- case 9: name = "NUM4";
- case 10: name = "NUM6";
- case 11: name = "Y";
- case 12: name = "N";
- case 13: name = "H";
- }
- return name;
- }
- stock Commands1()
- {
- new txt[128];
- for(new i; i < sizeof (Commands);i++)
- {
- strcat(txt, Commands[i]);
- strcat(txt, "\n");
- }
- return txt;
- }
- public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
- {
- if (PRESSED(K_TAB))
- {
- CommandUse(playerid,TAB);
- }
- if (PRESSED(K_C))
- {
- CommandUse(playerid,C);
- }
- if (PRESSED(K_LMB))
- {
- CommandUse(playerid,LMB);
- }
- if (PRESSED(K_SPACE))
- {
- CommandUse(playerid,SPACE);
- }
- if (PRESSED(K_ENTER))
- {
- CommandUse(playerid,ENTER);
- }
- if (PRESSED(K_LSHIFT))
- {
- CommandUse(playerid,LSHIFT);
- }
- if (PRESSED(K_NUM1))
- {
- CommandUse(playerid,NUM1);
- }
- if (PRESSED(K_NUM8))
- {
- CommandUse(playerid,NUM8);
- }
- if (PRESSED(K_NUM2))
- {
- CommandUse(playerid,NUM2);
- }
- if (PRESSED(K_NUM4))
- {
- CommandUse(playerid,NUM6);
- }
- if (PRESSED(K_Y))
- {
- CommandUse(playerid,Y);
- }
- if (PRESSED(K_N))
- {
- CommandUse(playerid,N);
- }
- if (PRESSED(K_H))
- {
- CommandUse(playerid,H);
- }
- return 1;
- }
- stock CommandUse(playerid,key)
- {
- switch(pKey[playerid][key])
- {
- case 1: Zinute(playerid);
- case 2: GautiHP(playerid);
- case 3: GautiArmor(playerid);
- }
- }
- SaveInfo(playerid)
- {
- new string[128];
- format(string,sizeof(string),"Bind/%s.txt",pName(playerid));
- dini_IntSet(string,"TAB",pKey[playerid][TAB]);
- dini_IntSet(string,"C",pKey[playerid][C]);
- dini_IntSet(string,"LMB",pKey[playerid][LMB]);
- dini_IntSet(string,"SPACE",pKey[playerid][SPACE]);
- dini_IntSet(string,"ENTER",pKey[playerid][ENTER]);
- dini_IntSet(string,"LSHIFT",pKey[playerid][LSHIFT]);
- dini_IntSet(string,"NUM1",pKey[playerid][NUM1]);
- dini_IntSet(string,"NUM8",pKey[playerid][NUM8]);
- dini_IntSet(string,"NUM2",pKey[playerid][NUM2]);
- dini_IntSet(string,"NUM4",pKey[playerid][NUM4]);
- dini_IntSet(string,"NUM6",pKey[playerid][NUM6]);
- dini_IntSet(string,"Y",pKey[playerid][Y]);
- dini_IntSet(string,"N",pKey[playerid][N]);
- dini_IntSet(string,"H",pKey[playerid][H]);
- }
Advertisement
Add Comment
Please, Sign In to add comment