Resolved GAG problem with prefixes.

Coding Help/Re-API Supported
neverminddw
Member
Member
Posts: 32
Joined: 2 Years Ago
Has thanked: 0
Been thanked: 2 times
Contact:

GAG problem with prefixes.

#1

Post by neverminddw » 2 Months Ago

I have a plugin of prefixes. Works perfectly except that gag doesn't work. You can gag someone, but he will still be able to write.

Here's the code:
  1. #include <amxmodx>
  2. #include <cstrike>
  3.  
  4. // Prefixes
  5. new const szOwnerPrefix[] = "^1[^4Owner^1]", szHeadPrefix[] = "^1[^4Head Admin^1]", szAdminPrefix[] = "^1[^4Admin^1]"
  6.  
  7. new g_iMaxPlayers, g_iSayText
  8. new g_pCvarLogMessages
  9.  
  10. public plugin_init()
  11. {
  12.     register_plugin("Prefixes", "2.0", "alKapone")
  13.    
  14.     register_clcmd("say", "Hook_Say")
  15.     register_clcmd("say_team", "Hook_SayTeam")
  16.    
  17.     g_pCvarLogMessages = register_cvar("rgc_log_messages", "1")
  18.    
  19.     g_iMaxPlayers = get_maxplayers()
  20.     g_iSayText = get_user_msgid("SayText")
  21.    
  22.     register_message(g_iSayText, "BlockDoubleMessages")
  23. }
  24.  
  25. public BlockDoubleMessages()
  26. {
  27.     return PLUGIN_HANDLED
  28. }
  29.  
  30. public Hook_Say(id)
  31. {
  32.     if (!is_user_connected(id))
  33.         return PLUGIN_CONTINUE
  34.    
  35.     new szName[32], szMessage[200]
  36.     get_user_name(id, szName, charsmax(szName))
  37.     read_args(szMessage, charsmax(szMessage))
  38.     remove_quotes(szMessage)
  39.     trim(szMessage)
  40.    
  41.     for(new iChar = 0; iChar <= charsmax(szMessage); iChar++)
  42.     {
  43.         if (szMessage[iChar] == '^2' || szMessage[iChar] == '^3' || szMessage[iChar] == '^4')
  44.             szMessage[iChar] = '^1'
  45.     }
  46.  
  47.     if (!is_valid_msg(szMessage))
  48.         return PLUGIN_CONTINUE
  49.    
  50.     // Message format
  51.     if (is_user_alive(id) && (get_user_flags(id) & ADMIN_RCON) && (get_user_flags(id) & ADMIN_CVAR)) // Owner alive
  52.         format(szMessage, charsmax(szMessage), "%s ^3%s ^1: ^1%s", szOwnerPrefix, szName, szMessage)
  53.     else if (!is_user_alive(id) && (get_user_flags(id) & ADMIN_RCON) && (get_user_flags(id) & ADMIN_CVAR)) // Owner dead
  54.         format(szMessage, charsmax(szMessage), "^1*DEAD* %s ^3%s ^1: ^1%s", szOwnerPrefix, szName, szMessage)
  55.     else if (is_user_alive(id) && (get_user_flags(id) & ADMIN_CVAR) && (get_user_flags(id) & ADMIN_KICK)) // Head alive
  56.         format(szMessage, charsmax(szMessage), "%s ^3%s ^1: ^1%s", szHeadPrefix, szName, szMessage)
  57.     else if (!is_user_alive(id) && (get_user_flags(id) & ADMIN_CVAR) && (get_user_flags(id) & ADMIN_KICK)) // Head dead
  58.         format(szMessage, charsmax(szMessage), "^1*DEAD* %s ^3%s ^1: ^1%s", szHeadPrefix, szName, szMessage)
  59.     else if (is_user_alive(id) && (get_user_flags(id) & ADMIN_KICK))
  60.         format(szMessage, charsmax(szMessage), "%s ^3%s ^1: ^1%s", szAdminPrefix, szName, szMessage)
  61.     else if (!is_user_alive(id) && (get_user_flags(id) & ADMIN_KICK))
  62.         format(szMessage, charsmax(szMessage), "^1*DEAD* %s ^3%s ^1: ^1%s", szAdminPrefix, szName, szMessage)
  63.     else if (is_user_alive(id)) // Alive
  64.         format(szMessage, charsmax(szMessage), "^3%s ^1: ^1%s", szName, szMessage)
  65.     else if (!is_user_alive(id)) // Dead
  66.         format(szMessage, charsmax(szMessage), "^1*DEAD* ^3%s ^1: ^1%s", szName, szMessage)
  67.  
  68.     // Send the message
  69.     for (new i = 1; i <= g_iMaxPlayers; i++)
  70.     {
  71.         if (!is_user_connected(i))
  72.             continue
  73.  
  74.         Send_Message(szMessage, id, i)
  75.     }
  76.    
  77.     // Log messages
  78.     if (get_pcvar_num(g_pCvarLogMessages))
  79.     {
  80.         new szSteamID[36], szIP[16]
  81.         get_user_authid(id, szSteamID, charsmax(szSteamID))
  82.         get_user_ip(id, szIP, charsmax(szIP), 1)
  83.         Log_Messages("[%s|%s|%s] %s", szName, szSteamID, szIP, szMessage)
  84.     }
  85.    
  86.     return PLUGIN_CONTINUE
  87. }
  88.  
  89. public Hook_SayTeam(id)
  90. {
  91.     if (!is_user_connected(id))
  92.         return PLUGIN_CONTINUE
  93.    
  94.     new szName[32], szMessage[200]
  95.     get_user_name(id, szName, charsmax(szName))
  96.     read_args(szMessage, charsmax(szMessage))
  97.     remove_quotes(szMessage)
  98.     trim(szMessage)
  99.    
  100.     for(new iChar = 0; iChar <= charsmax(szMessage); iChar++)
  101.     {
  102.         if (szMessage[iChar] == '^2' || szMessage[iChar] == '^3' || szMessage[iChar] == '^4')
  103.             szMessage[iChar] = '^1'
  104.     }
  105.  
  106.     if (!is_valid_msg(szMessage))
  107.         return PLUGIN_CONTINUE
  108.  
  109.     // Message format
  110.     if(is_user_alive(id) && get_user_team(id) == 2)
  111.         format(szMessage, charsmax(szMessage), "^1(Counter-Terrorist) ^3%s ^1: ^1%s", szName, szMessage)
  112.     else if (!is_user_alive(id) && get_user_team(id) == 2)
  113.         format(szMessage, charsmax(szMessage), "^1*DEAD* ^1(Counter-Terrorist) ^3%s ^1: ^1%s", szName, szMessage)
  114.     else if (is_user_alive(id) && get_user_team(id) == 1)
  115.         format(szMessage, charsmax(szMessage), "^1(Terrorist) ^3%s ^1: ^1%s", szName, szMessage)
  116.     else if (!is_user_alive(id) && get_user_team(id) == 1)
  117.         format(szMessage, charsmax(szMessage), "^1*DEAD* ^1(Terrorist) ^3%s ^1: ^1%s", szName, szMessage)
  118.  
  119.     // Send the message
  120.     for (new i = 1; i <= g_iMaxPlayers; i++)
  121.     {
  122.         if(!is_user_connected(i) || get_user_team(i) != get_user_team(id))
  123.             continue
  124.  
  125.         Send_Message(szMessage, id, i)
  126.     }
  127.  
  128.     // Log messages
  129.     if (get_pcvar_num(g_pCvarLogMessages))
  130.     {
  131.         new szSteamID[36], szIP[16]
  132.         get_user_authid(id, szSteamID, charsmax(szSteamID))
  133.         get_user_ip(id, szIP, charsmax(szIP), 1)
  134.         Log_Messages("[%s|%s|%s] %s", szName, szSteamID, szIP, szMessage)
  135.     }
  136.    
  137.     return PLUGIN_CONTINUE
  138. }
  139.  
  140. bool:is_valid_msg(const szMessage[])
  141. {
  142.     if (!strlen(szMessage) || szMessage[0] == '/' && szMessage[1] == 'r' && szMessage[2] == 's')
  143.         return false
  144.        
  145.     return true
  146. }
  147.  
  148. stock Log_Messages(const szMessage_Fmt[], any:...)
  149. {
  150.     static szMessage[256], szFileName[32], szDate[16]
  151.     vformat(szMessage, charsmax(szMessage), szMessage_Fmt, 2)
  152.     replace_all(szMessage, charsmax(szMessage), "^4", "")
  153.     replace_all(szMessage, charsmax(szMessage), "^1", "")
  154.     replace_all(szMessage, charsmax(szMessage), "^1", "")
  155.     replace_all(szMessage, charsmax(szMessage), "^3", "")
  156.     format_time(szDate, charsmax(szDate), "%d%m%Y")
  157.     formatex(szFileName, charsmax(szFileName), "RGC_Messages_%s.log", szDate)
  158.     log_to_file(szFileName, "%s", szMessage)
  159. }
  160.  
  161. stock Send_Message(const szMessage[], const id, const iIndex)
  162. {
  163.     message_begin(MSG_ONE, g_iSayText, {0, 0, 0}, iIndex)
  164.     write_byte(id)
  165.     write_string(szMessage)
  166.     message_end()
  167. }

User avatar
Mohamed Alaa
Mod Developer
Mod Developer
Egypt
Posts: 622
Joined: 2 Years Ago
Location: Egypt
Has thanked: 34 times
Been thanked: 48 times
Age: 19
Contact:

#2

Post by Mohamed Alaa » 2 Months Ago

Make sure your gag plugin comes before the prefix plugin.
Want your own mod edition? PM me.
Accepting web projects.
CS 1.6 hosting: powergamingtech.com

neverminddw
Member
Member
Posts: 32
Joined: 2 Years Ago
Has thanked: 0
Been thanked: 2 times
Contact:

#3

Post by neverminddw » 2 Months Ago

Mohamed Alaa wrote:
2 Months Ago
Make sure your gag plugin comes before the prefix plugin.
You mean?
amx_gag.amxx
...
...
...
prefixes.amxx
I tried, still same problem.

User avatar
Mohamed Alaa
Mod Developer
Mod Developer
Egypt
Posts: 622
Joined: 2 Years Ago
Location: Egypt
Has thanked: 34 times
Been thanked: 48 times
Age: 19
Contact:

#4

Post by Mohamed Alaa » 2 Months Ago

Provide your gag plugin.
Want your own mod edition? PM me.
Accepting web projects.
CS 1.6 hosting: powergamingtech.com


User avatar
Mohamed Alaa
Mod Developer
Mod Developer
Egypt
Posts: 622
Joined: 2 Years Ago
Location: Egypt
Has thanked: 34 times
Been thanked: 48 times
Age: 19
Contact:

#6

Post by Mohamed Alaa » 2 Months Ago

Try to re-compile your both plugins, i have tried both plugins and when someone was gagged, he wasn't able to talk.
Want your own mod edition? PM me.
Accepting web projects.
CS 1.6 hosting: powergamingtech.com

neverminddw
Member
Member
Posts: 32
Joined: 2 Years Ago
Has thanked: 0
Been thanked: 2 times
Contact:

#7

Post by neverminddw » 2 Months Ago

Do you mean putting both sources of prefixes and gag in 1? Making 1 plugin from both?
Because if you mean to recompile them as they are like that... I don't seem to understand why recompiling will solve the problem.

User avatar
Muhammet20
Veteran Member
Veteran Member
Syria
Posts: 399
Joined: 1 Year Ago
Location: Turkey
Has thanked: 36 times
Been thanked: 5 times
Age: 13
Contact:

#8

Post by Muhammet20 » 2 Months Ago

neverminddw wrote:
2 Months Ago
Do you mean putting both sources of prefixes and gag in 1? Making 1 plugin from both?
Because if you mean to recompile them as they are like that... I don't seem to understand why recompiling will solve the problem.
re-compile mean open it with AmxModX studio and press compile then replace the new compiled one with the new one(make it for the both)
not mean merge them in one plugin
.::Kaya Gaming || Never Give Up || Zombie Escape::. [Server is Under The Work]
https://kaya-gaming.ga/

I just believe in two things, First thing is who i see in the mirror, second thing is who i don't see in the sky.

neverminddw
Member
Member
Posts: 32
Joined: 2 Years Ago
Has thanked: 0
Been thanked: 2 times
Contact:

#9

Post by neverminddw » 2 Months Ago

I did that to both when I installed them. Lol...
Still same problem, the problem should be on my prefix plugin for sure, but nobody seems to be able and find what's wrong there.

User avatar
Muhammet20
Veteran Member
Veteran Member
Syria
Posts: 399
Joined: 1 Year Ago
Location: Turkey
Has thanked: 36 times
Been thanked: 5 times
Age: 13
Contact:

#10

Post by Muhammet20 » 2 Months Ago

neverminddw wrote:
2 Months Ago
I did that to both when I installed them. Lol...
Still same problem, the problem should be on my prefix plugin for sure, but nobody seems to be able and find what's wrong there.
i found a fix for you
but i cant post it cuz i exploring with phone
i will post it when turn my pc on

[ Post made via Android ]
.::Kaya Gaming || Never Give Up || Zombie Escape::. [Server is Under The Work]
https://kaya-gaming.ga/

I just believe in two things, First thing is who i see in the mirror, second thing is who i don't see in the sky.

Post Reply

Who is online

Users browsing this forum: No registered users and 4 guests