Raised This Month: $51 Target: $400
 12% 

Hook Chat


Post New Thread Reply   
 
Thread Tools Display Modes
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 01-30-2024 , 23:33   Re: Hook Chat
Reply With Quote #11

I put quite a bit of effort into making quite simple instructions for you. Just follow the instructions and it will fix major issues with your plugin. AFTER doing those steps and re-testing, then you can add more code.

The latest version that you just posted has some serious mistakes that weren't there in your original code. The most abundant one is that you changed a most of the charsmax() to sizeof() which is completely wrong. When you are providing a function with the maximum string length for a variable, you must NOT use sizeof. You should use charsmax() for this.

The one correct change you made by when removing all the charsmax() functions was when you used strlen(sflags) in your for loop for the flag string.

You also removed a string variable that is required (szChatMessage in iHookSay()).

The least important change that you made was to randomly remove semicolons and add other random semicolons. This just makes it harder for me to investigate the functional changes that you've made.
__________________
fysiks is offline
yagami
Senior Member
Join Date: Jan 2021
Old 01-31-2024 , 11:58   Re: Hook Chat
Reply With Quote #12

Quote:
Originally Posted by fysiks View Post
I put quite a bit of effort into making quite simple instructions for you. Just follow the instructions and it will fix major issues with your plugin. AFTER doing those steps and re-testing, then you can add more code.

The latest version that you just posted has some serious mistakes that weren't there in your original code. The most abundant one is that you changed a most of the charsmax() to sizeof() which is completely wrong. When you are providing a function with the maximum string length for a variable, you must NOT use sizeof. You should use charsmax() for this.

The one correct change you made by when removing all the charsmax() functions was when you used strlen(sflags) in your for loop for the flag string.

You also removed a string variable that is required (szChatMessage in iHookSay()).

The least important change that you made was to randomly remove semicolons and add other random semicolons. This just makes it harder for me to investigate the functional changes that you've made.

PHP Code:
new 
    
iLine,
    
iLength,
    
iPre_Flags_Count,
    
iPre_IPs_Count,
    
iPre_Names_Count,
    
iPre_SteamIDs_Count;

new 
    
iText[128],
    
iPrefix[32],
    
iType[2],
    
iKey[32],
    
str_id[16],
    
temp_key[35],
    
playerPrefix[64],
    
configs_dir[64],
    
szChatMessage[190];

new 
    
Trie:iPre_IPs_Collect,
    
Trie:iPre_Names_Collect,
    
Trie:iPre_SteamIDs_Collect,
    
Trie:iPre_Flags_Collect,
    
Trie:client_prefix;


#define MAX_PREFIXES 30
#define FLAG_RELOADPREFIX ADMIN_CFG


public plugin_init()
{
    
register_clcmd("say_team""cmdTop")
    
register_clcmd("say_team /hs""menuStatsViewer1")

    
    
sz_saytext get_user_msgid ("SayText");
    
register_clcmd("say""iHookSay")
    
register_clcmd("say_team""iHookSayT")

    
iPre_IPs_Collect TrieCreate()
    
iPre_Names_Collect TrieCreate()
    
iPre_SteamIDs_Collect TrieCreate()
    
iPre_Flags_Collect TrieCreate()
    
client_prefix TrieCreate()

    
get_configsdir(configs_dircharsmax(configs_dir))
    
formatex(iFile_Prefixcharsmax(iFile_Prefix), "%s/admin_prefixes.ini"configs_dir)


    
xLoadPrefix(0)

    
g_iMaxPlayers get_maxplayers() + 1

}

public 
client_putinserver(id)
{
    
num_to_str(idstr_idcharsmax(str_id))
    
TrieSetString(client_prefixstr_id"")
    
xPutPrefix(id)
    
    if(!
g_eSetting[RANK_BOTS] && is_user_bot(id))
    {
        return  
    }

    
g_szAuthID[id][0] = EOS
    get_user_info
(id"*sid"g_szAuthID[id], charsmax(g_szAuthID[]))
    
formatex(g_szPlayerFile[id], charsmax(g_szPlayerFile[]), "%s/%s.txt"g_szSteamDatag_szAuthID[id])

    if(!
file_exists(g_szPlayerFile[id]))
    {
        
curl_save_player_info(idg_szPlayerFile[id], g_szAuthID[id])
    }
    else
    {
        
set_task(0.1"taskLoadStats"id)
    }

    
set_task(1.0"taskShowRank"id TASK_RANK, .flags "b")
    
set_task(0.1"taskShowHud",  id TASK_HUD,  .flags "b")

    
}

public 
client_putinserver(id)
{
    
    if(!
g_eSetting[RANK_BOTS] && is_user_bot(id))
    {
        return  
    }

    
g_szAuthID[id][0] = EOS
    get_user_info
(id"*sid"g_szAuthID[id], charsmax(g_szAuthID[]))
    
formatex(g_szPlayerFile[id], charsmax(g_szPlayerFile[]), "%s/%s.txt"g_szSteamDatag_szAuthID[id])

    if(!
file_exists(g_szPlayerFile[id]))
    {
        
curl_save_player_info(idg_szPlayerFile[id], g_szAuthID[id])
    }
    else
    {
        
set_task(0.1"taskLoadStats"id)
    }

    
set_task(1.0"taskShowRank"id TASK_RANK, .flags "b")
    
set_task(0.1"taskShowHud",  id TASK_HUD,  .flags "b")

    
num_to_str(idstr_idcharsmax(str_id))
    
TrieSetString(client_prefixstr_id"")
    
xPutPrefix(id)
    
}

public 
xLoadPrefix(id)
{
    if (!(
get_user_flags(id) & FLAG_RELOADPREFIX))
        return 
PLUGIN_HANDLED;

    
TrieClear(iPre_IPs_Collect);
    
TrieClear(iPre_Names_Collect);
    
TrieClear(iPre_SteamIDs_Collect);
    
TrieClear(iPre_Flags_Collect);

    
iLine 0;
    
iLength 0;
    
iPre_Flags_Count 0;
    
iPre_IPs_Count 0;
    
iPre_Names_Count 0;

    if (!
file_exists(iFile_Prefix))
        
set_fail_state("Arquivo admin_prefixes.ini nao encontrado.");

    while (
read_file(iFile_PrefixiLine++, iTextcharsmax(iText), iLength) && (iPre_IPs_Count iPre_Names_Count iPre_SteamIDs_Count iPre_Flags_Count) <= MAX_PREFIXES)
    {
        if (!
iText[0] || iText[0] == '^n' || iText[0] == ';' || (iText[0] == '/' && iText[1] == '/'))
            continue;

        
parse(iTextiTypecharsmax(iType), iKeycharsmax(iKey), iPrefixcharsmax(iPrefix));
        
trim(iPrefix);

        if (!
iType[0] || !iPrefix[0] || !iKey[0])
            continue;

        
replace_all(iPrefixcharsmax(iPrefix), "!g""^x04");
        
replace_all(iPrefixcharsmax(iPrefix), "!t""^x03");
        
replace_all(iPrefixcharsmax(iPrefix), "!y""^x01");

        switch (
iType[0])
        {
        case 
'f':
        {
            
iPre_Flags_Count++;
            
TrieSetString(iPre_Flags_CollectiKeyiPrefix);
        }
        case 
'i':
        {
            
iPre_IPs_Count++;
            
TrieSetString(iPre_IPs_CollectiKeyiPrefix);
        }
        case 
's':
        {
            
iPre_SteamIDs_Count++;
            
TrieSetString(iPre_SteamIDs_CollectiKeyiPrefix);
        }
        case 
'n':
        {
            
iPre_Names_Count++;
            
TrieSetString(iPre_Names_CollectiKeyiPrefix);
        }
        default:
            continue;
        }
    }

    for(new 
1<= g_iMaxPlayersi++)
    {
        
num_to_str(istr_idcharsmax(str_id))
        
TrieDeleteKey(client_prefixstr_id)
        
xPutPrefix(i)
    }

    return 
PLUGIN_HANDLED
}

public 
xPutPrefix(id)
{

    
num_to_str(idstr_idcharsmax(str_id));
    
TrieSetString(client_prefixstr_id"");

    new 
sflags[32], temp_flag[2]
    
get_flags(get_user_flags(id), sflagscharsmax(sflags));

    for(new 
0strlen(sflags); i++)
    {
        
formatex(temp_flagcharsmax(temp_flag), "%c"sflags[i]);

        if(
TrieGetString(iPre_Flags_Collecttemp_flagplayerPrefixcharsmax(playerPrefix)))
        {
            
TrieSetString(client_prefixstr_idplayerPrefix);
        }
    }

    
get_user_ip(idtemp_keycharsmax(temp_key), 1);

    if (
TrieGetString(iPre_IPs_Collecttemp_keyplayerPrefixcharsmax(playerPrefix)))
    {
        
TrieSetString(client_prefixstr_idplayerPrefix);
    }

    
get_user_authid(idtemp_keycharsmax(temp_key));

    if (
TrieGetString(iPre_SteamIDs_Collecttemp_keyplayerPrefixcharsmax(playerPrefix)))
    {
        
TrieSetString(client_prefixstr_idplayerPrefix);
    }

    
get_user_name(idtemp_keycharsmax(temp_key));

    if (
TrieGetString(iPre_Names_Collecttemp_keyplayerPrefixcharsmax(playerPrefix)))
    {
        
TrieSetString(client_prefixstr_idplayerPrefix);
    }

    return 
PLUGIN_HANDLED;
}

