Advertisement
Guest User

Untitled

a guest
Nov 22nd, 2017
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.72 KB | None | 0 0
  1. #include <amxmodx>
  2. #include <fakemeta>
  3. #include <fakemeta_util>
  4. #include <hamsandwich>
  5.  
  6. #define PLUGIN "CSO Emotion"
  7. #define VERSION "2.3"
  8. #define AUTHOR "neX0n111"
  9.  
  10. #define EDIT "neX0n111"
  11. #define ADMIN "ADMIN_LEVEL_C"
  12.  
  13. #define MAX_EMOTION 6
  14. #define BUTTON_HOLDTIME 0.5
  15. #define USE_TYPE 1 // 1 = J Button (Cheer); 2 = Hold R Button
  16.  
  17. #define TASK_EMOTION 1962
  18. #define TASK_HOLDTIME 1963
  19.  
  20.  
  21. new const p_model[] = "models/cso_emotion/cso_emotion2.mdl"
  22. new const v_model[] = "models/cso_emotion/v_cso_emotion_v23.mdl"
  23. new const Resource_Sound[MAX_EMOTION][] =
  24. {
  25. "cso_emotion/man_angry.wav",
  26. "cso_emotion/man_dance.wav",
  27. "cso_emotion/man_hi.wav",
  28. "cso_emotion/man_joy.wav",
  29. "cso_emotion/man_procoke.wav",
  30. "cso_emotion/man_special.wav"
  31. }
  32.  
  33. new Emotion_Name[MAX_EMOTION][] =
  34. {
  35. "\rBULJKO \yPozdrav",
  36. "\yPROVOCIRAM kao \rLUD1",
  37. "\rUzivam kao \yTriglav",
  38. "\yLjut sam kao \r$R3D3R",
  39. "\rPlesem kao \yKINDZI",
  40. "\yJAK SAM KAO \rneX0n111"
  41. }
  42.  
  43. new Float:Emotion_Time[MAX_EMOTION] =
  44. {
  45. 3.0,
  46. 7.0,
  47. 4.5,
  48. 3.8,
  49. 6.7,
  50. 6.0
  51. }
  52.  
  53. enum
  54. {
  55. EMO_HI = 0,
  56. EMO_PROVOKE,
  57. EMO_JOY,
  58. EMO_ANGRY,
  59. EMO_DANCE,
  60. EMO_SPECIAL1
  61. }
  62.  
  63. new g_InDoingEmo[33], g_AnimEnt[33], g_AvtEnt[33], g_OldWeapon[33], g_OldKnifeModel[33][128]
  64. new g_MaxPlayers, g_HoldingButton[33], g_UseType
  65.  
  66. public plugin_init()
  67. {
  68. register_plugin(PLUGIN, VERSION, AUTHOR)
  69.  
  70. register_event("HLTV", "Event_NewRound", "a", "1=0", "2=0")
  71. register_event("DeathMsg", "Event_DeathMsg", "a")
  72.  
  73. register_forward(FM_CmdStart, "fw_CmdStart")
  74. register_forward(FM_AddToFullPack, "fw_AddToFullPack_Post", 1)
  75. register_forward(FM_Think, "fw_Think")
  76.  
  77. RegisterHam(Ham_Spawn, "player", "fw_PlayerSpawn_Post", 1)
  78.  
  79. g_UseType = USE_TYPE
  80. if(g_UseType == 1) register_clcmd("cheer", "Open_EmoMenu")
  81.  
  82. g_MaxPlayers = get_maxplayers()
  83. }
  84.  
  85. public plugin_precache()
  86. {
  87. engfunc(EngFunc_PrecacheModel, p_model)
  88. engfunc(EngFunc_PrecacheModel, v_model)
  89.  
  90. for(new i = 0; i < sizeof(Resource_Sound); i++)
  91. engfunc(EngFunc_PrecacheSound, Resource_Sound[i])
  92. }
  93.  
  94. public Event_NewRound()
  95. {
  96. for(new i = 0; i < g_MaxPlayers; i++)
  97. {
  98. if(!is_user_connected(i))
  99. continue
  100.  
  101. Reset_Var(i)
  102. }
  103. }
  104.  
  105. public Event_DeathMsg()
  106. {
  107. static Victim; Victim = read_data(2)
  108. Do_Reset_Emotion(Victim)
  109. }
  110.  
  111. public fw_PlayerSpawn_Post(id)
  112. {
  113. if(g_UseType == 1)
  114. client_printc(id, "!g[BULJKO Dance]!n Pritisni !g[J]!n Da korsitis !tDance!n")
  115. else if(g_UseType == 2)
  116. client_printc(id, "!g[BULJKO Dance]!n Pritisni !g[R]!n Da koristis !tDance!n")
  117. }
  118.  
  119. public Reset_Var(id)
  120. {
  121. if(!is_user_connected(id))
  122. return
  123.  
  124. if(g_InDoingEmo[id])
  125. {
  126. if(get_user_weapon(id) == CSW_KNIFE)
  127. set_pev(id, pev_viewmodel2, g_OldKnifeModel[id])
  128. }
  129.  
  130. if(task_exists(id+TASK_EMOTION)) remove_task(id+TASK_EMOTION)
  131.  
  132. Set_Entity_Invisible(id, 0)
  133.  
  134. if(pev_valid(g_AnimEnt[id])) engfunc(EngFunc_RemoveEntity, g_AnimEnt[id])
  135. if(pev_valid(g_AvtEnt[id])) engfunc(EngFunc_RemoveEntity, g_AvtEnt[id])
  136.  
  137. g_InDoingEmo[id] = 0
  138. g_AnimEnt[id] = g_AvtEnt[id] = 0
  139. g_HoldingButton[id] = 0
  140. }
  141.  
  142. public Open_EmoMenu2(id)
  143. {
  144. id -= TASK_HOLDTIME
  145. Open_EmoMenu(id)
  146. }
  147.  
  148. public Open_EmoMenu(id)
  149. {
  150. if(!is_user_alive(id))
  151. return
  152. if(g_InDoingEmo[id])
  153. return
  154.  
  155. static menu, NumberId[6]
  156. menu = menu_create("BULJKO Dance \yBy: \rneX0n111", "MenuHandle_Emo")
  157.  
  158. for(new i = 0; i < MAX_EMOTION; i++)
  159. {
  160. num_to_str(i, NumberId, sizeof(NumberId))
  161. menu_additem(menu, Emotion_Name[i], NumberId)
  162. }
  163.  
  164. menu_setprop(menu, MPROP_EXIT, MEXIT_ALL)
  165. menu_display(id, menu, 0)
  166. }
  167.  
  168. public MenuHandle_Emo(id, menu, item)
  169. {
  170. if(item == MENU_EXIT)
  171. {
  172. menu_destroy(menu)
  173. return
  174. }
  175. if(!is_user_alive(id))
  176. return
  177. if(g_InDoingEmo[id])
  178. return
  179.  
  180. static Data[6], Name[64], Access, Callback
  181. menu_item_getinfo(menu, item, Access, Data, charsmax(Data), Name, charsmax(Name), Callback)
  182.  
  183. static EmoId; EmoId = str_to_num(Data)
  184.  
  185. if(EmoId >= MAX_EMOTION)
  186. return
  187.  
  188. Set_Emotion_Start(id, EmoId)
  189. }
  190.  
  191. public Set_Emotion_Start(id, EmoId)
  192. {
  193. g_InDoingEmo[id] = 1
  194. Set_Entity_Invisible(id, 1)
  195.  
  196. Create_AvtEnt(id)
  197. Create_AnimEnt(id)
  198.  
  199. if(!Check_Avalible(id)) return
  200.  
  201. Do_Set_Emotion(id, EmoId)
  202. }
  203.  
  204. public Create_AvtEnt(id)
  205. {
  206. if(pev_valid(g_AvtEnt[id]))
  207. return
  208.  
  209. g_AvtEnt[id] = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "info_target"))
  210.  
  211. if(!pev_valid(g_AvtEnt[id]))
  212. return
  213.  
  214. static ent; ent = g_AvtEnt[id]
  215. set_pev(ent, pev_classname, "avatar")
  216. set_pev(ent, pev_owner, id)
  217. set_pev(ent, pev_movetype, MOVETYPE_FOLLOW)
  218. set_pev(ent, pev_solid, SOLID_NOT)
  219.  
  220. // Set Model
  221. static PlayerModel[64]
  222. fm_cs_get_user_model(id, PlayerModel, sizeof(PlayerModel))
  223.  
  224. format(PlayerModel, sizeof(PlayerModel), "models/player/%s/%s.mdl", PlayerModel, PlayerModel)
  225. engfunc(EngFunc_SetModel, g_AvtEnt[id], PlayerModel)
  226.  
  227. // Set Avatar
  228. set_pev(ent, pev_body, pev(id, pev_body))
  229. set_pev(ent, pev_skin, pev(id, pev_skin))
  230.  
  231. set_pev(ent, pev_renderamt, pev(id, pev_renderamt))
  232. static Float:Color[3]; pev(id, pev_rendercolor, Color)
  233. set_pev(ent, pev_rendercolor, Color)
  234. set_pev(ent, pev_renderfx, pev(id, pev_renderfx))
  235. set_pev(ent, pev_rendermode, pev(id, pev_rendermode))
  236.  
  237. Set_Entity_Invisible(ent, 0)
  238. }
  239.  
  240. public Create_AnimEnt(id)
  241. {
  242. if(pev_valid(g_AnimEnt[id]))
  243. return
  244.  
  245. g_AnimEnt[id] = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "info_target"))
  246.  
  247. if(!pev_valid(g_AnimEnt[id]))
  248. return
  249.  
  250. static ent; ent = g_AnimEnt[id]
  251. set_pev(ent, pev_classname, "AnimEnt")
  252. set_pev(ent, pev_owner, id)
  253. set_pev(ent, pev_movetype, MOVETYPE_TOSS)
  254.  
  255. engfunc(EngFunc_SetModel, ent, p_model)
  256. engfunc(EngFunc_SetSize, ent, {-16.0, -16.0, 0.0}, {16.0, 16.0, 72.0})
  257. set_pev(ent, pev_solid, SOLID_BBOX)
  258.  
  259. engfunc(EngFunc_DropToFloor, ent)
  260. Set_Entity_Invisible(ent, 0)
  261.  
  262. set_pev(ent, pev_nextthink, get_gametime() + 0.1)
  263. }
  264.  
  265. public Check_Avalible(id)
  266. {
  267. if(!pev_valid(g_AnimEnt[id]) || !pev_valid(g_AvtEnt[id]))
  268. {
  269. Do_Reset_Emotion(id)
  270. return 0
  271. }
  272.  
  273. return 1
  274. }
  275.  
  276. public Do_Set_Emotion(id, EmoId)
  277. {
  278. // Set Player Emotion
  279. static Float:Origin[3], Float:Angles[3], Float:Velocity[3]
  280.  
  281. pev(id, pev_origin, Origin); pev(id, pev_angles, Angles); pev(id, pev_velocity, Velocity)
  282.  
  283. Origin[2] -= 36.0
  284. set_pev(g_AnimEnt[id], pev_origin, Origin)
  285.  
  286. Angles[0] = 0.0; Angles[2] = 0.0
  287. set_pev(g_AnimEnt[id], pev_angles, Angles)
  288. set_pev(g_AnimEnt[id], pev_velocity, Velocity)
  289.  
  290. set_pev(g_AvtEnt[id], pev_aiment, g_AnimEnt[id])
  291. Set_Entity_Anim(g_AnimEnt[id], EmoId, 1)
  292.  
  293. // Set Hand Emotion
  294. g_OldWeapon[id] = get_user_weapon(id)
  295. fm_give_item(id, "weapon_knife")
  296. engclient_cmd(id, "weapon_knife")
  297.  
  298. pev(id, pev_viewmodel2, g_OldKnifeModel[id], 127)
  299. set_pev(id, pev_viewmodel2, v_model)
  300. Set_Weapon_Anim(id, EmoId)
  301.  
  302. static KnifeEnt; KnifeEnt = fm_get_user_weapon_entity(id, CSW_KNIFE)
  303. if(pev_valid(KnifeEnt)) set_pdata_float(KnifeEnt, 48, Emotion_Time[EmoId], 4)
  304.  
  305. if(task_exists(id+TASK_EMOTION)) remove_task(id+TASK_EMOTION)
  306. set_task(Emotion_Time[EmoId], "Reset_Emotion", id+TASK_EMOTION)
  307. }
  308.  
  309. public Reset_Emotion(id)
  310. {
  311. id -= TASK_EMOTION
  312.  
  313. if(!is_user_connected(id))
  314. return
  315. if(!g_InDoingEmo[id])
  316. return
  317.  
  318. Do_Reset_Emotion(id)
  319. }
  320.  
  321. public Do_Reset_Emotion(id)
  322. {
  323. if(!is_user_connected(id))
  324. return
  325. if(!g_InDoingEmo[id])
  326. return
  327.  
  328. if(task_exists(id+TASK_EMOTION)) remove_task(id+TASK_EMOTION)
  329. Set_Entity_Invisible(id, 0)
  330.  
  331. if(pev_valid(g_AnimEnt[id])) engfunc(EngFunc_RemoveEntity, g_AnimEnt[id])
  332. if(pev_valid(g_AvtEnt[id])) engfunc(EngFunc_RemoveEntity, g_AvtEnt[id])
  333.  
  334. g_AnimEnt[id] = g_AvtEnt[id] = 0
  335.  
  336. if(is_user_alive(id))
  337. {
  338. if(get_user_weapon(id) == CSW_KNIFE)
  339. set_pev(id, pev_viewmodel2, g_OldKnifeModel[id])
  340.  
  341. static MyOldWeapon; MyOldWeapon = g_OldWeapon[id]
  342. static Classname[64]; get_weaponname(MyOldWeapon, Classname, sizeof(Classname))
  343. engclient_cmd(id, Classname)
  344. }
  345.  
  346. g_InDoingEmo[id] = 0
  347. }
  348.  
  349. public fw_CmdStart(id, uc_handle, seed)
  350. {
  351. if(!is_user_alive(id))
  352. return
  353.  
  354.  
  355. if(!g_InDoingEmo[id] && g_UseType == 2)
  356. {
  357. static UseButton, UseOldButton
  358. UseButton = (get_uc(uc_handle, UC_Buttons) & IN_RELOAD)
  359. UseOldButton = (pev(id, pev_oldbuttons) & IN_RELOAD)
  360.  
  361. if(UseButton)
  362. {
  363. if(!UseOldButton && !g_InDoingEmo[id])
  364. {
  365. g_HoldingButton[id] = 1
  366. set_task(BUTTON_HOLDTIME, "Open_EmoMenu2", id+TASK_HOLDTIME)
  367. }
  368. } else {
  369. if(UseOldButton && g_HoldingButton[id])
  370. {
  371. if(task_exists(id+TASK_HOLDTIME))
  372. {
  373. remove_task(id+TASK_HOLDTIME)
  374. g_HoldingButton[id] = 0
  375. }
  376. }
  377. }
  378.  
  379. return
  380. }
  381.  
  382. static CurButton; CurButton = get_uc(uc_handle, UC_Buttons)
  383.  
  384. if((CurButton & IN_ATTACK) || (CurButton & IN_ATTACK2) || (CurButton & IN_DUCK) || (CurButton & IN_JUMP))
  385. {
  386. Do_Reset_Emotion(id)
  387. return
  388. }
  389.  
  390. static Float:Velocity[3], Float:Vector
  391. pev(id, pev_velocity, Velocity); Vector = vector_length(Velocity)
  392.  
  393. if(Vector != 0.0)
  394. {
  395. Do_Reset_Emotion(id)
  396. return
  397. }
  398.  
  399. /*
  400. if(get_user_weapon(id) != CSW_KNIFE)
  401. {
  402. Do_Reset_Emotion(id)
  403. return
  404. }*/
  405. }
  406.  
  407. public fw_AddToFullPack_Post(es_handle, e , ent, host, hostflags, player, pSet)
  408. {
  409. if(!is_user_alive(host) && !pev_valid(ent))
  410. return FMRES_IGNORED
  411. if(g_AnimEnt[host] != ent)
  412. return FMRES_IGNORED
  413.  
  414. set_es(es_handle, ES_Effects, get_es(es_handle, ES_Effects) | EF_NODRAW)
  415. return FMRES_IGNORED
  416. }
  417.  
  418. public fw_Think(ent)
  419. {
  420. if(!pev_valid(ent))
  421. return
  422.  
  423. static Classname[64]
  424. pev(ent, pev_classname, Classname, sizeof(Classname))
  425.  
  426. if(equal(Classname, "AnimEnt"))
  427. {
  428. static id; id = pev(ent, pev_owner)
  429. if(!is_user_alive(id))
  430. return
  431.  
  432. // Set Player Emotion
  433. static Float:Angles[3], Float:Angles2[3]
  434.  
  435. pev(id, pev_angles, Angles)
  436. pev(ent, pev_angles, Angles2)
  437.  
  438. Angles[0] = 0.0; Angles[2] = 0.0
  439.  
  440. if(Angles[1] != Angles2[1]) set_pev(ent, pev_angles, Angles)
  441. set_pev(ent, pev_nextthink, get_gametime() + 0.05)
  442.  
  443. if(pev(ent, pev_effects) == (pev(ent, pev_effects) | EF_NODRAW)) Set_Entity_Invisible(ent, 0)
  444. }
  445. }
  446.  
  447. stock fm_cs_get_user_model(id, Model[], Len)
  448. {
  449. if(!is_user_connected(id))
  450. return
  451.  
  452. engfunc(EngFunc_InfoKeyValue, engfunc(EngFunc_GetInfoKeyBuffer, id), "model", Model, Len)
  453. }
  454.  
  455. stock Set_Entity_Invisible(ent, Invisible = 1)
  456. {
  457. if(!pev_valid(ent))
  458. return
  459.  
  460. set_pev(ent, pev_effects, Invisible == 0 ? pev(ent, pev_effects) & ~EF_NODRAW : pev(ent, pev_effects) | EF_NODRAW)
  461. }
  462.  
  463. stock Set_Entity_Anim(ent, Anim, ResetFrame)
  464. {
  465. if(!pev_valid(ent))
  466. return
  467.  
  468. set_pev(ent, pev_animtime, get_gametime())
  469. set_pev(ent, pev_framerate, 1.0)
  470. set_pev(ent, pev_sequence, Anim)
  471. if(ResetFrame) set_pev(ent, pev_frame, 0)
  472. }
  473.  
  474.  
  475. stock Set_Weapon_Anim(id, Anim)
  476. {
  477. if(!is_user_alive(id))
  478. return
  479.  
  480. set_pev(id, pev_weaponanim, Anim)
  481.  
  482. message_begin(MSG_ONE_UNRELIABLE, SVC_WEAPONANIM, _, id)
  483. write_byte(Anim)
  484. write_byte(pev(id, pev_body))
  485. message_end()
  486. }
  487.  
  488. stock client_printc(index, const text[], any:...)
  489. {
  490. new szMsg[128];
  491. vformat(szMsg, sizeof(szMsg) - 1, text, 3);
  492.  
  493. replace_all(szMsg, sizeof(szMsg) - 1, "!g", "^x04");
  494. replace_all(szMsg, sizeof(szMsg) - 1, "!n", "^x01");
  495. replace_all(szMsg, sizeof(szMsg) - 1, "!t", "^x03");
  496.  
  497. if(index == 0)
  498. {
  499. for(new i = 0; i < g_MaxPlayers; i++)
  500. {
  501. if(!is_user_connected(i))
  502. continue
  503.  
  504. message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("SayText"), _, i)
  505. write_byte(i)
  506. write_string(szMsg)
  507. message_end()
  508. }
  509. } else {
  510. message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("SayText"), _, index);
  511. write_byte(index);
  512. write_string(szMsg);
  513. message_end();
  514. }
  515. }
  516. /* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
  517. *{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1033\\ f0\\ fs16 \n\\ par }
  518. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement