talkstyle.inc 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. #include <YSI_Coding\y_hooks>
  2. static TalkStyle[MAX_PLAYERS];
  3. static Timer:ChatTimer[MAX_PLAYERS];
  4. timer OnPlayerStopsChatting[2000](playerid)
  5. {
  6. ApplyAnimation(playerid, "CARRY", "crry_prtial", 4.0, 0, 0, 0, 0, 0, 1);
  7. }
  8. hook OnPlayerConnect(playerid)
  9. {
  10. TalkStyle[playerid] = 0;
  11. }
  12. hook OnPlayerText(playerid, text[])
  13. {
  14. StartChatting(playerid, strlen(text) * 100);
  15. }
  16. StartChatting(playerid, length)
  17. {
  18. if(!IsPlayerDoingAnimation(playerid))
  19. {
  20. switch(TalkStyle[playerid])
  21. {
  22. case 0: ApplyAnimation(playerid, "PED", "IDLE_CHAT", 4.0, 1, 0, 0, 1, 1);
  23. case 1: ApplyAnimation(playerid, "GANGS", "prtial_gngtlkA", 4.0, 1, 0, 0, 1, 1);
  24. case 2: ApplyAnimation(playerid, "GANGS", "prtial_gngtlkB", 4.0, 1, 0, 0, 1, 1);
  25. case 3: ApplyAnimation(playerid, "GANGS", "prtial_gngtlkC", 4.0, 1, 0, 0, 1, 1);
  26. case 4: ApplyAnimation(playerid, "GANGS", "prtial_gngtlkD", 4.0, 1, 0, 0, 1, 1);
  27. case 5: ApplyAnimation(playerid, "GANGS", "prtial_gngtlkE", 4.0, 1, 0, 0, 1, 1);
  28. case 6: ApplyAnimation(playerid, "GANGS", "prtial_gngtlkF", 4.0, 1, 0, 0, 1, 1);
  29. case 7: ApplyAnimation(playerid, "GANGS", "prtial_gngtlkG", 4.0, 1, 0, 0, 1, 1);
  30. case 8: ApplyAnimation(playerid, "GANGS", "prtial_gngtlkH", 4.0, 1, 0, 0, 1, 1);
  31. }
  32. if(!Timer_IsRunning(ChatTimer[playerid]))
  33. {
  34. ChatTimer[playerid] = defer OnPlayerStopsChatting[length](playerid);
  35. }
  36. }
  37. }
  38. CMD:talkstyle(playerid, params[])
  39. {
  40. if(isnull(params) || !IsNumeric(params)) return SendSyntaxMessage(playerid, "/talkstyle (0-8)");
  41. new styleid = strval(params);
  42. if(!(0 <= styleid <= 9)) return SendErrorMessage(playerid, "Talking style ID must be between 0 and 8.");
  43. if(TalkStyle[playerid] == styleid) return SendErrorMessage(playerid, "You already have that talking style.");
  44. Player_SetTalkStyle(playerid, styleid, true);
  45. SendInfoMessage(playerid, "You have set a new talking style.");
  46. return 1;
  47. }
  48. stock Player_SetTalkStyle(playerid, styleid, bool:save)
  49. {
  50. TalkStyle[playerid] = styleid;
  51. if(save)
  52. {
  53. new query[64];
  54. mysql_format(MySQL_GetHandle(), query, sizeof(query), "UPDATE characters SET talk_style = %d WHERE id = %d", styleid, Character_GetSQLID(playerid));
  55. mysql_tquery(MySQL_GetHandle(), query);
  56. }
  57. }
  58. stock Player_GetTalkStyle(playerid)
  59. {
  60. return TalkStyle[playerid];
  61. }