public 
iHookSay(id)
{
    
read_args(szChatMessagecharsmax(szChatMessage));
    
remove_quotes(szChatMessage); 
    
trim(szChatMessage);

    if(
equal(szChatMessage"") || !is_user_connected(id) || is_user_bot(id) || is_user_hltv(id) || check_say_characters(szChatMessage))
        return 
PLUGIN_HANDLED_MAIN;

    
num_to_str(idstr_idcharsmax(str_id))
        
    new 
szEstado[32]
    if(
is_user_alive(id)) szEstado ""
    
else szEstado "•MORTO• "

    
get_user_name(idg_szName[id], charsmax(g_szName[]));

    
replace_all(szChatMessagecharsmax(szChatMessage), "!g"""); // green
    
replace_all(szChatMessagecharsmax(szChatMessage), "!n"""); // normal
    
replace_all(szChatMessagecharsmax(szChatMessage), "!y"""); // normal
    
replace_all(szChatMessagecharsmax(szChatMessage), "!t"""); // team
    
replace_all(szChatMessagecharsmax(szChatMessage), "x04"""); // green
    
replace_all(szChatMessagecharsmax(szChatMessage), "x03"""); // normal
    
replace_all(szChatMessagecharsmax(szChatMessage), "x01"""); // normal

    
new eRank[RankInfo]
    
ArrayGetArray(g_aRanksg_pPlayerData[id][Level], eRank)

    new 
szClanTag[MAX_CLAN_TAG_LENGTH];
    
cm_get_user_clan_tag(idszClanTag);

    if(
playerPrefix[0])
    {
        
format(szChatMessagecharsmax(szChatMessage), "^1%s^4%s ^1» ^4%s ^1« ^3%s: ^4%s"szEstadoplayerPrefixeRank[RankName], g_szName[id], szChatMessage);

    }
    else 
    {
        
format(szChatMessagecharsmax(szChatMessage), "^1%s ^1» ^4%s ^1« ^3%s: ^1%s"szEstadoeRank[RankName], g_szName[id], szChatMessage);

    }    

    for (new 
1<= g_iMaxPlayersi++)
    {
        if (!
is_user_connected(i) || is_user_bot(i) || is_user_hltv(i))
            continue;

        
send_message(szChatMessageidi)

    }

    return 
PLUGIN_HANDLED_MAIN;


public 
iHookSayT(id)
{
    
read_args(szChatMessagecharsmax(szChatMessage));
    
remove_quotes(szChatMessage);
    
trim(szChatMessage);

    if (
equal(szChatMessage"") || !is_user_connected(id) || is_user_bot(id) || is_user_hltv(id) || check_say_characters(szChatMessage))
        return 
PLUGIN_HANDLED_MAIN;

    new 
szEstado[32];
    if (
is_user_alive(id))
        
szEstado "";
    else
        
szEstado "*MORTO*";


    
get_user_name(idg_szName[id], charsmax(g_szName[]));

    
replace_all(szChatMessagecharsmax(szChatMessage), "!g"""); // green
    
replace_all(szChatMessagecharsmax(szChatMessage), "!n"""); // normal
    
replace_all(szChatMessagecharsmax(szChatMessage), "!y"""); // normal
    
replace_all(szChatMessagecharsmax(szChatMessage), "!t"""); // team
    
replace_all(szChatMessagecharsmax(szChatMessage), "x04"""); // green
    
replace_all(szChatMessagecharsmax(szChatMessage), "x03"""); // normal
    
replace_all(szChatMessagecharsmax(szChatMessage), "x01"""); // normal

    
new eRank[RankInfo];
    
ArrayGetArray(g_aRanksg_pPlayerData[id][Level], eRank);

    new 
szClanTag[MAX_CLAN_TAG_LENGTH];

    new 
TeamName:iPlayerTeam rg_get_user_team(id)

    new 
szTeamInfo[32];
    if (
iPlayerTeam == TEAM_TERRORIST)
        
copy(szTeamInfocharsmax(szTeamInfo), "(T)");
    else if(
iPlayerTeam == TEAM_CT)
        
copy(szTeamInfocharsmax(szTeamInfo), "(CT)")
    

    if (!
cm_get_user_clan_tag(idszClanTag))
    {
        if(
playerPrefix[0])
        {
            
format(szChatMessagecharsmax(szChatMessage), "^1%s^1%s ^4%s ^1» ^4%s ^1« ^3%s: ^4%s"szTeamInfoszEstadoplayerPrefixeRank[RankName], g_szName[id], szChatMessage);
        }
        else 
        {
            
format(szChatMessagecharsmax(szChatMessage), "^1%s^1%s ^1» ^4%s ^1« ^3%s: ^1%s"szTeamInfoszEstadoeRank[RankName], g_szName[id], szChatMessage);
        }
        
    }
    else
    {
        if(
playerPrefix[0])
        {
            
format(szChatMessagecharsmax(szChatMessage), "^1%s^1%s ^4%s ^4[%s] ^1» ^4%s ^1« ^3%s: ^4%s "szTeamInfoszEstadoplayerPrefixszClanTageRank[RankName], g_szName[id], szChatMessage);
        }
        else 
        {
            
format(szChatMessagecharsmax(szChatMessage), "^1%s^1%s ^4[%s] ^1» ^4%s ^1« ^3%s: ^1%s "szTeamInfoszEstadoszClanTageRank[RankName], g_szName[id], szChatMessage);
        }
        
    }

    for (new 
1<= g_iMaxPlayersi++)
    {
        if (!
is_user_connected(i) || is_user_bot(i) || is_user_hltv(i))
            continue;

        
send_message(szChatMessageidi)
    }

    return 
PLUGIN_HANDLED_MAIN;
}

send_message(const message[], const id, const i)
{
    
message_begin(MSG_ONEsz_saytext, {000}, i)
    
write_byte(id)
    
write_string(message)
    
message_end()

I tried several times to do what you recommended, but every time I kept crashing the server in some way, so I didn't want to come back every time to ask what was going on, so I thought, well, I'll try to do it here the way I know how,

I realized that I was commenting some errors
inside
PHP Code:
if(!cm_get_user_clan_tag(idszClanTag))// ^1%s^1%s ^4%s ^1» ^4%s ^1« ^3%s: ^1%s
    
{
        if(
playerPrefix[0])
        {
            
format(szChatMessagecharsmax(szChatMessage), "^1%s^4%s ^1» ^4%s ^1« ^3%s: ^4%s"szEstadoplayerPrefixeRank[RankName], g_szName[id], szChatMessage);

        }
        else 
        {
            
format(szChatMessagecharsmax(szChatMessage), "^1%s^4%s ^1» ^4%s ^1« ^3%s: ^1%s"szEstadoplayerPrefixeRank[RankName], g_szName[id], szChatMessage);

        }    
    }
    else
    {
        if(
playerPrefix[0])
        {
            
format(szChatMessagecharsmax(szChatMessage), "^1%s^4%s ^4[%s] ^1» ^4%s ^1« ^3%s: ^4%s"szEstadoplayerPrefixszClanTageRank[RankName], g_szName[id], szChatMessage);

        }
        else 
        {
            
format(szChatMessagecharsmax(szChatMessage), "^1%s^4%s ^4[%s] ^1» ^4%s ^1« ^3%s: ^1%s"szEstadoplayerPrefixszClanTageRank[RankName], g_szName[id], szChatMessage);

        } 
    } 
I was using playerPrefix even if player didn't have the prefix
inside the else I was using playerPrefix

So I changed everything and tried again, but it's still going wrong.
yagami is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 01-31-2024 , 22:25   Re: Hook Chat
Reply With Quote #13

Quote:
Originally Posted by yagami View Post
I tried several times to do what you recommended, but every time I kept crashing the server in some way, so I didn't want to come back every time to ask what was going on
That's why the forum is here. To help you learn. I can't fully test every little thing that I'm telling you because you didn't provide the entire plugin.

Quote:
Originally Posted by yagami View Post
so I thought, well, I'll try to do it here the way I know how,
You're posting on the forums because you don't know how. That's why the forums are here, to help you learn.

Quote:
Originally Posted by yagami View Post
but it's still going wrong.
Statements like this are extremely unhelpful. How can we tell if you are getting compile errors or you're getting run-time erorrs or you're getting full on crashes of the server from this statement?

I still contend that we should go back to your original post and my original instructions. Ask questions on what you don't understand about my instructions. It's not a bad thing to ask questions, that's what these forums are for, to help you learn what you don't know. You are still making significant basic mistakes that would be resolved by my instructions.

I'm not trying to be mean in all of this, I'm simply trying to help you learn to write your own code. I don't generally do all the work for you (that's what the Suggestion/Requests section is for) but even if I wanted to, you have not provided the entire plugin so I can't even test my changes (though I'm confident that they are fundamentally correct).

