hlmod.hu

Magyar Half-Life Mód közösség!
Pontos idő: 2025.06.16. 20:41



Jelenlévő felhasználók

Jelenleg 373 felhasználó van jelen :: 2 regisztrált, 0 rejtett és 371 vendég

A legtöbb felhasználó (2761 fő) 2025.01.09. 20:06-kor tartózkodott itt.

Regisztrált felhasználók: Bing [Bot], Google [Bot]az elmúlt 5 percben aktív felhasználók alapján

Utoljára aktív
Ahhoz hogy lásd ki volt utoljára aktív, be kell jelentkezned.



Az oldal teljeskörű
használatához regisztrálj.

Regisztráció

Kereső


Új téma nyitása Hozzászólás a témához  [1 hozzászólás ] 
Szerző Üzenet
 Hozzászólás témája: Gázgránát
HozzászólásElküldve:2013.04.26. 15:49 
Offline
Veterán
Avatar

Csatlakozott:2013.03.26. 20:20
Hozzászólások:1846
Megköszönt másnak: 27 alkalommal
Megköszönték neki: 120 alkalommal
Van ez a plugin és nekem úgy kéne, hogy külön modellje legyen (van hozzá nekem).
Pl. mint az extra fegyverek, úgy kellene.
Még az kellene, hogy /gasgrenade parancssal lehessen megvenni 1000 $-ért.
Remélem érhetően írtam le :D

SMA Forráskód: [ Mindet kijelol ]
  1. /* Copyright © 2008, ConnorMcLeod
  2.  
  3. GasNades is free software;
  4. you can redistribute it and/or modify it under the terms of the
  5. GNU General Public License as published by the Free Software Foundation.
  6.  
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU General Public License for more details.
  11.  
  12. You should have received a copy of the GNU General Public License
  13. along with GasNades; if not, write to the
  14. Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  15. Boston, MA 02111-1307, USA.
  16. */
  17.  
  18. #include <amxmodx>
  19. #include <fakemeta>
  20. #include <hamsandwich>
  21.  
  22. #pragma semicolon 1
  23.  
  24. #define PLUGIN "GasNades"
  25. #define AUTHOR "ConnorMcLeod"
  26. #define VERSION "2.0.0"
  27.  
  28. #define GASP_SOUND1 "player/gasp1.wav"
  29. #define GASP_SOUND2 "player/gasp2.wav"
  30.  
  31. #define PEV_PDATA_SAFE 2
  32.  
  33. #define MAX_PLAYERS 32
  34.  
  35. #define m_bitsDamageType 76 // VEN
  36.  
  37. #define OFFSET_TEAM 114
  38. #define fm_get_user_team(%1) get_pdata_int(%1,OFFSET_TEAM)
  39.  
  40. #define write_coord_f(%1) engfunc(EngFunc_WriteCoord, %1)
  41.  
  42. #define GASNADE_HURT -666
  43. #define GASNADE_HEAL -777
  44.  
  45. new g_pCvarRadius, g_pCvarCheckTime, g_pCvarDmg, g_pCvarFF, g_pCvarLife, g_pCvarGasp,
  46. g_pCvarRestore, g_pCvarNoSmoke, g_pCvarEnabled;
  47. new mp_friendlyfire;
  48.  
  49. new g_iMaxPlayers;
  50.  
  51. new g_iHealer;
  52.  
  53. new Float:g_fLastHurt[MAX_PLAYERS+1];
  54. new Float:g_fDmgToRestore[MAX_PLAYERS+1];
  55.  
  56. new g_iForwardEmitSound;
  57. new HamHook:g_iHamTouch, HamHook:g_iHamThink;
  58.  
  59. public plugin_init()
  60. {
  61. register_plugin( PLUGIN, VERSION, AUTHOR );
  62. register_cvar("gasnade", VERSION, FCVAR_SERVER);
  63.  
  64. g_pCvarEnabled = register_cvar("amx_gasnades", "1");
  65.  
  66. g_pCvarDmg = register_cvar("amx_gasdmg", "2");
  67. g_pCvarRadius = register_cvar("amx_gasradius", "175");
  68. g_pCvarCheckTime = register_cvar("amx_gascheck", "2");
  69. g_pCvarFF = register_cvar("amx_gasobeyFF", "0");
  70. g_pCvarLife = register_cvar("amx_gaslife", "25");
  71. g_pCvarGasp = register_cvar("amx_smokegasp", "1");
  72. g_pCvarRestore = register_cvar("amx_gas_restore", "1");
  73. g_pCvarNoSmoke = register_cvar("amx_gas_nosmoke", "0");
  74.  
  75. register_event("HLTV", "Event_HLTV_NewRound", "a", "1=0", "2=0");
  76.  
  77. g_iMaxPlayers = get_maxplayers();
  78. mp_friendlyfire = get_cvar_pointer("mp_friendlyfire");
  79.  
  80. Event_HLTV_NewRound();
  81. }
  82.  
  83. public plugin_precache()
  84. {
  85. precache_sound(GASP_SOUND1);
  86. precache_sound(GASP_SOUND2);
  87. }
  88.  
  89. public plugin_pause()
  90. {
  91. new iEnt = FM_NULLENT;
  92. while( (iEnt = engfunc(EngFunc_FindEntityByString, iEnt, "classname", "trigger_hurt")) > 0 )
  93. {
  94. if( pev(iEnt, pev_iuser1) == GASNADE_HURT )
  95. engfunc(EngFunc_RemoveEntity, iEnt);
  96. }
  97. Healer(0);
  98. }
  99.  
  100. public Event_HLTV_NewRound()
  101. {
  102. new iEnt = FM_NULLENT;
  103. while( (iEnt = engfunc(EngFunc_FindEntityByString, iEnt, "classname", "trigger_hurt")) > 0 )
  104. {
  105. if( pev(iEnt, pev_iuser1) == GASNADE_HURT )
  106. engfunc(EngFunc_RemoveEntity, iEnt);
  107. }
  108.  
  109. for(new id=1; id<=g_iMaxPlayers; id++)
  110. {
  111. g_fLastHurt[id] = g_fDmgToRestore[id] = 0.0;
  112. }
  113.  
  114. if( get_pcvar_num(g_pCvarEnabled) )
  115. {
  116. if( !g_iForwardEmitSound )
  117. {
  118. g_iForwardEmitSound = register_forward(FM_EmitSound, "EmitSound");
  119. }
  120.  
  121. if( g_iHamTouch )
  122. {
  123. EnableHamForward(g_iHamTouch);
  124. }
  125. else
  126. {
  127. g_iHamTouch = RegisterHam(Ham_Touch, "trigger_hurt", "HurtTouch");
  128. }
  129.  
  130. if( g_iHamThink )
  131. {
  132. EnableHamForward(g_iHamThink);
  133. }
  134. else
  135. {
  136. g_iHamThink = RegisterHam(Ham_Think, "trigger_hurt", "HurtThink");
  137. }
  138.  
  139. Healer(get_pcvar_num(g_pCvarRestore) ? 1 : 0);
  140. }
  141. else
  142. {
  143. if( g_iForwardEmitSound )
  144. {
  145. unregister_forward(FM_EmitSound, g_iForwardEmitSound);
  146. g_iForwardEmitSound = 0;
  147. }
  148.  
  149. if( g_iHamTouch )
  150. {
  151. DisableHamForward(g_iHamTouch);
  152. }
  153.  
  154. if( g_iHamThink )
  155. {
  156. DisableHamForward(g_iHamThink);
  157. }
  158.  
  159. Healer(0);
  160. }
  161. }
  162.  
  163. public EmitSound(iEntity, iChannel, const szSample[], Float:fVol, Float:fAttn, iFlags, iPitch)
  164. {
  165. if( !equal(szSample, "weapons/sg_explode.wav") )
  166. return;
  167.  
  168. new iEnt = engfunc( EngFunc_CreateNamedEntity , engfunc( EngFunc_AllocString, "trigger_hurt") );
  169.  
  170. dllfunc(DLLFunc_Spawn, iEnt);
  171.  
  172. new Float:fRadius = get_pcvar_float(g_pCvarRadius);
  173. new Float:fMins[3], Float:fMaxs[3];
  174. for(new i; i<3; i++)
  175. {
  176. fMins[i] = -fRadius;
  177. fMaxs[i] = fRadius;
  178. }
  179. engfunc(EngFunc_SetSize , iEnt , fMins , fMaxs );
  180.  
  181. new Float:fOrigin[3];
  182. pev(iEntity, pev_origin, fOrigin);
  183. engfunc(EngFunc_SetOrigin, iEnt, fOrigin);
  184.  
  185. set_pev(iEnt, pev_dmg, get_pcvar_float(g_pCvarDmg));
  186.  
  187. set_pev(iEnt, pev_iuser1, GASNADE_HURT);
  188.  
  189. new iOwner = pev(iEntity, pev_owner);
  190. if( pev_valid(iOwner) == PEV_PDATA_SAFE )
  191. {
  192. set_pev(iEnt, pev_iuser2, fm_get_user_team(iOwner));
  193. set_pev(iEnt, pev_owner, iOwner);
  194. }
  195.  
  196. set_pev(iEnt, pev_nextthink, get_gametime() + get_pcvar_float(g_pCvarLife));
  197.  
  198. if( get_pcvar_num(g_pCvarNoSmoke) )
  199. {
  200. emit_sound(iEntity, iChannel, szSample, fVol, fAttn, iFlags, iPitch);
  201. engfunc(EngFunc_RemoveEntity, iEntity);
  202. }
  203. }
  204.  
  205. public HurtThink(iEnt)
  206. {
  207. if( pev(iEnt, pev_iuser1) == GASNADE_HURT )
  208. {
  209. engfunc(EngFunc_RemoveEntity, iEnt);
  210. }
  211. }
  212.  
  213. public HurtTouch(iEnt, id)
  214. {
  215. static iPod;
  216. iPod = pev(iEnt, pev_iuser1);
  217. if( (iPod != GASNADE_HURT && iPod != GASNADE_HEAL) ||
  218. !(1 <= id <= g_iMaxPlayers) )
  219. {
  220. return HAM_IGNORED;
  221. }
  222.  
  223. new iOwner = pev(iEnt, pev_owner);
  224.  
  225. if( iPod == GASNADE_HURT && get_pcvar_num(g_pCvarFF) && !get_pcvar_num(mp_friendlyfire) &&
  226. pev(iEnt, pev_iuser2) == fm_get_user_team(id) )
  227. {
  228. return HAM_SUPERCEDE;
  229. }
  230.  
  231. static Float:flTime, Float:flDmgTime;
  232. flTime = get_gametime();
  233. pev(iEnt, pev_dmgtime, flDmgTime);
  234.  
  235. if( flDmgTime > flTime )
  236. {
  237. static Float:flPainFinished;
  238. pev(iEnt, pev_pain_finished, flPainFinished);
  239. if( flTime != flPainFinished )
  240. {
  241. static iImpulse;
  242. iImpulse = pev(iEnt, pev_impulse);
  243. if ( iImpulse & (1<<(id-1)) )
  244. return HAM_SUPERCEDE;
  245.  
  246. set_pev(iEnt, pev_impulse, iImpulse | (1<<(id-1)));
  247. }
  248. }
  249. else
  250. {
  251. set_pev(iEnt, pev_impulse, (1<<(id-1)));
  252. }
  253.  
  254. static Float:flDmg, Float:flCheckTime;
  255. pev(iEnt, pev_dmg, flDmg);
  256. flCheckTime = get_pcvar_float(g_pCvarCheckTime);
  257.  
  258. if( iPod == GASNADE_HURT )
  259. {
  260. TakeDamage(id, iEnt, iOwner, flDmg, DMG_SLOWFREEZE);
  261. g_fDmgToRestore[id] += flDmg;
  262.  
  263. if(get_pcvar_num(g_pCvarGasp))
  264. {
  265. switch (random_num(1, 2))
  266. {
  267. case 1: emit_sound(id, CHAN_VOICE, GASP_SOUND1, 1.0, ATTN_NORM, 0, PITCH_NORM);
  268. case 2: emit_sound(id, CHAN_VOICE, GASP_SOUND2, 1.0, ATTN_NORM, 0, PITCH_NORM);
  269. }
  270. }
  271. g_fLastHurt[id] = flTime;
  272. }
  273. else
  274. {
  275. if( flTime - g_fLastHurt[id] > flCheckTime && g_fDmgToRestore[id])
  276. {
  277. if( g_fDmgToRestore[id] < flDmg )
  278. {
  279. flDmg = g_fDmgToRestore[id];
  280. }
  281. g_fDmgToRestore[id] -= flDmg;
  282. TakeHealth(id, flDmg);
  283. }
  284. }
  285.  
  286. set_pev(iEnt, pev_pain_finished, flTime);
  287. set_pev(iEnt, pev_dmgtime, flTime + flCheckTime);
  288.  
  289. return HAM_SUPERCEDE;
  290. }
  291.  
  292. Healer(iStatus)
  293. {
  294. if( iStatus )
  295. {
  296. if( !pev_valid(g_iHealer) )
  297. {
  298. g_iHealer = engfunc( EngFunc_CreateNamedEntity , engfunc( EngFunc_AllocString, "trigger_hurt") );
  299. dllfunc(DLLFunc_Spawn, g_iHealer);
  300. engfunc(EngFunc_SetSize , g_iHealer , Float:{-4096.0, -4096.0, -4096.0} , Float:{4096.0, 4096.0, 4096.0} );
  301. set_pev(g_iHealer, pev_iuser1, GASNADE_HEAL);
  302. }
  303. set_pev(g_iHealer, pev_dmg, get_pcvar_float(g_pCvarDmg));
  304. }
  305. else
  306. {
  307. if( pev_valid(g_iHealer) )
  308. {
  309. engfunc(EngFunc_RemoveEntity, g_iHealer);
  310. g_iHealer = FM_NULLENT;
  311. }
  312. }
  313. }
  314.  
  315. TakeHealth(id, Float:flDmg)
  316. {
  317. new Float:flHealth, Float:flMaxHealth;
  318.  
  319. pev(id, pev_health, flHealth);
  320. pev(id, pev_max_health, flMaxHealth);
  321.  
  322. if( flMaxHealth <= flHealth )
  323. return;
  324.  
  325. flHealth += flDmg;
  326.  
  327. if( flHealth > flMaxHealth )
  328. flHealth = flMaxHealth;
  329.  
  330. set_pev(id, pev_health, flHealth);
  331. }
  332.  
  333. TakeDamage(id, iEnt, iAttacker, Float:flDmg, iDmgBit)
  334. {
  335. new Float:flHealth;
  336. pev(id, pev_health, flHealth);
  337.  
  338. flHealth -= flDmg;
  339.  
  340. if( flHealth < 1 )
  341. {
  342. ExecuteHamB( Ham_Killed, id, iAttacker, 0 );
  343. return;
  344. }
  345.  
  346. set_pev(id, pev_health, flHealth);
  347.  
  348. set_pev(id, pev_dmg_take, flDmg);
  349. set_pdata_int(id, m_bitsDamageType, iDmgBit);
  350. set_pev(id, pev_dmg_inflictor, iEnt);
  351. }

_________________
Projektem:

[CSO2] Ghost Mod
CSO2 GamePlay video: https://www.youtube.com/watch?feature=p ... iOS4Ik1Yrk


Hozzászólás jelentése
Vissza a tetejére
   
Hozzászólások megjelenítése: Rendezés 
Új téma nyitása Hozzászólás a témához  [1 hozzászólás ] 


Ki van itt

Jelenlévő fórumozók: nincs regisztrált felhasználó valamint 4 vendég


Nyithatsz új témákat ebben a fórumban.
Válaszolhatsz egy témára ebben a fórumban.
Nem szerkesztheted a hozzászólásaidat ebben a fórumban.
Nem törölheted a hozzászólásaidat ebben a fórumban.
Nem küldhetsz csatolmányokat ebben a fórumban.

Keresés:
Ugrás:  
Powered by phpBB® Forum Software © phpBB Limited
Magyar fordítás © Magyar phpBB Közösség
Portal: Kiss Portal Extension © Michael O'Toole