hlmod.hu

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



Jelenlévő felhasználók

Jelenleg 359 felhasználó van jelen :: 2 regisztrált, 0 rejtett és 357 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: Pet plugin átalakítás
HozzászólásElküldve:2013.11.23. 14:02 
Offline
Tag
Avatar

Csatlakozott:2013.01.28. 16:11
Hozzászólások:48
Megköszönt másnak: 8 alkalommal
Sziasztok.
Ezt a plugint kellene úgy átalakítani hogy az iron féle vip rendszerrel működjön.

Segítségeteket előre is köszönöm.

SMA Forráskód: [ Mindet kijelol ]
  1. /*
  2. * _______ _ _ __ __
  3. * | _____/ | | | | \ \ __ / /
  4. * | | | | | | | | / \ | |
  5. * | | | |____| | | |/ __ \| |
  6. * | | ___ | ______ | | / \ |
  7. * | | |_ | | | | | | / \ |
  8. * | | | | | | | | | | | |
  9. * | |____| | | | | | | | | |
  10. * |_______/ |_| |_| \_/ \_/
  11. *
  12. *
  13. *
  14. * Last Edited: 07-04-09
  15. *
  16. * ============
  17. * Changelog:
  18. * ============
  19. *
  20. * v2.1
  21. * -Added some pets
  22. * -Fixed death animations
  23. * -Fixed chat text bug
  24. *
  25. * v2.0
  26. * -Added ML
  27. *
  28. * v1.0
  29. * -Initial Release
  30. *
  31. */
  32.  
  33. #define VERSION "2.1"
  34.  
  35. #include <amxmodx>
  36. #include <amxmisc>
  37. #include <chr_engine>
  38.  
  39. #define PET_NUM 9
  40.  
  41. static const pet_name[PET_NUM][32] =
  42. {
  43. "Headcrab",
  44. "Rat",
  45. "Bat",
  46. "Frog",
  47. "Floater",
  48. "Cockroach",
  49. "Hyper Bat",
  50. "Fish",
  51. "Baby Headcrab"
  52. }
  53.  
  54. static const pet_models[PET_NUM][32] =
  55. {
  56. "models/headcrab.mdl",
  57. "models/bigrat.mdl",
  58. "models/boid.mdl",
  59. "models/chumtoad.mdl",
  60. "models/floater.mdl",
  61. "models/roach.mdl",
  62. "models/stukabat.mdl",
  63. "models/archer.mdl",
  64. "models/baby_headcrab.mdl"
  65. }
  66.  
  67. static const pet_idle[PET_NUM] =
  68. {
  69. 0,
  70. 1,
  71. 0,
  72. 0,
  73. 0,
  74. 1,
  75. 13,
  76. 0,
  77. 1
  78. }
  79.  
  80. static const Float:pet_idle_speed[PET_NUM] =
  81. {
  82. 1.0,
  83. 1.0,
  84. 1.0,
  85. 1.0,
  86. 1.0,
  87. 1.0,
  88. 0.5,
  89. 1.0,
  90. 1.0
  91. }
  92.  
  93. static const pet_run[PET_NUM] =
  94. {
  95. 4,
  96. 4,
  97. 0,
  98. 5,
  99. 0,
  100. 0,
  101. 13,
  102. 6,
  103. 4
  104. }
  105.  
  106. static const Float:pet_run_speed[PET_NUM] =
  107. {
  108. 2.0,
  109. 6.0,
  110. 3.0,
  111. 0.75,
  112. 1.0,
  113. 1.0,
  114. 13.0,
  115. 0.6,
  116. 0.6
  117. }
  118.  
  119. static const pet_die[PET_NUM] =
  120. {
  121. 7,
  122. 7,
  123. 0,
  124. 12,
  125. 0,
  126. 0,
  127. 5,
  128. 9,
  129. 7
  130. }
  131.  
  132. static const Float:pet_die_length[PET_NUM] =
  133. {
  134. 2.4,
  135. 2.4,
  136. 0.1,
  137. 3.0,
  138. 0.1,
  139. 0.1,
  140. 3.0,
  141. 3.0,
  142. 3.0
  143. }
  144.  
  145. static const Float:pet_minus_z_standing[PET_NUM] =
  146. {
  147. 36.0,
  148. 36.0,
  149. 5.0,
  150. 36.0,
  151. 5.0,
  152. 36.0,
  153. 10.0,
  154. 20.0,
  155. 36.0
  156. }
  157.  
  158. static const Float:pet_minus_z_crouching[PET_NUM] =
  159. {
  160. 16.0,
  161. 16.0,
  162. 6.0,
  163. 16.0,
  164. 6.0,
  165. 16.0,
  166. 11.0,
  167. 30.0,
  168. 16.0
  169. }
  170.  
  171. static const Float:pet_max_distance[PET_NUM] =
  172. {
  173. 300.0,
  174. 300.0,
  175. 300.0,
  176. 300.0,
  177. 300.0,
  178. 300.0,
  179. 300.0,
  180. 300.0,
  181. 300.0
  182. }
  183.  
  184. static const Float:pet_min_distance[PET_NUM] =
  185. {
  186. 80.0,
  187. 80.0,
  188. 80.0,
  189. 80.0,
  190. 80.0,
  191. 80.0,
  192. 80.0,
  193. 80.0,
  194. 80.0
  195. }
  196.  
  197. new pet[33]
  198. new pettype[33]
  199. new maxplayers
  200.  
  201. public plugin_init()
  202. {
  203. register_plugin("GHW Pet Followers",VERSION,"GHW_Chronic")
  204. register_clcmd("say","say_hook")
  205. register_clcmd("say_team","say_hook")
  206. register_event("DeathMsg","DeathMsg","a")
  207. register_forward(FM_Think,"FM_Think_hook")
  208.  
  209. maxplayers = get_maxplayers()
  210.  
  211. register_dictionary("GHW_Pet_Followers.txt")
  212. }
  213.  
  214. public plugin_precache()
  215. {
  216. for(new i=0;i<PET_NUM;i++) precache_model(pet_models[i])
  217. }
  218.  
  219. public client_disconnect(id) handle_DeathMsg(id)
  220.  
  221. public DeathMsg() handle_DeathMsg(read_data(2))
  222.  
  223. public handle_DeathMsg(id)
  224. {
  225. if(pet[id] && pev_valid(pet[id]))
  226. {
  227. set_pev(pet[id],pev_animtime,100.0)
  228. set_pev(pet[id],pev_framerate,1.0)
  229. set_pev(pet[id],pev_sequence,pet_die[pettype[id]])
  230. set_pev(pet[id],pev_gaitsequence,pet_die[pettype[id]])
  231. set_task(pet_die_length[pettype[id]],"remove_pet",pet[id])
  232. }
  233. pet[id]=0
  234. }
  235.  
  236. public remove_pet(ent) if(pev_valid(ent)) engfunc(EngFunc_RemoveEntity,ent)
  237.  
  238. public say_hook(id)
  239. {
  240. new arg[32]
  241. read_argv(1,arg,31)
  242. if(equali(arg,"/pet Headcrab")) pet_cmd_handle(id,0)
  243. else if(equali(arg,"/pet Rat")) pet_cmd_handle(id,1)
  244. else if(equali(arg,"/pet Bat")) pet_cmd_handle(id,2)
  245. else if(equali(arg,"/pet Frog")) pet_cmd_handle(id,3)
  246. else if(equali(arg,"/pet Floater")) pet_cmd_handle(id,4)
  247. else if(equali(arg,"/pet Cockroach")) pet_cmd_handle(id,5)
  248. else if(equali(arg,"/pet Hyper") || equali(arg,"/pet Hyper Bat")) pet_cmd_handle(id,6)
  249. else if(equali(arg,"/pet Fish")) pet_cmd_handle(id,9)
  250. else if(equali(arg,"/pet Baby Headcrab") || equali(arg,"/pet Baby")) pet_cmd_handle(id,10)
  251. else if(containi(arg,"/pet")==0) pet_cmd_handle(id,random_num(0,PET_NUM-1))
  252. else if(containi(arg,"/nopet")==0)
  253. {
  254. if(pet[id]) client_print(id,print_chat,"[AMXX] %L",id,"MSG_REMOVEPET")
  255. else client_print(id,print_chat,"[AMXX] %L",id,"MSG_NOREMOVEPET")
  256. handle_DeathMsg(id)
  257. }
  258. }
  259.  
  260. public random_pet()
  261. {
  262. new num = random_num(0,PET_NUM-1);
  263. if(num==7 || num==8 || num==12 || num==15 || num==16)
  264. num = random_pet()
  265.  
  266. return num;
  267. }
  268.  
  269. public pet_cmd_handle(id,num)
  270. {
  271. if(pet[id])
  272. {
  273. client_print(id,print_chat,"[AMXX] %L",id,"MSG_NOGIVEPET_HAVE")
  274. }
  275. else if(!is_user_alive(id))
  276. {
  277. client_print(id,print_chat,"[AMXX] %L",id,"MSG_NOGIVEPET_DEAD")
  278. }
  279. else
  280. {
  281. pet[id] = engfunc(EngFunc_CreateNamedEntity,engfunc(EngFunc_AllocString,"info_target"))
  282. set_pev(pet[id],pev_classname,"GHW_Pet")
  283. pettype[id] = num
  284. engfunc(EngFunc_SetModel,pet[id],pet_models[pettype[id]])
  285. new Float:origin[3]
  286. pev(id,pev_origin,origin)
  287. if(is_user_crouching(id)) origin[2] -= pet_minus_z_crouching[pettype[id]]
  288. else origin[2] -= pet_minus_z_standing[pettype[id]]
  289. set_pev(pet[id],pev_origin,origin)
  290. set_pev(pet[id],pev_solid,SOLID_NOT)
  291. set_pev(pet[id],pev_movetype,MOVETYPE_FLY)
  292. set_pev(pet[id],pev_owner,33)
  293. set_pev(pet[id],pev_nextthink,1.0)
  294. set_pev(pet[id],pev_sequence,0)
  295. set_pev(pet[id],pev_gaitsequence,0)
  296. set_pev(pet[id],pev_framerate,1.0)
  297. client_print(id,print_chat,"[AMXX] %L",id,"MSG_GIVEPET",pet_name[pettype[id]])
  298. }
  299. }
  300.  
  301. public FM_Think_hook(ent)
  302. {
  303. for(new i=0;i<=maxplayers;i++)
  304. {
  305. if(ent==pet[i])
  306. {
  307. static Float:origin[3]
  308. static Float:origin2[3]
  309. static Float:velocity[3]
  310. pev(ent,pev_origin,origin2)
  311. get_offset_origin_body(i,Float:{50.0,0.0,0.0},origin)
  312. if(is_user_crouching(i)) origin[2] -= pet_minus_z_crouching[pettype[i]]
  313. else origin[2] -= pet_minus_z_standing[pettype[i]]
  314.  
  315. if(get_distance_f(origin,origin2)>pet_max_distance[pettype[i]])
  316. {
  317. set_pev(ent,pev_origin,origin)
  318. }
  319. else if(get_distance_f(origin,origin2)>pet_min_distance[pettype[i]])
  320. {
  321. get_speed_vector(origin2,origin,250.0,velocity)
  322. set_pev(ent,pev_velocity,velocity)
  323. if(pev(ent,pev_sequence)!=pet_run[pettype[i]] || pev(ent,pev_framerate)!=pet_run_speed[pettype[i]])
  324. {
  325. set_pev(ent,pev_frame,1)
  326. set_pev(ent,pev_sequence,pet_run[pettype[i]])
  327. set_pev(ent,pev_gaitsequence,pet_run[pettype[i]])
  328. set_pev(ent,pev_framerate,pet_run_speed[pettype[i]])
  329. }
  330. }
  331. else if(get_distance_f(origin,origin2)<pet_min_distance[pettype[i]] - 5.0)
  332. {
  333. if(pev(ent,pev_sequence)!=pet_idle[pettype[i]] || pev(ent,pev_framerate)!=pet_idle_speed[pettype[i]])
  334. {
  335. set_pev(ent,pev_frame,1)
  336. set_pev(ent,pev_sequence,pet_idle[pettype[i]])
  337. set_pev(ent,pev_gaitsequence,pet_idle[pettype[i]])
  338. set_pev(ent,pev_framerate,pet_idle_speed[pettype[i]])
  339. }
  340. set_pev(ent,pev_velocity,Float:{0.0,0.0,0.0})
  341. }
  342. pev(i,pev_origin,origin)
  343. origin[2] = origin2[2]
  344. entity_set_aim(ent,origin)
  345.  
  346. set_pev(ent,pev_nextthink,1.0)
  347. break;
  348. }
  349. }
  350. }
  351.  

_________________
[kozep]Kép
Kép[/kozep]


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 10 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