In summary, go back to the original code and implement my changes. Either post your attempt to follow my instructions or ask specific questions about the instructions themselves. When you do post, it would be beneficial if you post the entire plugin code.
__________________

Last edited by fysiks; 01-31-2024 at 22:30.
fysiks is offline
yagami
Senior Member
Join Date: Jan 2021
Old 02-01-2024 , 15:17   Re: Hook Chat
Reply With Quote #14

Quote:
Originally Posted by fysiks View Post
That's why the forum is here. To help you learn. I can't fully test every little thing that I'm telling you because you didn't provide the entire plugin.



You're posting on the forums because you don't know how. That's why the forums are here, to help you learn.



Statements like this are extremely unhelpful. How can we tell if you are getting compile errors or you're getting run-time erorrs or you're getting full on crashes of the server from this statement?

I still contend that we should go back to your original post and my original instructions. Ask questions on what you don't understand about my instructions. It's not a bad thing to ask questions, that's what these forums are for, to help you learn what you don't know. You are still making significant basic mistakes that would be resolved by my instructions.

I'm not trying to be mean in all of this, I'm simply trying to help you learn to write your own code. I don't generally do all the work for you (that's what the Suggestion/Requests section is for) but even if I wanted to, you have not provided the entire plugin so I can't even test my changes (though I'm confident that they are fundamentally correct).

