Advertisement
Guest User

bind.pwn

a guest
Aug 5th, 2016
164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 7.41 KB | None | 0 0
  1. #include <a_samp>
  2. #include <zcmd>
  3. #include <sscanf2>
  4. #include <dini>
  5. //mielőtt berakod a scriptet, vedd ki az összes bindet, pl num2 - jármű javítása stb...
  6. /*
  7. Created by:
  8. ###################################################################
  9. #                                                                 #
  10. #     /$$$$$$                                                     #
  11. #    |_  $$_/                                                     #
  12. #      | $$   /$$$$$$$   /$$$$$$$  /$$$$$$  /$$$$$$$   /$$$$$$    #
  13. #      | $$  | $$__  $$ /$$_____/ |____  $$| $$__  $$ /$$__  $$   #
  14. #      | $$  | $$  \ $$|  $$$$$$   /$$$$$$$| $$  \ $$| $$$$$$$$   #
  15. #      | $$  | $$  | $$ \____  $$ /$$__  $$| $$  | $$| $$_____/   #
  16. #     /$$$$$$| $$  | $$ /$$$$$$$/|  $$$$$$$| $$  | $$|  $$$$$$$   #
  17. #    |______/|__/  |__/|_______/  \_______/|__/  |__/ \_______/   #
  18. #                                                                 #
  19. ###################################################################
  20.  
  21.  
  22.  
  23.                  ,---,
  24.        ,---.  ,`--.' |
  25.       /__./| /    /  :
  26.  ,---.;  ; |:    |.' '
  27. /___/ \  | |`----':  |
  28. \   ;  \ ' |   '   ' ;
  29.  \   \  \: |   |   | |
  30.   ;   \  ' .   '   : ;
  31.    \   \   '   |   | '
  32.     \   `  ;   '   : |
  33.      :   \ |   ;   |.'
  34.       '---"    '---'
  35.  
  36. */
  37.  
  38. new bindfile[128];
  39. new hasznalomabindet[MAX_PLAYERS];
  40. public OnFilterScriptInit()
  41. {
  42.     for(new i =0; i < MAX_PLAYERS;i++)
  43.     {
  44.     if(IsPlayerConnected(i))
  45.         {
  46.             hasznalomabindet[i] = 0;
  47.             format(bindfile,sizeof(bindfile),"/binds/%s.txt",pname(i));
  48.             if(!fexist(bindfile))
  49.             {
  50.                 dini_Create(bindfile);
  51.                 dini_Set(bindfile,"keyn","empty");
  52.                 dini_Set(bindfile,"key2","empty");
  53.                 dini_Set(bindfile,"keynum8","empty");
  54.                 dini_Set(bindfile,"keynum6","empty");
  55.                 dini_Set(bindfile,"keynum4","empty");
  56.                 dini_Set(bindfile,"keynum2","empty");
  57.             }
  58.         }
  59.     }
  60.     print("***********KEY BIND BY INSANE***********");
  61.  
  62.     return 1;
  63. }
  64.  
  65. public OnFilterScriptExit()
  66. {
  67.     return 1;
  68. }
  69.  
  70. public OnPlayerConnect(playerid)
  71. {
  72.     hasznalomabindet[playerid] = 0;
  73.     format(bindfile,sizeof(bindfile),"/binds/%s.txt",pname(playerid));
  74.     if(!fexist(bindfile))
  75.     {
  76.         dini_Create(bindfile);
  77.         dini_Set(bindfile,"keyn","empty");
  78.         dini_Set(bindfile,"key2","empty");
  79.         dini_Set(bindfile,"keynum8","empty");
  80.         dini_Set(bindfile,"keynum6","empty");
  81.         dini_Set(bindfile,"keynum4","empty");
  82.         dini_Set(bindfile,"keynum2","empty");
  83.     }
  84.     return 1;
  85. }
  86.  
  87. public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
  88. {
  89.     if(hasznalomabindet[playerid] == 1)
  90.     {
  91.         format(bindfile,sizeof(bindfile),"/binds/%s.txt",pname(playerid));
  92.         if(fexist(bindfile))
  93.         {
  94.             if(newkeys & KEY_SUBMISSION) //2
  95.             {
  96.                 if(strfind(dini_Get(bindfile,"key2"),"empty",true) != -1) return SendClientMessage(playerid,-1,"{FF0000}Erre a billentyűre nincs rakva bind! /bind");
  97.                 // ha üres stringet kap a CallRemoteFunction, crashel a szerver!
  98.                 CallRemoteFunction("OnPlayerCommandText","is",playerid,dini_Get(bindfile,"key2"));
  99.             }
  100.             if(newkeys & KEY_NO) //n
  101.             {
  102.                 if(strfind(dini_Get(bindfile,"keyn"),"empty",true) != -1) return SendClientMessage(playerid,-1,"{FF0000}Erre a billentyűre nincs rakva bind! /bind");
  103.                 CallRemoteFunction("OnPlayerCommandText","is",playerid,dini_Get(bindfile,"keyn"));
  104.             }
  105.             if(newkeys & KEY_ANALOG_UP) // num8
  106.             {
  107.                 if(strfind(dini_Get(bindfile,"keynum8"),"empty",true) != -1) return SendClientMessage(playerid,-1,"{FF0000}Erre a billentyűre nincs rakva bind! /bind");
  108.                 CallRemoteFunction("OnPlayerCommandText","is",playerid,dini_Get(bindfile,"keynum8"));
  109.             }
  110.             if(newkeys & KEY_ANALOG_DOWN) // num2
  111.             {
  112.                 if(strfind(dini_Get(bindfile,"keynum2"),"empty",true) != -1) return SendClientMessage(playerid,-1,"{FF0000}Erre a billentyűre nincs rakva bind! /bind");
  113.                 CallRemoteFunction("OnPlayerCommandText","is",playerid,dini_Get(bindfile,"keynum2"));
  114.             }
  115.             if(newkeys & KEY_ANALOG_LEFT) // num4
  116.             {
  117.                 if(strfind(dini_Get(bindfile,"keynum4"),"empty",true) != -1) return SendClientMessage(playerid,-1,"{FF0000}Erre a billentyűre nincs rakva bind! /bind");
  118.                 CallRemoteFunction("OnPlayerCommandText","is",playerid,dini_Get(bindfile,"keynum4"));
  119.             }
  120.             if(newkeys & KEY_ANALOG_RIGHT) // num6
  121.             {
  122.                 if(strfind(dini_Get(bindfile,"keynum6"),"empty",true) != -1) return SendClientMessage(playerid,-1,"{FF0000}Erre a billentyűre nincs rakva bind! /bind");
  123.                 CallRemoteFunction("OnPlayerCommandText","is",playerid,dini_Get(bindfile,"keynum6"));
  124.             }
  125.         }
  126.     }
  127.     return 1;
  128. }
  129.  
  130. CMD:bind(playerid,params[])
  131. {
  132.     if(hasznalomabindet[playerid] == 0) return  SendClientMessage(playerid,-1,"{00FF00}A bindelés neked ki van kapcsolva! bekapcsoláshoz /bindon");
  133.     new billentyu[6],bindeles[64];
  134.     format(bindfile,sizeof(bindfile),"/binds/%s.txt",pname(playerid));
  135.     if(!fexist(bindfile)) dini_Create(bindfile);
  136.     if(sscanf(params,"s[6]s[64]",billentyu,bindeles))
  137.     {
  138.         SendClientMessage(playerid,-1,"{FF0000}Használat: /bind billentyűzet /parancs");
  139.         SendClientMessage(playerid,-1,"{FF0000}Használható billentyűk: subm, keyno, num2,num4,num6,num8");
  140.     }else
  141.     if(strfind(billentyu,"keyno",true) != -1)
  142.     {
  143.         dini_Set(bindfile,"keyn",bindeles);
  144.         SendClientMessage(playerid,-1,"{00FF00}Bind beállítva, használathoz \"N\" billentyű!");
  145.     }
  146.     else
  147.     if(strfind(billentyu,"subm",true) != -1)
  148.     {
  149.         dini_Set(bindfile,"key2",bindeles);
  150.         SendClientMessage(playerid,-1,"{00FF00}Bind beállítva, használathoz (gyalog num1 vagy görgő) kocsiban \"2 vagy +\" billentyű!");
  151.     }
  152.     else
  153.     if(strfind(billentyu,"num2",true) != -1)
  154.     {
  155.         dini_Set(bindfile,"keynum2",bindeles);
  156.         SendClientMessage(playerid,-1,"{00FF00}Bind beállítva, használathoz \"num2\" billentyű!");
  157.         SendClientMessage(playerid,-1,"{00FF00}Ezt csak kocsiban tudod használni!");
  158.     }
  159.     else
  160.     if(strfind(billentyu,"num4",true) != -1)
  161.     {
  162.         dini_Set(bindfile,"keynum4",bindeles);
  163.         SendClientMessage(playerid,-1,"{00FF00}Bind beállítva, használathoz \"num4\" billentyű!");
  164.     }
  165.     else
  166.     if(strfind(billentyu,"num6",true) != -1)
  167.     {
  168.         dini_Set(bindfile,"keynum6",bindeles);
  169.         SendClientMessage(playerid,-1,"{00FF00}Bind beállítva, használathoz \"num6\" billentyű!");
  170.     }
  171.     else
  172.     if(strfind(billentyu,"num8",true) != -1)
  173.     {
  174.         dini_Set(bindfile,"keynum8",bindeles);
  175.         SendClientMessage(playerid,-1,"{00FF00}Bind beállítva, használathoz \"num8\" billentyű!");
  176.         SendClientMessage(playerid,-1,"{00FF00}Ezt csak kocsiban tudod használni!");
  177.     }
  178.     else
  179.     {
  180.         SendClientMessage(playerid,-1,"{FF0000}Használható billentyűk: subm, keyno, num2,num4,num6,num8");
  181.     }
  182.     return 1;
  183. }
  184. CMD:unbindall(playerid)
  185. {
  186.     format(bindfile,sizeof(bindfile),"/binds/%s.txt",pname(playerid));
  187.     dini_Remove(bindfile);
  188.     dini_Create(bindfile);
  189.     dini_Set(bindfile,"keyn","empty");
  190.     dini_Set(bindfile,"key2","empty");
  191.     dini_Set(bindfile,"keynum8","empty");
  192.     dini_Set(bindfile,"keynum6","empty");
  193.     dini_Set(bindfile,"keynum4","empty");
  194.     dini_Set(bindfile,"keynum2","empty");
  195.     SendClientMessage(playerid,-1,"{00FF00}Összes bind törölve!");
  196.     return 1;
  197. }
  198. CMD:bindon(playerid)
  199. {
  200.     hasznalomabindet[playerid] = 1;
  201.     SendClientMessage(playerid,-1,"{00FF00}Bind használat bekapcsolva! /bind");
  202.     return 1;
  203. }
  204. CMD:bindoff(playerid)
  205. {
  206.     hasznalomabindet[playerid] = 0;
  207.     SendClientMessage(playerid,-1,"{00FF00}Bind használat kikapcsolva!");
  208.     return 1;
  209. }
  210. stock pname(playerid)
  211. {
  212.     new tmp[MAX_PLAYER_NAME];
  213.     GetPlayerName(playerid,tmp,sizeof(tmp));
  214.     return tmp;
  215. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement