HLMOD.HU Forrás Megtekintés - www.hlmod.hu
  1. #include <amxmodx>
  2. #include <amxmisc>
  3. #include <fakemeta>
  4. #include <xs>
  5. #include <fun>
  6. #include <zombieplague.inc>
  7.  
  8. // The sizes of models
  9. #define PALLET_MINS Float:{ -27.260000, -22.280001, -22.290001 }
  10. #define PALLET_MAXS Float:{ 27.340000, 26.629999, 29.020000 }
  11.  
  12.  
  13. // from fakemeta util by VEN
  14. #define fm_find_ent_by_class(%1,%2) engfunc(EngFunc_FindEntityByString, %1, "classname", %2)
  15. #define fm_remove_entity(%1) engfunc(EngFunc_RemoveEntity, %1)
  16. // this is mine
  17. #define fm_drop_to_floor(%1) engfunc(EngFunc_DropToFloor,%1)
  18.  
  19. // cvars
  20. new pnumplugin, remove_nrnd, maxpallets, phealth;
  21.  
  22. // num of pallets with bags
  23. new palletscout = 0;
  24.  
  25. /* Models for pallets with bags .
  26.   Are available 2 models, will be set a random of them */
  27. new g_models[][] =
  28. {
  29. "models/pallet_with_bags2.mdl",
  30. "models/pallet_with_bags.mdl"
  31. }
  32.  
  33. new stuck[33]
  34. new g_bolsas[33];
  35. new cvar[3]
  36.  
  37. new const Float:size[][3] = {
  38. {0.0, 0.0, 1.0}, {0.0, 0.0, -1.0}, {0.0, 1.0, 0.0}, {0.0, -1.0, 0.0}, {1.0, 0.0, 0.0}, {-1.0, 0.0, 0.0}, {-1.0, 1.0, 1.0}, {1.0, 1.0, 1.0}, {1.0, -1.0, 1.0}, {1.0, 1.0, -1.0}, {-1.0, -1.0, 1.0}, {1.0, -1.0, -1.0}, {-1.0, 1.0, -1.0}, {-1.0, -1.0, -1.0},
  39. {0.0, 0.0, 2.0}, {0.0, 0.0, -2.0}, {0.0, 2.0, 0.0}, {0.0, -2.0, 0.0}, {2.0, 0.0, 0.0}, {-2.0, 0.0, 0.0}, {-2.0, 2.0, 2.0}, {2.0, 2.0, 2.0}, {2.0, -2.0, 2.0}, {2.0, 2.0, -2.0}, {-2.0, -2.0, 2.0}, {2.0, -2.0, -2.0}, {-2.0, 2.0, -2.0}, {-2.0, -2.0, -2.0},
  40. {0.0, 0.0, 3.0}, {0.0, 0.0, -3.0}, {0.0, 3.0, 0.0}, {0.0, -3.0, 0.0}, {3.0, 0.0, 0.0}, {-3.0, 0.0, 0.0}, {-3.0, 3.0, 3.0}, {3.0, 3.0, 3.0}, {3.0, -3.0, 3.0}, {3.0, 3.0, -3.0}, {-3.0, -3.0, 3.0}, {3.0, -3.0, -3.0}, {-3.0, 3.0, -3.0}, {-3.0, -3.0, -3.0},
  41. {0.0, 0.0, 4.0}, {0.0, 0.0, -4.0}, {0.0, 4.0, 0.0}, {0.0, -4.0, 0.0}, {4.0, 0.0, 0.0}, {-4.0, 0.0, 0.0}, {-4.0, 4.0, 4.0}, {4.0, 4.0, 4.0}, {4.0, -4.0, 4.0}, {4.0, 4.0, -4.0}, {-4.0, -4.0, 4.0}, {4.0, -4.0, -4.0}, {-4.0, 4.0, -4.0}, {-4.0, -4.0, -4.0},
  42. {0.0, 0.0, 5.0}, {0.0, 0.0, -5.0}, {0.0, 5.0, 0.0}, {0.0, -5.0, 0.0}, {5.0, 0.0, 0.0}, {-5.0, 0.0, 0.0}, {-5.0, 5.0, 5.0}, {5.0, 5.0, 5.0}, {5.0, -5.0, 5.0}, {5.0, 5.0, -5.0}, {-5.0, -5.0, 5.0}, {5.0, -5.0, -5.0}, {-5.0, 5.0, -5.0}, {-5.0, -5.0, -5.0}
  43. }
  44.  
  45. new const g_item_name[] = { "15 db. Homokzsak" }
  46. const g_item_bolsas = 0
  47. new g_itemid_bolsas
  48. new ZPSTUCK, g_BINDMODE, g_MSGMODE
  49.  
  50. /*************************************************************
  51. ************************* AMXX PLUGIN *************************
  52. **************************************************************/
  53.  
  54.  
  55. public plugin_init()
  56. {
  57. register_plugin("[ZP] Extra: SandBags", "1.1", "LARP")
  58. set_task(0.1,"checkstuck",0,"",0,"b")
  59. g_itemid_bolsas = zp_register_extra_item(g_item_name, g_item_bolsas, ZP_TEAM_HUMAN)
  60. /* Register the cvars */
  61. g_BINDMODE = register_cvar("zp_pb_bind","0"); //Auto bind L Key!
  62. g_MSGMODE = register_cvar("zp_pb_msg","1"); //
  63. ZPSTUCK = register_cvar("zp_pb_stuck","1")
  64. pnumplugin = register_cvar("zp_pb_enable","1"); // 1 = ON ; 0 = OFF
  65. remove_nrnd = register_cvar("zp_pb_remround","1");
  66. maxpallets = register_cvar("zp_pb_limit","200"); // max number of pallets with bags
  67. phealth = register_cvar("zp_pb_health","200"); // set the health to a pallet with bags
  68.  
  69. /* Game Events */
  70. register_event("HLTV","event_newround", "a","1=0", "2=0"); // it's called every on new round
  71.  
  72. /* This is for menuz: */
  73. register_menucmd(register_menuid("\yHomok Zsakok:"), 1023, "menu_command" );
  74. register_clcmd("say /pb","show_the_menu");
  75. register_clcmd("/pb","show_the_menu");
  76. //cvar[0] = register_cvar("zp_autounstuck","1")
  77. cvar[1] = register_cvar("zp_pb_stuckeffects","1")
  78. cvar[2] = register_cvar("zp_pb_stuckwait","7")
  79.  
  80. }
  81.  
  82.  
  83. public plugin_precache()
  84. {
  85. for(new i;i < sizeof g_models;i++)
  86. engfunc(EngFunc_PrecacheModel,g_models[i]);
  87. }
  88.  
  89. public show_the_menu(id,level,cid)
  90. {
  91. // check if user doesen't have admin
  92. /*if( ! cmd_access( id,level, cid , 0 ))
  93. return PLUGIN_HANDLED;
  94. */
  95.  
  96. // check if the plugin cvar is turned off
  97. if( ! get_pcvar_num( pnumplugin ) )
  98. return PLUGIN_HANDLED;
  99.  
  100.  
  101. // check if user isn't alive
  102. if( ! is_user_alive( id ) )
  103. {
  104. client_print( id, print_chat, "" ); //msg muerto
  105. return PLUGIN_HANDLED;
  106. }
  107.  
  108. if ( !zp_get_user_zombie(id) )
  109. {
  110. new szMenuBody[256];
  111. new keys;
  112.  
  113. new nLen = format( szMenuBody, 255, "\yHomok Zsakok:^n" );
  114. nLen += format( szMenuBody[nLen], 255-nLen, "^n\w1. Homokzsak elhelyezese (%i Maradt)", g_bolsas[id] );
  115. //nLen += format( szMenuBody[nLen], 255-nLen, "^n\w2. Remove a pallet with bags" );
  116. nLen += format( szMenuBody[nLen], 255-nLen, "^n^n\w0. Kilepes" );
  117.  
  118. keys = (1<<0|1<<1|1<<2|1<<3|1<<4|1<<5|1<<6|1<<9)
  119.  
  120. show_menu( id, keys, szMenuBody, -1 );
  121.  
  122. // depends what you want, if is continue will appear on chat what the admin sayd
  123. return PLUGIN_HANDLED;
  124. }
  125. client_print(id, print_chat, "[ZP] A zombik nem hasznalhatjak ezt a parancsot!")
  126. return PLUGIN_HANDLED;
  127. }
  128.  
  129.  
  130. public menu_command(id,key,level,cid)
  131. {
  132.  
  133. switch( key )
  134. {
  135. // place a pallet with bags
  136. case 0:
  137. {
  138. if ( !zp_get_user_zombie(id) )
  139. {
  140. new money = g_bolsas[id]
  141. if ( money < 1 )
  142. {
  143. if ( get_pcvar_num(g_MSGMODE) == 1 )
  144. {
  145. set_hudmessage(0, 0, 100, 0.80, 0.80, 0, 6.0, 2.0, 1.0, 1.0)
  146. show_hudmessage(id, "Nincs homokzsakod")
  147. return PLUGIN_CONTINUE
  148. }
  149. client_print(id, print_chat, "[ZP] Nincs homokzsakod!")
  150. return PLUGIN_CONTINUE
  151. }
  152. g_bolsas[id]-= 1
  153. place_palletwbags(id);
  154. show_the_menu(id,level,cid);
  155. return PLUGIN_CONTINUE
  156. }
  157. client_print(id, print_chat, "[ZP] A zombik nem hasznalhatjak ezt!!")
  158. return PLUGIN_CONTINUE
  159. }
  160.  
  161. // remove a pallet with bags
  162. /*case 1:
  163. {
  164. if ( !zp_get_user_zombie(id) )
  165. {
  166. new ent, body, class[32];
  167. get_user_aiming(id, ent, body);
  168. if (pev_valid(ent))
  169. {
  170. pev(ent, pev_classname, class, 31);
  171.  
  172. if (equal(class, "amxx_pallets"))
  173. {
  174. g_bolsas[id]+= 1
  175. fm_remove_entity(ent);
  176. }
  177.  
  178. else
  179. client_print(id, print_chat, "[ZP] You are not aiming at a pallet with bags");
  180. }
  181. else
  182. client_print(id, print_chat, "[ZP] You are not aiming at a valid entity !");
  183.  
  184. show_the_menu(id,level,cid);
  185. }
  186. }
  187. */
  188.  
  189. // remove all pallets with bags
  190. /*case 2:
  191. {
  192. g_bolsas[id]= 0
  193. remove_allpalletswbags();
  194. client_print(id,print_chat,"[AMXX] You removed all pallets with bags !");
  195. show_the_menu(id,level,cid);
  196. }
  197. */
  198.  
  199. }
  200.  
  201. return PLUGIN_HANDLED;
  202. }
  203.  
  204.  
  205.  
  206. public place_palletwbags(id)
  207. {
  208.  
  209. if( palletscout == get_pcvar_num(maxpallets) )
  210. {
  211. client_print(id,print_chat,"[ZP] A szabalyok szerint csak %d homokzsakot hasznalhatsz a szerveren!",get_pcvar_num(maxpallets));
  212. return PLUGIN_HANDLED;
  213. }
  214.  
  215. // create a new entity
  216. new ent = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "func_wall"));
  217.  
  218.  
  219. // set a name to the entity
  220. set_pev(ent,pev_classname,"amxx_pallets");
  221.  
  222. // set model
  223. engfunc(EngFunc_SetModel,ent,g_models[random(sizeof g_models)]);
  224.  
  225. // register a new var. for origin
  226. static Float:xorigin[3];
  227. get_user_hitpoint(id,xorigin);
  228.  
  229.  
  230. // check if user is aiming at the air
  231. if(engfunc(EngFunc_PointContents,xorigin) == CONTENTS_SKY)
  232. {
  233. client_print(id,print_chat,"[ZP] Az egre nem tudsz elhelyezni homokzsakot!");
  234. return PLUGIN_HANDLED;
  235. }
  236.  
  237.  
  238. // set sizes
  239. static Float:p_mins[3], Float:p_maxs[3];
  240. p_mins = PALLET_MINS;
  241. p_maxs = PALLET_MAXS;
  242. engfunc(EngFunc_SetSize, ent, p_mins, p_maxs);
  243. set_pev(ent, pev_mins, p_mins);
  244. set_pev(ent, pev_maxs, p_maxs );
  245. set_pev(ent, pev_absmin, p_mins);
  246. set_pev(ent, pev_absmax, p_maxs );
  247.  
  248.  
  249. // set the rock of origin where is user placed
  250. engfunc(EngFunc_SetOrigin, ent, xorigin);
  251.  
  252.  
  253. // make the rock solid
  254. set_pev(ent,pev_solid,SOLID_BBOX); // touch on edge, block
  255.  
  256. // set the movetype
  257. set_pev(ent,pev_movetype,MOVETYPE_FLY); // no gravity, but still collides with stuff
  258.  
  259. // now the damage stuff, to set to take it or no
  260. // if you set the cvar "pallets_wbags_health" 0, you can't destroy a pallet with bags
  261. // else, if you want to make it destroyable, just set the health > 0 and will be
  262. // destroyable.
  263. new Float:p_cvar_health = get_pcvar_float(phealth);
  264. switch(p_cvar_health)
  265. {
  266. case 0.0 :
  267. {
  268. set_pev(ent,pev_takedamage,DAMAGE_NO);
  269. }
  270.  
  271. default :
  272. {
  273. set_pev(ent,pev_health,p_cvar_health);
  274. set_pev(ent,pev_takedamage,DAMAGE_YES);
  275. }
  276. }
  277.  
  278.  
  279. static Float:rvec[3];
  280. pev(id,pev_v_angle,rvec);
  281.  
  282. rvec[0] = 0.0;
  283.  
  284. set_pev(ent,pev_angles,rvec);
  285.  
  286. // drop entity to floor
  287. fm_drop_to_floor(ent);
  288.  
  289. // num ..
  290. palletscout++;
  291.  
  292. // confirm message
  293. if ( get_pcvar_num(g_MSGMODE) == 1 )
  294. {
  295. set_hudmessage(0, 0, 100, 0.80, 0.80, 0, 6.0, 2.0, 1.0, 1.0)
  296. show_hudmessage(id, "Elhelyeztel egy homokzsakot^n%i Maradt", g_bolsas[id])
  297. return PLUGIN_HANDLED
  298. }
  299. client_print(id, print_chat, "[ZP] Elhelyeztel egy homokzsakot.")
  300. return PLUGIN_HANDLED;
  301. }
  302.  
  303. /* ====================================================
  304. get_user_hitpoin stock . Was maked by P34nut, and is
  305. like get_user_aiming but is with floats and better :o
  306. ====================================================*/
  307. stock get_user_hitpoint(id, Float:hOrigin[3])
  308. {
  309. if ( ! is_user_alive( id ))
  310. return 0;
  311.  
  312. new Float:fOrigin[3], Float:fvAngle[3], Float:fvOffset[3], Float:fvOrigin[3], Float:feOrigin[3];
  313. new Float:fTemp[3];
  314.  
  315. pev(id, pev_origin, fOrigin);
  316. pev(id, pev_v_angle, fvAngle);
  317. pev(id, pev_view_ofs, fvOffset);
  318.  
  319. xs_vec_add(fOrigin, fvOffset, fvOrigin);
  320.  
  321. engfunc(EngFunc_AngleVectors, fvAngle, feOrigin, fTemp, fTemp);
  322.  
  323. xs_vec_mul_scalar(feOrigin, 9999.9, feOrigin);
  324. xs_vec_add(fvOrigin, feOrigin, feOrigin);
  325.  
  326. engfunc(EngFunc_TraceLine, fvOrigin, feOrigin, 0, id);
  327. global_get(glb_trace_endpos, hOrigin);
  328.  
  329. return 1;
  330. }
  331.  
  332.  
  333. /* ====================================================
  334. This is called on every round, at start up,
  335. with HLTV logevent. So if the "pallets_wbags_nroundrem"
  336. cvar is set to 1, all placed pallets with bugs will be
  337. removed.
  338. ====================================================*/
  339. public event_newround()
  340. {
  341. if( get_pcvar_num ( remove_nrnd ) == 1)
  342. remove_allpalletswbags();
  343.  
  344. }
  345.  
  346.  
  347. /* ====================================================
  348. This is a stock to help for remove all pallets with
  349. bags placed . Is called on new round if the cvar
  350. "pallets_wbags_nroundrem" is set 1.
  351. ====================================================*/
  352. stock remove_allpalletswbags()
  353. {
  354. new pallets = -1;
  355. while((pallets = fm_find_ent_by_class(pallets, "amxx_pallets")))
  356. fm_remove_entity(pallets);
  357.  
  358. palletscout = 0;
  359. }
  360.  
  361. public checkstuck() {
  362. if ( get_pcvar_num(ZPSTUCK) == 1 )
  363. {
  364. static players[32], pnum, player
  365. get_players(players, pnum)
  366. static Float:origin[3]
  367. static Float:mins[3], hull
  368. static Float:vec[3]
  369. static o,i
  370. for(i=0; i<pnum; i++){
  371. player = players[i]
  372. if (is_user_connected(player) && is_user_alive(player)) {
  373. pev(player, pev_origin, origin)
  374. hull = pev(player, pev_flags) & FL_DUCKING ? HULL_HEAD : HULL_HUMAN
  375. if (!is_hull_vacant(origin, hull,player) && !get_user_noclip(player) && !(pev(player,pev_solid) & SOLID_NOT)) {
  376. ++stuck[player]
  377. if(stuck[player] >= get_pcvar_num(cvar[2])) {
  378. pev(player, pev_mins, mins)
  379. vec[2] = origin[2]
  380. for (o=0; o < sizeof size; ++o) {
  381. vec[0] = origin[0] - mins[0] * size[o][0]
  382. vec[1] = origin[1] - mins[1] * size[o][1]
  383. vec[2] = origin[2] - mins[2] * size[o][2]
  384. if (is_hull_vacant(vec, hull,player)) {
  385. engfunc(EngFunc_SetOrigin, player, vec)
  386. effects(player)
  387. set_pev(player,pev_velocity,{0.0,0.0,0.0})
  388. o = sizeof size
  389. }
  390. }
  391. }
  392. }
  393. else
  394. {
  395. stuck[player] = 0
  396. }
  397. }
  398. }
  399.  
  400. }
  401.  
  402. }
  403.  
  404. stock bool:is_hull_vacant(const Float:origin[3], hull,id) {
  405. static tr
  406. engfunc(EngFunc_TraceHull, origin, origin, 0, hull, id, tr)
  407. if (!get_tr2(tr, TR_StartSolid) || !get_tr2(tr, TR_AllSolid)) //get_tr2(tr, TR_InOpen))
  408. return true
  409.  
  410. return false
  411. }
  412.  
  413. public effects(id) {
  414. if(get_pcvar_num(cvar[1])) {
  415. set_hudmessage(255,150,50, -1.0, 0.65, 0, 6.0, 1.5,0.1,0.7) // HUDMESSAGE
  416. show_hudmessage(id,"Automatikus Kiszabaditas!") // HUDMESSAGE
  417. message_begin(MSG_ONE_UNRELIABLE,105,{0,0,0},id )
  418. write_short(1<<10) // fade lasts this long duration
  419. write_short(1<<10) // fade lasts this long hold time
  420. write_short(1<<1) // fade type (in / out)
  421. write_byte(20) // fade red
  422. write_byte(255) // fade green
  423. write_byte(255) // fade blue
  424. write_byte(255) // fade alpha
  425. message_end()
  426. client_cmd(id,"spk fvox/blip.wav")
  427. }
  428. }
  429.  
  430. public zp_extra_item_selected(player, itemid)
  431. {
  432. if (itemid == g_itemid_bolsas)
  433. {
  434. g_bolsas[player]+= 15
  435. cmd_bind(player)
  436. set_task(0.3,"show_the_menu",player)
  437. if ( get_pcvar_num(g_MSGMODE) == 1 )
  438. {
  439. set_hudmessage(0, 0, 100, 0.80, 0.80, 0, 6.0, 2.0, 1.0, 1.0)
  440. show_hudmessage(player, "A plugint keszitette LARP^n Chile 2008")
  441. }
  442. }
  443.  
  444. }
  445.  
  446. public cmd_bind(id)
  447. {
  448. if ( get_pcvar_num(g_BINDMODE) == 1 )
  449. {
  450. client_print(id, print_chat, "[ZP] Neked van %i homokzsakod, hasznalat: 'L' betu", g_bolsas[id])
  451. client_cmd(id,"bind l /pb")
  452. return PLUGIN_HANDLED
  453. }
  454. client_print(id, print_chat, "[ZP] Neked van %i homokzsakod, hasznalat: 'say /pb'", g_bolsas[id])
  455. return PLUGIN_HANDLED
  456.  
  457. }
  458.