HLMOD.HU Forrás Megtekintés - www.hlmod.hu
  1. #include <amxmodx>
  2. #include <amxmisc>
  3.  
  4. #define PLUGIN "Emoticons Displayer"
  5. #define VERSION "1.0"
  6. #define AUTHOR "Alka"
  7.  
  8. #define MAX_EMOTICONS 50
  9.  
  10. new const g_szSymbol[MAX_EMOTICONS][16];
  11. new const g_szSprite[MAX_EMOTICONS][32];
  12. new g_iSpirteIndex[MAX_EMOTICONS];
  13. new g_iNum;
  14.  
  15. public plugin_init() {
  16.  
  17. register_plugin(PLUGIN, VERSION, AUTHOR);
  18.  
  19. register_clcmd("say", "clcmdSay", -1, "");
  20. }
  21.  
  22. public plugin_precache()
  23. {
  24. new szFile[64];
  25. get_configsdir(szFile, sizeof szFile - 1);
  26.  
  27. add(szFile, sizeof szFile - 1, "/emoticons.ini");
  28.  
  29. if(!file_exists(szFile))
  30. write_file(szFile, "", -1);
  31.  
  32. new szBuffer[128], iLen, iLine;
  33.  
  34. while(read_file(szFile, iLine++, szBuffer, sizeof szBuffer - 1, iLen))
  35. {
  36. if(!iLen || szBuffer[0] == ';')
  37. continue;
  38.  
  39. parse(szBuffer, g_szSymbol[g_iNum], sizeof g_szSymbol[] - 1, g_szSprite[g_iNum], sizeof g_szSprite[] - 1);
  40.  
  41. g_iSpirteIndex[g_iNum] = precache_model(g_szSprite[g_iNum]);
  42.  
  43. g_iNum++;
  44.  
  45. if(g_iNum >= MAX_EMOTICONS)
  46. break;
  47. }
  48. }
  49.  
  50. public clcmdSay(id)
  51. {
  52. if(!is_user_alive(id))
  53. return;
  54.  
  55. static szArgs[128];
  56. read_args(szArgs, sizeof szArgs - 1);
  57.  
  58. for(new i = 0 ; i < sizeof(g_szSymbol) ; i++)
  59. {
  60. if(!g_szSymbol[i][0])
  61. continue;
  62.  
  63. if(containi(szArgs, g_szSymbol[i]) != -1)
  64. {
  65. util_p_killattachment(id);
  66. util_p_attach(id, g_iSpirteIndex[i], 5);
  67. }
  68. }
  69. }
  70.  
  71. stock util_p_killattachment(index)
  72. {
  73. if(!is_user_connected(index))
  74. return;
  75.  
  76. message_begin(MSG_ALL, SVC_TEMPENTITY)
  77. write_byte(TE_KILLPLAYERATTACHMENTS);
  78. write_byte(index);
  79. message_end();
  80. }
  81.  
  82. stock util_p_attach(index, iSprite, iHoldTime)
  83. {
  84. if(!is_user_connected(index))
  85. return;
  86.  
  87. message_begin(MSG_ALL, SVC_TEMPENTITY);
  88. write_byte(TE_PLAYERATTACHMENT);
  89. write_byte(index);
  90. write_coord(60);
  91. write_short(iSprite);
  92. write_short(iHoldTime * 10);
  93. message_end();
  94. }
  95.