In summary, go back to the original code and implement my changes. Either post your attempt to follow my instructions or ask specific questions about the instructions themselves. When you do post, it would be beneficial if you post the entire plugin code.

Plugins in one piece, if you can help me please try to understand what's going on.
Attached Files
File Type: sma Get Plugin or Get Source (rank_system_ultimate.sma - 5 views - 101.7 KB)

Last edited by yagami; 02-01-2024 at 16:58.
yagami is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 02-01-2024 , 22:16   Re: Hook Chat
Reply With Quote #15

You have all of the code commented out . . . Is this part of the code not actually related to this full plugin? It appears like this code that you're working on has nothing to do with the plugin you just posted. That is, you just added wholly unrelated code to this plugin which seems to imply that you can just make the prefix code its own plugin. Is that true? Is there any actual reason why you need to add that code to this plugin?

If this new code does not use any variables of the rank_system_ultimate plugin then just create a new plugin with just the prefix code. Even if you do use some variable from the larger plugin, I would actually recommend that you create a separate plugin anyways for testing purposes which can help you develop and debug this particular logic more easily.

When you do this (create a separate plugin), go through the steps I created in my original post. The only code that I'm expecting to see next is the code with the changes I've described.
__________________
fysiks is offline
yagami
Senior Member
Join Date: Jan 2021
Old 02-02-2024 , 04:29   Re: Hook Chat
Reply With Quote #16

Quote:
Originally Posted by fysiks View Post
You have all of the code commented out . . . Is this part of the code not actually related to this full plugin? It appears like this code that you're working on has nothing to do with the plugin you just posted. That is, you just added wholly unrelated code to this plugin which seems to imply that you can just make the prefix code its own plugin. Is that true? Is there any actual reason why you need to add that code to this plugin?

If this new code does not use any variables of the rank_system_ultimate plugin then just create a new plugin with just the prefix code. Even if you do use some variable from the larger plugin, I would actually recommend that you create a separate plugin anyways for testing purposes which can help you develop and debug this particular logic more easily.

When you do this (create a separate plugin), go through the steps I created in my original post. The only code that I'm expecting to see next is the code with the changes I've described.
This is the plugin I'm using, I commented because I was testing AdminPrefixes
Plugin Name: Admin Prefixes
Plugin Author: m0skVi4a ;]

Because I tried to copy everything from it to see if it worked and the chat was duplicating so I commented code because chat was duplicated



With Admin Prefixes it worked perfectly without any error, I was trying to find out why it was giving bugs but it's the same plugin
yagami is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 02-02-2024 , 21:16   Re: Hook Chat
Reply With Quote #17

Wow, you've made this whole ordeal very confusing. So, you don't need any help any more because you're able to use the "Admin Prefixes" plugin, right?
__________________
fysiks is offline
yagami
Senior Member
Join Date: Jan 2021
Old 02-03-2024 , 14:02   Re: Hook Chat
Reply With Quote #18

Quote:
Originally Posted by fysiks View Post
Wow, you've made this whole ordeal very confusing. So, you don't need any help any more because you're able to use the "Admin Prefixes" plugin, right?
I still need it because I wanted to implement this within the ranking instead of using prefix outside of it
yagami is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 02-03-2024 , 14:31   Re: Hook Chat
Reply With Quote #19

Why? What variables or information from the rank plugin do you want/need in you prefix logic? If you do need something from the rank plugin, we can likely just use the rank plugin's API to get that information.
__________________

Last edited by fysiks; 02-03-2024 at 14:34.
fysiks is offline
yagami
Senior Member
Join Date: Jan 2021
Old 02-03-2024 , 21:32   Re: Hook Chat
Reply With Quote #20

Quote:
Originally Posted by fysiks View Post
Why? What variables or information from the rank plugin do you want/need in you prefix logic? If you do need something from the rank plugin, we can likely just use the rank plugin's API to get that information.
I wanted to use only the basic plugins, so I wanted to put prefix into the ranking system now, leaving everything ready
yagami is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 03:28.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode