Advertisement
Guest User

poftim

a guest
Jun 17th, 2018
199
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.46 KB | None | 0 0
  1. //O sa definim numarul armelor totale
  2.  
  3. #define ORDER_WEAPONS 3
  4.  
  5. //adaugam in enum (sau define, depinde cum lucrati) un dialog
  6.  
  7. DIALOG_ORDER
  8.  
  9. //Adaugam armele dorite de noi intr-un array
  10.  
  11. new orderWeapons[ORDER_WEAPONS] = {
  12. WEAPON_DEAGLE, WEAPON_M4, WEAPON_RIFLE
  13. };
  14.  
  15. //La enum-ul vostru adaugati urmatoarea variabila, ca mai jos
  16.  
  17. pOrderWeapons[ORDER_WEAPONS];
  18.  
  19. //Veti adauga field-ul OrderWeapons in vaza de date, ca variabila de tip varchar
  20.  
  21. //La logarea jucatorului pe server, vom lua armele din baza de date
  22.  
  23. new string[64];
  24. cache_get_field_content(0, "OrderWeapons", string);
  25. sscanf(string, "p<|>iii", PlayerInfo[playerid][pOrderWeapons][0],
  26. PlayerInfo[playerid][pOrderWeapons][1], PlayerInfo[playerid][pOrderWeapons][2]);
  27.  
  28. //Cateva functii de care ne vom folosi
  29.  
  30. stock getOrderWeapons(playerid) {
  31. new count = 0;
  32.  
  33. for(new i = 0; i < ORDER_WEAPONS; i++) {
  34. if(!PlayerInfo[playerid][pOrderWeapons][i]) {
  35. count ++;
  36. }
  37. }
  38.  
  39. return count;
  40. }
  41.  
  42. stock orderWeaponsUpdate(playerid) {
  43. new string[64], query[128];
  44.  
  45. for(new i = 0; i < ORDER_WEAPONS; i++) {
  46. if(i == ORDER_WEAPONS - 1) format(string, sizeof string, "%s%d", string, PlayerInfo[playerid][pOrderWeapons][i]);
  47. else format(string, sizeof string, "%s%d|", string, PlayerInfo[playerid][pOrderWeapons][i]);
  48. }
  49.  
  50. mysql_format(SQL, query, sizeof query, "UPDATE `users` SET `OrderWeapons` = '%s' WHERE `id` = '%d'", string, PlayerInfo[playerid][pSQLID]);
  51. mysql_tquery(SQL, query, "", "");
  52. return 1;
  53. }
  54.  
  55. //Comenzile propriu-zise:
  56.  
  57. CMD:order(playerid, params[], help) {
  58. if(!getOrderWeapons(playerid)) return SCM(playerid, -1, "Nu ai nici o arma setata [/setguns].");
  59.  
  60. new count = 0;
  61.  
  62. for(new i = 0; i < ORDER_WEAPONS; i++) {
  63. if(!PlayerInfo[playerid][pOrderWeapons][i]) {
  64. GivePlayerWeapon(playerid, orderWeapons[i], 100);
  65. count ++;
  66. }
  67. }
  68.  
  69. new string[128];
  70. format(string, sizeof string, "(Order): {ffffff}Ai luat %d %s din seif.", count, (count == 1) ? ("arma") : ("arme"));
  71. SCM(playerid, 0x009999FF, string);
  72. return 1;
  73. }
  74.  
  75. CMD:setguns(playerid, params[], help) {
  76. new string[128], weaponName[30];
  77. format(string, sizeof string, "Arma\tStatus\n");
  78.  
  79. for(new i = 0; i < ORDER_WEAPONS; i++) {
  80. GetWeaponName(orderWeapons[i], weaponName, 30);
  81. format(string, sizeof string, "%s%s\t%s\n", string, weaponName, (!PlayerInfo[playerid][pOrderWeapons][i]) ? ("{d90909}neutilizat") : ("{27c42a}utilizat"));
  82. }
  83.  
  84. ShowPlayerDialog(playerid, DIALOG_ORDER, DIALOG_STYLE_TABLIST_HEADERS, "Order:", string, "Select", "Exit");
  85. return 1;
  86. }
  87.  
  88. //Dialogul
  89.  
  90. if(dialogid == DIALOG_ORDER)
  91. {
  92. if(!response) return 1;
  93.  
  94. PlayerInfo[playerid][pOrderWeapons][listitem] = (!PlayerInfo[playerid][pOrderWeapons][listitem]) ? (1) : (0);
  95. orderWeaponsUpdate(playerid);
  96.  
  97. // in cazul in care folositi YCMD, veti folosi:
  98. Command_ReProcess(playerid, "setguns", false);
  99.  
  100. // in cazul in care folositi oricare alt procesor de comenzi, cum ar fii zcmd, veti folosi:
  101. cmd_setguns(playerid);
  102.  
  103. new string[128], weaponName[30];
  104. GetWeaponName(orderWeapons[listitem], weaponName, 30);
  105. format(string, sizeof string, "(Order): {ffffff}Arma %s: %s{ffffff}.", weaponName, (!PlayerInfo[playerid][pOrderWeapons][i]) ? ("{d90909}neutilizat") : ("{27c42a}utilizat"));
  106. SCM(playerid, 0x009999FF, string);
  107. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement