Advertisement
Guest User

Untitled

a guest
May 22nd, 2015
231
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.36 KB | None | 0 0
  1. #include <amxmodx>
  2. #include <amxmisc>
  3. #include <fakemeta>
  4.  
  5. #define PLUGIN "Czapki"
  6. #define VERSION "1.0"
  7. #define AUTHOR "Cypis"
  8.  
  9. new gEnt[33];
  10. new Array:gModel;
  11. new Array:gNazwa;
  12. new Array:gBody;
  13.  
  14. public plugin_init()
  15. {
  16. register_plugin(PLUGIN, VERSION, AUTHOR);
  17.  
  18. register_clcmd("say /hat", "MenuHat");
  19. register_clcmd("say /hats", "MenuHat");
  20. register_clcmd("say /czapki", "MenuHat");
  21. }
  22.  
  23. public plugin_precache()
  24. {
  25. gModel = ArrayCreate(128);
  26. gNazwa = ArrayCreate(64);
  27. gBody = ArrayCreate();
  28.  
  29. ArrayPushString(gModel, "Zadna");
  30. ArrayPushString(gNazwa, "\yZdejmij czapke");
  31. ArrayPushCell(gBody, 0);
  32.  
  33. new configfile[128];
  34. get_configsdir(configfile, 127);
  35. add(configfile, 127, "/hats.ini");
  36.  
  37. if(!file_exists(configfile))
  38. return;
  39.  
  40. new linia[256], txtlen, ilosc;
  41. for(new i=0; i<file_size(configfile, 1); i++)
  42. {
  43. read_file(configfile, i, linia, 255, txtlen);
  44. if(contain(linia, ";") != -1 || !txtlen)
  45. continue;
  46.  
  47. new model[128], nazwa[64], body[6];
  48. parse(linia, model, 127, nazwa, 63, body, 5);
  49. remove_quotes(model);
  50. remove_quotes(nazwa);
  51. remove_quotes(body);
  52. format(model, 127, "models/hat/%s", model);
  53.  
  54. ArrayPushString(gModel, model);
  55. ArrayPushString(gNazwa, nazwa);
  56. ArrayPushCell(gBody, str_to_num(body));
  57.  
  58. new gmodel[64];
  59. if(ilosc)
  60. {
  61. for(new j=1; j<ArraySize(gBody)-1; j++)
  62. {
  63. ArrayGetString(gModel, j, gmodel, 63);
  64. if(equal(model, gmodel))
  65. {
  66. gmodel[0] = 1;
  67. break;
  68. }
  69. else
  70. gmodel[0] = 0;
  71. }
  72. }
  73. if(!gmodel[0])
  74. {
  75. precache_model(model);
  76. log_amx("Precache %s", model);
  77. }
  78. else
  79. log_amx("Precache %s %s %s", model, nazwa, body);
  80.  
  81. ilosc++;
  82. }
  83. }
  84.  
  85. public MenuHat(id)
  86. {
  87. new nazwa[64], int[4], menu = menu_create("Czapki:", "Handel_Czapki");
  88.  
  89. for(new i=0; i<ArraySize(gBody); i++)
  90. {
  91. num_to_str(i, int, 3);
  92. ArrayGetString(gNazwa, i, nazwa, 63);
  93. menu_additem(menu, nazwa, int);
  94. }
  95.  
  96. menu_setprop(menu, MPROP_EXITNAME, "Wyjdz");
  97. menu_display(id, menu);
  98. return PLUGIN_HANDLED;
  99. }
  100.  
  101. public Handel_Czapki(id, menu, item)
  102. {
  103. if(item == MENU_EXIT)
  104. return;
  105.  
  106. new acces, callback, num[4], nazwa[64];
  107. menu_item_getinfo(menu, item, acces, num, 3, nazwa, 63, callback);
  108.  
  109. UstawCzapke(id, str_to_num(num));
  110. item? client_print(id, 3, "Zalozyles czapke %s", nazwa): client_print(id, 3, "Zdjales swoja czapke");
  111. }
  112.  
  113. stock UstawCzapke(id, anum)
  114. {
  115. if(gEnt[id])
  116. set_pev(gEnt[id], pev_effects, anum? pev(gEnt[id], pev_effects) & ~EF_NODRAW: pev(gEnt[id], pev_effects) | EF_NODRAW);
  117.  
  118. if(!anum)
  119. return;
  120.  
  121. new model[128];
  122. ArrayGetString(gModel, anum, model, 127);
  123.  
  124. if(!gEnt[id])
  125. {
  126. gEnt[id] = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "info_target"))
  127. set_pev(gEnt[id], pev_movetype, MOVETYPE_FOLLOW);
  128. set_pev(gEnt[id], pev_aiment, id);
  129. set_pev(gEnt[id], pev_rendermode, kRenderNormal);
  130. }
  131.  
  132. engfunc(EngFunc_SetModel, gEnt[id], model);
  133. set_pev(gEnt[id], pev_body, ArrayGetCell(gBody, anum));
  134. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement