hlmod.hu

Magyar Half-Life Mód közösség!
Pontos idő: 2024.04.16. 21:34



Jelenlévő felhasználók

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

A legtöbb felhasználó (1565 fő) 2020.11.21. 11:26-kor tartózkodott itt.

Regisztrált felhasználók: Bing [Bot], MateaBoss 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  [ 12 hozzászólás ]  Oldal Előző 1 2
Szerző Üzenet
 Hozzászólás témája: Re: Egyedi Hook
HozzászólásElküldve: 2014.01.17. 17:57 
Offline
Senior Tag
Avatar

Csatlakozott: 2013.12.06. 18:38
Hozzászólások: 229
Megköszönt másnak: 15 alkalommal
Megköszönték neki: 16 alkalommal
Kedves ultraibolya!
Most már közeletsz a megoldáshoz! Csak az az egy baj hogy T is tudja használni!
Szerintem az előzőbe írd be ezt amugy csak ez az egy baj :S !


Hozzászólás jelentése
Vissza a tetejére
   
 Hozzászólás témája: Re: Egyedi Hook
HozzászólásElküldve: 2014.01.17. 20:12 
Offline
Jómunkásember

Csatlakozott: 2012.01.29. 12:48
Hozzászólások: 408
Megköszönt másnak: 15 alkalommal
Megköszönték neki: 126 alkalommal
SMA Forráskód: [ Mindet kijelol ]
  1. /**************************************************************************************************
  2.  
  3. **** CVARS (FEATURES) ****
  4. sv_adminhook = Turn Plugin On/off
  5. **** ADMIN COMMANDS ****
  6. ADMIN_LEVEL_A (flag="m")
  7. Granting Hook/Rope = amx_granthook <authid, nick, @team, @all or #userid> <on/off>
  8.  
  9. ADMIN_LEVEL_E (flag="q") || Granted by admin
  10. Ninja Rope by Spacedude (slightly modified) & Hook thingy
  11. Attaching Rope = +rope
  12. Deattaching Rope = -rope
  13. Attaching Hook = +hook
  14. Deattaching Hook = -hook
  15.  
  16. **************************************************************************************************/
  17. #define USING_AMX 0 // 1 = Using AMX \ 0 = Useing AMXX
  18.  
  19. #if USING_AMX
  20. #include <amxmod>
  21. #include <amxmisc>
  22. #include <VexdUM>
  23. #include <fun>
  24. new gModName[32] = "AMX"
  25. #else
  26. #include <amxmodx>
  27. #include <amxmisc>
  28. #include <fun>
  29. #include <engine>
  30. #include <cstrike>
  31. new gModName[32] = "AMXX"
  32. #endif
  33.  
  34. #define TE_BEAMENTPOINT 1
  35. #define TE_KILLBEAM 99
  36. #define DELTA_T 0.1 // seconds
  37. #define BEAMLIFE 100 // deciseconds
  38. #define MOVEACCELERATION 150 // units per second^2
  39. #define REELSPEED 300 // units per second
  40.  
  41. /* Hook Stuff */
  42. new gHookLocation[33][3]
  43. new gHookLenght[33]
  44. new bool:gIsHooked[33]
  45. new gAllowedHook[33]
  46. new Float:gBeamIsCreated[33]
  47. new global_gravity
  48. new beam
  49.  
  50. /************************************************************************************************************************/
  51. public plugin_init() //Called on plugin start
  52. {
  53. // Plugin Info
  54. register_plugin("Admin Hook","1.0","AssKicR")
  55.  
  56. //CVARS
  57. register_cvar("sv_adminhook", "1" )
  58.  
  59. //ADMIN CMDS
  60. register_concmd("amx_granthook","AdminGrantHook",ADMIN_LEVEL_A,"<authid, nick, @team, @all or #userid> <on/off>")
  61.  
  62. //USER COMMANDS
  63. register_clcmd("+rope", "hook_on")
  64. register_clcmd("-rope", "hook_off")
  65. register_clcmd("+hook", "hook_on")
  66. register_clcmd("-hook", "hook_off")
  67.  
  68. //HOOKED EVENTS
  69. register_event("ResetHUD", "ResetHUD", "b")
  70. }
  71. /************************************************************************************************************************/
  72. public plugin_precache()
  73. {
  74. beam = precache_model("sprites/zbeam4.spr")
  75. precache_sound("weapons/xbow_hit2.wav")
  76. }
  77. /*************************************************************************************************************************/
  78. /************************************************** USP/SCOUT REMOVE *****************************************************/
  79. /*************************************************************************************************************************/
  80.  
  81. /*************************************************************************************************************************/
  82. /**************************************************** HOOKED EVENTS ******************************************************/
  83. /*************************************************************************************************************************/
  84. public ResetHUD(id) {
  85. //Check if he is hooked to something
  86. if (gIsHooked[id]) RopeRelease(id)
  87. }
  88. /************************************************************************************************************************/
  89. stock kz_velocity_set(id,vel[3]) {
  90. //Set Their Velocity to 0 so that they they fall straight down from
  91. new Float:Ivel[3]
  92. Ivel[0]=float(vel[0])
  93. Ivel[1]=float(vel[1])
  94. Ivel[2]=float(vel[2])
  95. entity_set_vector(id, EV_VEC_velocity, Ivel)
  96. }
  97.  
  98. stock kz_velocity_get(id,vel[3]) {
  99. //Set Their Velocity to 0 so that they they fall straight down from
  100. new Float:Ivel[3]
  101.  
  102. entity_get_vector(id, EV_VEC_velocity, Ivel)
  103. vel[0]=floatround(Ivel[0])
  104. vel[1]=floatround(Ivel[1])
  105. vel[2]=floatround(Ivel[2])
  106. }
  107.  
  108. /************************************************************************************************************************/
  109. /**************************************************** ADMIN COMMANDS ****************************************************/
  110. /************************************************************************************************************************/
  111. public AdminGrantHook(id,level,cid)
  112. {
  113. if ( !cmd_access(id,level,cid,1) )
  114. return PLUGIN_HANDLED
  115.  
  116. new arg1[32],arg2[32]
  117. read_argv(1,arg1,31)
  118. read_argv(2,arg2,31)
  119. new onoff = str_to_num(arg2)
  120.  
  121. if ( equali(arg1,"@all") )
  122. {
  123. new plist[32],pnum
  124. get_players(plist,pnum,"a")
  125. if (pnum==0)
  126. {
  127. console_print(id,"[%s] There are no clients",gModName)
  128. return PLUGIN_HANDLED
  129. }
  130. for (new i=0; i<pnum; i++) {
  131. gAllowedHook[plist[i]]=onoff
  132. if (gIsHooked[plist[i]]==true && onoff==0)
  133. {
  134. RopeRelease(plist[i])
  135. }
  136. }
  137.  
  138. console_print(id,"[%s] %s all players access to hook/rope",gModName,onoff ? "Gave":"Removed")
  139. }
  140. else if ( arg1[0]=='@' )
  141. {
  142. new plist[32],pnum
  143. get_players(plist,pnum,"ae",arg1[1])
  144. if ( pnum==0 )
  145. {
  146. console_print(id,"[%s] No clients in such team",gModName)
  147. return PLUGIN_HANDLED
  148. }
  149. for (new i=0; i<pnum; i++) {
  150. gAllowedHook[plist[i]]=onoff
  151. if (gIsHooked[plist[i]]==true && onoff==0)
  152. {
  153. RopeRelease(plist[i])
  154. }
  155. }
  156. console_print(id,"[%s] %s all %ss access to hook/rope",onoff ? "Gave":"Removed",arg1[1])
  157. }
  158. else
  159. {
  160. new pName[32]
  161. new player = cmd_target(id,arg1,6)
  162. if (!player) return PLUGIN_HANDLED
  163.  
  164. gAllowedHook[player]=onoff
  165. if (gAllowedHook[player]==0 && onoff==0)
  166. {
  167. RopeRelease(player)
  168. }
  169.  
  170.  
  171. get_user_name(player,pName,31)
  172. console_print(id,"[%s] %s ^"%s^" access to hook/rope",onoff ? "Gave":"Removed",pName)
  173. }
  174.  
  175. return PLUGIN_HANDLED
  176. }
  177.  
  178. /************************************************************************************************************************/
  179. /****************************************************** NINJAROPE *******************************************************/
  180. /************************************************************************************************************************/
  181.  
  182. public ropetask(parm[])
  183. {
  184. new id = parm[0]
  185. new user_origin[3], user_look[3], user_direction[3], move_direction[3]
  186. new A[3], D[3], buttonadjust[3]
  187. new acceleration, velocity_towards_A, desired_velocity_towards_A
  188. new velocity[3], null[3]
  189.  
  190. if (!is_user_alive(id))
  191. {
  192. RopeRelease(id)
  193. return
  194. }
  195.  
  196. if (gBeamIsCreated[id] + BEAMLIFE/10 <= get_gametime())
  197. {
  198. beamentpoint(id)
  199. }
  200.  
  201. null[0] = 0
  202. null[1] = 0
  203. null[2] = 0
  204.  
  205. get_user_origin(id, user_origin)
  206. get_user_origin(id, user_look,2)
  207. kz_velocity_get(id, velocity)
  208.  
  209. buttonadjust[0]=0
  210. buttonadjust[1]=0
  211.  
  212. if (get_user_button(id)&IN_FORWARD) buttonadjust[0]+=1
  213. if (get_user_button(id)&IN_BACK) buttonadjust[0]-=1
  214. if (get_user_button(id)&IN_MOVERIGHT) buttonadjust[1]+=1
  215. if (get_user_button(id)&IN_MOVELEFT) buttonadjust[1]-=1
  216. if (get_user_button(id)&IN_JUMP) buttonadjust[2]+=1
  217. if (get_user_button(id)&IN_DUCK) buttonadjust[2]-=1
  218.  
  219. if (buttonadjust[0] || buttonadjust[1])
  220. {
  221. user_direction[0] = user_look[0] - user_origin[0]
  222. user_direction[1] = user_look[1] - user_origin[1]
  223.  
  224. move_direction[0] = buttonadjust[0]*user_direction[0] + user_direction[1]*buttonadjust[1]
  225. move_direction[1] = buttonadjust[0]*user_direction[1] - user_direction[0]*buttonadjust[1]
  226. move_direction[2] = 0
  227.  
  228. velocity[0] += floatround(move_direction[0] * MOVEACCELERATION * DELTA_T / get_distance(null,move_direction))
  229. velocity[1] += floatround(move_direction[1] * MOVEACCELERATION * DELTA_T / get_distance(null,move_direction))
  230. }
  231.  
  232. if (buttonadjust[2]) gHookLenght[id] -= floatround(buttonadjust[2] * REELSPEED * DELTA_T)
  233. if (gHookLenght[id] < 100) gHookLenght[id] = 100
  234.  
  235. A[0] = gHookLocation[id][0] - user_origin[0]
  236. A[1] = gHookLocation[id][1] - user_origin[1]
  237. A[2] = gHookLocation[id][2] - user_origin[2]
  238.  
  239. D[0] = A[0]*A[2] / get_distance(null,A)
  240. D[1] = A[1]*A[2] / get_distance(null,A)
  241. D[2] = -(A[1]*A[1] + A[0]*A[0]) / get_distance(null,A)
  242.  
  243. acceleration = - global_gravity * D[2] / get_distance(null,D)
  244.  
  245. velocity_towards_A = (velocity[0] * A[0] + velocity[1] * A[1] + velocity[2] * A[2]) / get_distance(null,A)
  246. desired_velocity_towards_A = (get_distance(user_origin,gHookLocation[id]) - gHookLenght[id] /*- 10*/) * 4
  247.  
  248. if (get_distance(null,D)>10)
  249. {
  250. velocity[0] += floatround((acceleration * DELTA_T * D[0]) / get_distance(null,D))
  251. velocity[1] += floatround((acceleration * DELTA_T * D[1]) / get_distance(null,D))
  252. velocity[2] += floatround((acceleration * DELTA_T * D[2]) / get_distance(null,D))
  253. }
  254.  
  255. velocity[0] += ((desired_velocity_towards_A - velocity_towards_A) * A[0]) / get_distance(null,A)
  256. velocity[1] += ((desired_velocity_towards_A - velocity_towards_A) * A[1]) / get_distance(null,A)
  257. velocity[2] += ((desired_velocity_towards_A - velocity_towards_A) * A[2]) / get_distance(null,A)
  258.  
  259. kz_velocity_set(id, velocity)
  260. }
  261.  
  262. public hooktask(parm[])
  263. {
  264. new id = parm[0]
  265. new velocity[3]
  266.  
  267. if ( !gIsHooked[id] ) return
  268.  
  269. new user_origin[3],oldvelocity[3]
  270. parm[0] = id
  271.  
  272. if (!is_user_alive(id))
  273. {
  274. RopeRelease(id)
  275. return
  276. }
  277.  
  278. if (gBeamIsCreated[id] + BEAMLIFE/10 <= get_gametime())
  279. {
  280. beamentpoint(id)
  281. }
  282.  
  283. get_user_origin(id, user_origin)
  284. kz_velocity_get(id, oldvelocity)
  285. new distance=get_distance( gHookLocation[id], user_origin )
  286. if ( distance > 10 )
  287. {
  288. velocity[0] = floatround( (gHookLocation[id][0] - user_origin[0]) * ( 2.0 * REELSPEED / distance ) )
  289. velocity[1] = floatround( (gHookLocation[id][1] - user_origin[1]) * ( 2.0 * REELSPEED / distance ) )
  290. velocity[2] = floatround( (gHookLocation[id][2] - user_origin[2]) * ( 2.0 * REELSPEED / distance ) )
  291. }
  292. else
  293. {
  294. velocity[0]=0
  295. velocity[1]=0
  296. velocity[2]=0
  297. }
  298.  
  299. kz_velocity_set(id, velocity)
  300.  
  301. }
  302.  
  303. public hook_on(id)
  304. {
  305. if (get_cvar_num("sv_adminhook")==1)
  306. {
  307. if (gAllowedHook[id] || (get_user_team(id) == 2)) {
  308. if (!gIsHooked[id] && is_user_alive(id))
  309. {
  310. new cmd[32]
  311. read_argv(0,cmd,31)
  312. if(equal(cmd,"+rope")) RopeAttach(id,0)
  313. if(equal(cmd,"+hook")) RopeAttach(id,1)
  314. }
  315. }else{
  316.  
  317. return PLUGIN_HANDLED
  318. }
  319. }else{
  320. client_print(id,print_chat,"[%s] This command is deativated",gModName)
  321. }
  322. return PLUGIN_HANDLED
  323. }
  324.  
  325. public hook_off(id)
  326. {
  327. if (gAllowedHook[id] || (get_user_team(id) == 2)) {
  328. if (gIsHooked[id])
  329. {
  330. RopeRelease(id)
  331. }
  332. }else{
  333. return PLUGIN_HANDLED
  334. }
  335. return PLUGIN_HANDLED
  336. }
  337.  
  338. public RopeAttach(id,hook)
  339. {
  340. new parm[1], user_origin[3]
  341. parm[0] = id
  342. gIsHooked[id] = true
  343. get_user_origin(id,user_origin)
  344. get_user_origin(id,gHookLocation[id], 3)
  345. gHookLenght[id] = get_distance(gHookLocation[id],user_origin)
  346. global_gravity = get_cvar_num("sv_gravity")
  347. set_user_gravity(id,0.001)
  348. beamentpoint(id)
  349. emit_sound(id, CHAN_STATIC, "weapons/xbow_hit2.wav", 1.0, ATTN_NORM, 0, PITCH_NORM)
  350. if (hook) set_task(DELTA_T, "hooktask", 200+id, parm, 1, "b")
  351. else set_task(DELTA_T, "ropetask", 200+id, parm, 1, "b")
  352. }
  353.  
  354. public RopeRelease(id)
  355. {
  356. gIsHooked[id] = false
  357. killbeam(id)
  358. set_user_gravity(id)
  359. remove_task(200+id)
  360. }
  361.  
  362. public beamentpoint(id)
  363. {
  364. message_begin( MSG_BROADCAST, SVC_TEMPENTITY )
  365. write_byte( TE_BEAMENTPOINT )
  366. write_short( id )
  367. write_coord( gHookLocation[id][0] )
  368. write_coord( gHookLocation[id][1] )
  369. write_coord( gHookLocation[id][2] )
  370. write_short( beam ) // sprite index
  371. write_byte( 0 ) // start frame
  372. write_byte( 0 ) // framerate
  373. write_byte( BEAMLIFE ) // life
  374. write_byte( 10 ) // width
  375. write_byte( 0 ) // noise
  376. if (get_user_team(id)==1) // Terrorist
  377. {
  378. write_byte( 255 ) // r, g, b
  379. write_byte( 0 ) // r, g, b
  380. write_byte( 0 ) // r, g, b
  381. }
  382. else // Counter-Terrorist
  383. {
  384. write_byte( 0 ) // r, g, b
  385. write_byte( 0 ) // r, g, b
  386. write_byte( 255 ) // r, g, b
  387. }
  388. write_byte( 150 ) // brightness
  389. write_byte( 0 ) // speed
  390. message_end( )
  391. gBeamIsCreated[id] = get_gametime()
  392. }
  393.  
  394. public killbeam(id)
  395. {
  396. message_begin( MSG_BROADCAST, SVC_TEMPENTITY )
  397. write_byte( TE_KILLBEAM )
  398. write_short( id )
  399. message_end()
  400. }
  401.  
  402. /************************************************************************************************************************/
  403. /******************************************************* FORWARDS *******************************************************/
  404. /************************************************************************************************************************/
  405.  
  406. public client_disconnect(id) {
  407. gAllowedHook[id]=0
  408. }
  409.  
  410. /************************************************************************************************************************/
  411. /************************************************** AMXX -> AMX funcs ***************************************************/
  412. /************************************************************************************************************************/
  413. #if USING_AMX
  414. stock get_user_button(id) return entity_get_int(id, EV_INT_button)
  415. #endif
  416.  

Ők köszönték meg HuBaBuBa nek ezt a hozzászólást: hallywood (2014.01.19. 18:55)
  Népszerűség: 2.27%


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  [ 12 hozzászólás ]  Oldal Előző 1 2


Ki van itt

Jelenlévő fórumozók: nincs regisztrált felhasználó valamint 14 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