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

set_user_flags &


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
yagami
Senior Member
Join Date: Jan 2021
Old 08-04-2023 , 07:23   set_user_flags &
Reply With Quote #1

I am trying to give vip automatically to player more server now is crashing because


PHP Code:

public plugin_init()
{
    
register_plugin(PLUGINAUTHORVERSION)
    
    
xCvars[CVAR_TOP15_SHOW_AMOUNT] = create_cvar("csr_top15f_show_amount""10", .has_min true, .min_val 5.0, .has_max true, .max_val 15.0)
    
xCvars[CVAR_PRUNE] = create_cvar("csr_top15f_prune_days""0")    // Quanto Tempo ate rank reseta 
    
xCvars[CVAR_FULL_TO_SHOW] = create_cvar("csr_top15f_full_to_show""1"// Mostra Modt 
    
xCvars[CVAR_MIN_PLAYERS] = create_cvar("csr_top15f_min_players""0")    // Min players pra rank ser ativado 
    
xCvars[CVAR_VIP_PLAYER] = create_cvar("cx_vip_players""15")    // Quanto player no rank pode ser VIP 
    
xCvars[CVAR_FLAGS_GIVE] = create_cvar("cx_vip_flags_give""bs")    // Quanto player no rank pode ser VIP 
    

    
set_task(60.0"CheckPlayerRank", .flags "b")    
    
register_clcmd("amx_resetflag""xResetTop15")

    
xRegisterSay("topflag""xShowMotdTop")    
    
xRegisterSay("topflag""xShowMotdTop")
    
xRegisterSay("topb""xShowMotdTop")
    
xRegisterSay("pbtop""xShowMotdTop")
    
xRegisterSay("rankpb""xSkillTop")
    
xRegisterSay("rankb""xSkillTop")
    
xRegisterSay("pbrank""xSkillTop")
}

public 
client_putinserver(id)
{
    if(
is_user_admin(id))
        
isAdmin[id] = true

    isTop
[id] = false
    
    set_task
(4.0"CheckPlayerRank"id)

    
set_task(1.0"xSaveData"id__"b")
    
xLoadData(id)
}



public 
CheckPlayerRank(id)
{
    if(
is_user_admin(id))
        return 
PLUGIN_HANDLED    

    
new szFlags[20]
    new 
iStats[8], iBodyHits[8], szName[MAX_NAME_LENGTH]
    new 
iRank
    iRank 
get_user_stats(idiStatsiBodyHits)
    
get_user_name(idszNamecharsmax(szName))

    if(
<= iRank <= get_pcvar_num(CVAR_VIP_PLAYER))
    {
        if(!
isTop[id])
        {
            
get_pcvar_string(xCvars[CVAR_FLAGS_GIVE], szFlagscharsmax(szFlags))
            
remove_user_flags(idADMIN_USER)
            
isTop[id] = true
            client_print_color
(idprint_team_default"^4%s ^3Voce esta no TOP15 e ganhou o ^4Chat VIP"PREFIX_CHAT)
            
client_print_color(0print_team_default"^4%s ^3%s esta no TOP15 e ganhou o ^4Chat VIP"PREFIX_CHATszName)

            new 
iFlags read_flags(szFlags)
            
set_user_flags(idiFlags)
        }
        else 
        {
            if(
isTop[id])
            {
                
set_user_flags(id, -1)
                
set_user_flags(idADMIN_USER)
                
isTop[id]= false
                client_print_color
(idprint_team_default"^4%s ^3Voce saiu no TOP15 e ganhou o ^4Chat VIP"PREFIX_CHAT)
                
client_print_color(0print_team_default"^4%s ^3%s saiu no TOP15 e ganhou o ^4Chat VIP"PREFIX_CHATszName)
            }
        }
    }
    return 
PLUGIN_HANDLED

yagami is offline
bigdaddy424
Senior Member
Join Date: Oct 2021
Location: Jupiter
Old 08-04-2023 , 08:24   Re: set_user_flags &
Reply With Quote #2

Quote:
Originally Posted by yagami View Post
I am trying to give vip automatically to player more server now is crashing because


PHP Code:

public plugin_init()
{
    
register_plugin(PLUGINAUTHORVERSION)
    
    
xCvars[CVAR_TOP15_SHOW_AMOUNT] = create_cvar("csr_top15f_show_amount""10", .has_min true, .min_val 5.0, .has_max true, .max_val 15.0)
    
xCvars[CVAR_PRUNE] = create_cvar("csr_top15f_prune_days""0")    // Quanto Tempo ate rank reseta 
    
xCvars[CVAR_FULL_TO_SHOW] = create_cvar("csr_top15f_full_to_show""1"// Mostra Modt 
    
xCvars[CVAR_MIN_PLAYERS] = create_cvar("csr_top15f_min_players""0")    // Min players pra rank ser ativado 
    
xCvars[CVAR_VIP_PLAYER] = create_cvar("cx_vip_players""15")    // Quanto player no rank pode ser VIP 
    
xCvars[CVAR_FLAGS_GIVE] = create_cvar("cx_vip_flags_give""bs")    // Quanto player no rank pode ser VIP 
    

    
set_task(60.0"CheckPlayerRank", .flags "b")    
    
register_clcmd("amx_resetflag""xResetTop15")

    
xRegisterSay("topflag""xShowMotdTop")    
    
xRegisterSay("topflag""xShowMotdTop")
    
xRegisterSay("topb""xShowMotdTop")
    
xRegisterSay("pbtop""xShowMotdTop")
    
xRegisterSay("rankpb""xSkillTop")
    
xRegisterSay("rankb""xSkillTop")
    
xRegisterSay("pbrank""xSkillTop")
}

public 
client_putinserver(id)
{
    if(
is_user_admin(id))
        
isAdmin[id] = true

    isTop
[id] = false
    
    set_task
(4.0"CheckPlayerRank"id)

    
set_task(1.0"xSaveData"id__"b")
    
xLoadData(id)
}



public 
CheckPlayerRank(id)
{
    if(
is_user_admin(id))
        return 
PLUGIN_HANDLED    

    
new szFlags[20]
    new 
iStats[8], iBodyHits[8], szName[MAX_NAME_LENGTH]
    new 
iRank
    iRank 
get_user_stats(idiStatsiBodyHits)
    
get_user_name(idszNamecharsmax(szName))

    if(
<= iRank <= get_pcvar_num(CVAR_VIP_PLAYER))
    {
        if(!
isTop[id])
        {
            
get_pcvar_string(xCvars[CVAR_FLAGS_GIVE], szFlagscharsmax(szFlags))
            
remove_user_flags(idADMIN_USER)
            
isTop[id] = true
            client_print_color
(idprint_team_default"^4%s ^3Voce esta no TOP15 e ganhou o ^4Chat VIP"PREFIX_CHAT)
            
client_print_color(0print_team_default"^4%s ^3%s esta no TOP15 e ganhou o ^4Chat VIP"PREFIX_CHATszName)

            new 
iFlags read_flags(szFlags)
            
set_user_flags(idiFlags)
        }
        else 
        {
            if(
isTop[id])
            {
                
set_user_flags(id, -1)
                
set_user_flags(idADMIN_USER)
                
isTop[id]= false
                client_print_color
(idprint_team_default"^4%s ^3Voce saiu no TOP15 e ganhou o ^4Chat VIP"PREFIX_CHAT)
                
client_print_color(0print_team_default"^4%s ^3%s saiu no TOP15 e ganhou o ^4Chat VIP"PREFIX_CHATszName)
            }
        }
    }
    return 
PLUGIN_HANDLED

if(1 <= iRank <= get_pcvar_num(CVAR_VIP_PLAYER))
to
if(1 <= iRank <= get_pcvar_num(xCvars[CVAR_VIP_PLAYER]))
__________________
bigdaddy424 is offline
yagami
Senior Member
Join Date: Jan 2021
Old 08-04-2023 , 11:08   Re: set_user_flags &
Reply With Quote #3

Quote:
Originally Posted by bigdaddy424 View Post
if(1 <= iRank <= get_pcvar_num(CVAR_VIP_PLAYER))
to
if(1 <= iRank <= get_pcvar_num(xCvars[CVAR_VIP_PLAYER]))

Can someone explain to me why I am not able to give VIP to top player?

PHP Code:
#define LOG "log.log"

public plugin_init()
{
    
register_plugin(PLUGIN"AUTHOR""VERSION")
    
    
xCvars[CVAR_TOP15_SHOW_AMOUNT] = create_cvar("csr_top15f_show_amount""10", .has_min true, .min_val 5.0, .has_max true, .max_val 15.0)
    
xCvars[CVAR_PRUNE] = create_cvar("csr_top15f_prune_days""0")    // Quanto Tempo ate rank reseta 
    
xCvars[CVAR_FULL_TO_SHOW] = create_cvar("csr_top15f_full_to_show""0"// Mostra Modt 
    
xCvars[CVAR_MIN_PLAYERS] = create_cvar("csr_top15f_min_players""0")    // Min players pra rank ser ativado 
    
xCvars[CVAR_VIP_PLAYER] = create_cvar("cx_vip_players""15")    // Quanto player no rank pode ser VIP 
    
xCvars[CVAR_FLAGS_GIVE] = create_cvar("cx_vip_flags_give""bst")    // Quanto player no rank pode ser VIP 
    

    
set_task(60.0"CheckPlayerRank", .flags "b")    
    
register_clcmd("amx_resetflag""xResetTop15")

    
xRegisterSay("topflag""xShowMotdTop")    
    
xRegisterSay("topflag""xShowMotdTop")
    
xRegisterSay("topb""xShowMotdTop")
    
xRegisterSay("pbtop""xShowMotdTop")
    
xRegisterSay("rankpb""xSkillTop")
    
xRegisterSay("rankb""xSkillTop")
    
xRegisterSay("pbrank""xSkillTop")
}

public 
CheckPlayerRank(id)
{
    if(
is_user_admin(id))
        return 
PLUGIN_HANDLED    

    
new szFlags[20]
    new 
iStats[8], iBodyHits[8], szName[MAX_NAME_LENGTH]
    new 
iRank
    iRank 
get_user_stats(idiStatsiBodyHits)
    
get_user_name(idszNamecharsmax(szName))

    if(
<= iRank <= get_pcvar_num(xCvars[CVAR_VIP_PLAYER]))
    {
        if(!
isTop[id])
        {

            
get_pcvar_string(xCvars[CVAR_FLAGS_GIVE], szFlagscharsmax(szFlags))
            
remove_user_flags(idADMIN_USER)
            
isTop[id] = true
            client_print_color
(idprint_team_default"^4%s ^3Voce esta no TOP15 e ganhou o ^4 chat VIP"PREFIX_CHAT)
            
client_print_color(0print_team_default"^4%s ^3%s esta no TOP15 e ganhou o ^4Chat VIP"PREFIX_CHATszName)
            
log_to_file(LOG"My flags are now %d"get_user_flags(id) )

            new 
iFlags read_flags(szFlags)
            
set_user_flags(idiFlags)
        }
        else 
        {
            if(
isTop[id])
            {
                new 
iFlags read_flags(szFlags)
                
set_user_flags(idiFlags)
                
set_user_flags(idADMIN_USER)
                
remove_user_flags(idiFlags)
                
isTop[id]= false
                client_print_color
(idprint_team_default"^4%s ^3Voce saiu no TOP15 e ganhou o ^4 chat VIP"PREFIX_CHAT)
                
client_print_color(0print_team_default"^4%s ^3%s saiu no TOP15 e ganhou o ^4Chat VIP"PREFIX_CHATszName)
                
log_to_file(LOG"My flags are now %d"get_user_flags(id) )

            }
        }
    }
    return 
PLUGIN_HANDLED


Last edited by yagami; 08-04-2023 at 11:13. Reason: error
yagami is offline
lexzor
Veteran Member
Join Date: Nov 2020
Old 08-04-2023 , 13:01   Re: set_user_flags &
Reply With Quote #4

first of all, don't assume you are "giving vip". you should assuming you are settings some flags, maybe the vip plugin it's using a bool var like bIsVIP[id] that is true or false after the user is connected and even if you change the flags the user won't have vip

Code:
#include <amxmodx> #include <amxmisc> #define LOG "log.log" enum _:CVARS {     CVAR_VIP_PLAYER,     CVAR_FLAGS_GIVE[12] } new xCvars[CVARS] new bool:g_bTop[MAX_PLAYERS + 1] public plugin_init() {     bind_pcvar_num(         create_cvar(             "cx_vip_players",             "15",             FCVAR_NONE,             "Quanto player no rank pode ser VIP"         ),         xCvars[CVAR_VIP_PLAYER]     )            bind_pcvar_string(         create_cvar(             "cx_vip_flags_give",             "bst",             FCVAR_NONE,             "Quanto player no rank pode ser VIP"         ),         xCvars[CVAR_FLAGS_GIVE],         charsmax(xCvars[CVAR_FLAGS_GIVE])     )        set_task(60.0, "CheckPlayerRank", .flags = "b") } public client_connect(id) {     g_bTop[id] = false } public CheckPlayerRank(id) {     if(is_user_admin(id))         return        new szFlags[20]     new iStats[8], iBodyHits[8], szName[MAX_NAME_LENGTH]     new iRank     new iPlayers[MAX_PLAYERS], iNum     get_players(iPlayers, iNum, "chi")     for(new i = 0, iPlayer; i < iNum; i++)     {         iPlayer = iPlayers[i]         if(!is_user_connected(iPlayer))             continue;         if(1 <= iRank <= xCvars[CVAR_VIP_PLAYER])         {             get_user_name(iPlayer, szName, charsmax(szName))                         if(!g_bTop[iPlayer])             {                 set_user_flags(iPlayer, read_flags(xCvars[CVAR_FLAGS_GIVE]))                 if(get_user_flags(iPlayer) & ADMIN_USER)                 {                     remove_user_flags(iPlayer, ADMIN_USER)                 }                                 server_print("Do %s have the flags? [%s]", szName,bool:(get_user_flags(iPlayer) & read_flags(szFlags)) ? "Yes" : "No")             }             else             {                 server_print("User %s is already top", szName)             }         }         iRank = get_user_stats(id, iStats, iBodyHits)     }     return }

you have to struggle your code to look clean
don't overhelm you with many functionalities from beginning, start with simpler things then add more functionalities


first of all, in that task you have to parse every player and decide if he's top

i'm not sure about this, but i think you can't remove user flags if he has only that flag
lexzor is offline
yagami
Senior Member
Join Date: Jan 2021
Old 08-04-2023 , 13:36   Re: set_user_flags & remove_user_flags & get_user_flags
Reply With Quote #5

Quote:
Originally Posted by lexzor View Post
first of all, don't assume you are "giving vip". you should assuming you are settings some flags, maybe the vip plugin it's using a bool var like bIsVIP[id] that is true or false after the user is connected and even if you change the flags the user won't have vip

Code:
#include <amxmodx> #include <amxmisc> #define LOG "log.log" enum _:CVARS {     CVAR_VIP_PLAYER,     CVAR_FLAGS_GIVE[12] } new xCvars[CVARS] new bool:g_bTop[MAX_PLAYERS + 1] public plugin_init() {     bind_pcvar_num(         create_cvar(             "cx_vip_players",             "15",             FCVAR_NONE,             "Quanto player no rank pode ser VIP"         ),         xCvars[CVAR_VIP_PLAYER]     )            bind_pcvar_string(         create_cvar(             "cx_vip_flags_give",             "bst",             FCVAR_NONE,             "Quanto player no rank pode ser VIP"         ),         xCvars[CVAR_FLAGS_GIVE],         charsmax(xCvars[CVAR_FLAGS_GIVE])     )        set_task(60.0, "CheckPlayerRank", .flags = "b") } public client_connect(id) {     g_bTop[id] = false } public CheckPlayerRank(id) {     if(is_user_admin(id))         return        new szFlags[20]     new iStats[8], iBodyHits[8], szName[MAX_NAME_LENGTH]     new iRank     new iPlayers[MAX_PLAYERS], iNum     get_players(iPlayers, iNum, "chi")     for(new i = 0, iPlayer; i < iNum; i++)     {         iPlayer = iPlayers[i]         if(!is_user_connected(iPlayer))             continue;         if(1 <= iRank <= xCvars[CVAR_VIP_PLAYER])         {             get_user_name(iPlayer, szName, charsmax(szName))                         if(!g_bTop[iPlayer])             {                 set_user_flags(iPlayer, read_flags(xCvars[CVAR_FLAGS_GIVE]))                 if(get_user_flags(iPlayer) & ADMIN_USER)                 {                     remove_user_flags(iPlayer, ADMIN_USER)                 }                                 server_print("Do %s have the flags? [%s]", szName,bool:(get_user_flags(iPlayer) & read_flags(szFlags)) ? "Yes" : "No")             }             else             {                 server_print("User %s is already top", szName)             }         }         iRank = get_user_stats(id, iStats, iBodyHits)     }     return }

you have to struggle your code to look clean
don't overhelm you with many functionalities from beginning, start with simpler things then add more functionalities


first of all, in that task you have to parse every player and decide if he's top

i'm not sure about this, but i think you can't remove user flags if he has only that flag
Everything kind of stopped working now, I'm not getting serve_print because rank was reset but since there's only me on the server shouldn't it appear that I'm in the top 1?
client_connect = client_putinserver?

For some reason it stopped saving, when I exit and return to the server the flag is not being saved.



PHP Code:
enum _:xFvaultData
{
    
xAuthId[64],
    
xDataTop[128]
}

enum _:PlayerData
{
    
pl_szAuthid[MAX_AUTHID_LENGTH],
}

enum _:xMaxCvars
{
    
CVAR_LIST_RANK_TYPE,
    
CVAR_TOP15_SHOW_AMOUNT,
    
CVAR_MOTD_CSS,
    
CVAR_PRUNE,
    
CVAR_PREFIXCHAT,
    
CVAR_FULL_TO_SHOW,
    
CVAR_MIN_PLAYERS,
    
CVAR_VIP_PLAYER,
    
CVAR_FLAGS_GIVE[12]
}

new 
xCvars[xMaxCvars]
new 
xFlagDelivery[33], xFlagCapturated[33], xFlagRecuperated[33], xMotd[2000],  Player[MAX_PLAYERS 1][PlayerData];
new 
bool:isTop[33], bool:isAdmin[33]
new 
szLeFlags[32]

new 
db_top15_data[] = "db_top15_flags"

public plugin_init()
{
    
register_plugin(PLUGINAUTHORVERSION)
    
    
xCvars[CVAR_TOP15_SHOW_AMOUNT] = create_cvar("csr_top15f_show_amount""10", .has_min true, .min_val 5.0, .has_max true, .max_val 15.0)
    
xCvars[CVAR_PRUNE] = create_cvar("csr_top15f_prune_days""0")            // Tempo Ate Rank Reseta 
    
xCvars[CVAR_FULL_TO_SHOW] = create_cvar("csr_top15f_full_to_show""0"// Shows MODT only complete  
    
xCvars[CVAR_MIN_PLAYERS] = create_cvar("csr_top15f_min_players""0")    // Minimum number of players for the ranking to be activated 
    
xCvars[CVAR_VIP_PLAYER] = create_cvar("cx_vip_players""15")            // How much player rank can be VIP 
    
xCvars[CVAR_FLAGS_GIVE] = create_cvar("cx_vip_flags_give""bst")        // Which VIP Flags do you receive 
    

    
set_task(60.0"CheckPlayerRank", .flags "b")    


    
register_clcmd("amx_resetflag""xResetTop15")

    
xRegisterSay("topflag""xShowMotdTop")    
    
xRegisterSay("topflag""xShowMotdTop")
    
xRegisterSay("topb""xShowMotdTop")
    
xRegisterSay("pbtop""xShowMotdTop")
    
xRegisterSay("rankpb""xSkillTop")
    
xRegisterSay("rankb""xSkillTop")
    
xRegisterSay("pbrank""xSkillTop")
}

public 
client_disconnected(id)
{

    
Player[id][pl_szAuthid][0] = 0;
    
xFlagDelivery[id] = false
    xFlagCapturated
[id] = false
    xFlagRecuperated
[id] = false

    xSaveData
(id);
}

public 
client_putinserver(id)
{
    if(
is_user_admin(id))
        
isAdmin[id] = true

    isTop
[id] = false

    
if(!Player[id][pl_szAuthid][0])
    {
        
set_task(1.5"client_putinserver"id);
    }
    
get_flags(get_user_flags(id), szLeFlagscharsmax(szLeFlags));
    
//server_print("Player (%d) Flags: %s", id, szLeFlags);/*skill issue*/
    
    
set_task(4.0"CheckPlayerRank"id)
    
set_task(1.0"xSaveData"id__"b")
    
xLoadData(id)
}

public 
client_authorized(id, const authid[])
{
    
copy(Player[id][pl_szAuthid], charsmax(Player[][pl_szAuthid]), authid);
}

public 
CheckPlayerRank(id)
{
    if(
is_user_admin(id))
        return    

    new 
szFlags[20]
    new 
iStats[8], iBodyHits[8], szName[MAX_NAME_LENGTH]
    new 
iRank

    
new iPlayers[MAX_PLAYERS], iNum
    get_players
(iPlayersiNum"chi")

    for(new 
0iPlayeriNumi++)
    {
        
iPlayer iPlayers[i]

        if(!
is_user_connected(iPlayer))
            continue;

        if(
<= iRank <= xCvars[CVAR_VIP_PLAYER])
        {
            
get_user_name(iPlayerszNamecharsmax(szName))
            
            if(!
isTop[iPlayer])
            {

                
set_user_flags(iPlayerread_flags(xCvars[CVAR_FLAGS_GIVE]))

                if(
get_user_flags(iPlayer) & ADMIN_USER)
                {
                    
remove_user_flags(iPlayerADMIN_USER)
                }
                
                
server_print("Do %s have the flags? [%s]"szName,bool:(get_user_flags(iPlayer) & read_flags(szFlags)) ? "Yes" "No")
            }
            else 
            {
                
server_print("User %s is already top"szName)
            }
        }

        
iRank get_user_stats(idiStatsiBodyHits)
    }

    return
}

public 
xNtvFilter(const name[], indextrap)
{
    if(!
trap)
        return 
PLUGIN_HANDLED
        
    
return PLUGIN_CONTINUE
}

public 
xSaveData(id)
{
    if(
get_playersnum(1) < get_pcvar_num(xCvars[CVAR_MIN_PLAYERS]) || is_user_alive(id))
        return 
PLUGIN_HANDLED

    
if(is_user_bot(id) || is_user_hltv(id) || !Player[id][pl_szAuthid][0]) return PLUGIN_HANDLED;
    {
        static 
xData[500], xUserName[32]
    
        
get_user_name(idxUserNamecharsmax(xUserName))

        
formatex(xDatacharsmax(xData), "%d %d %d ^"%s^""xFlagDelivery[id], xFlagRecuperated[id], xFlagCapturated[id], xUserName)
        
fvault_set_data(db_top15_dataPlayer[id][pl_szAuthid], xData
        
    }

    return 
PLUGIN_CONTINUE
}


public 
xLoadData(id)
{
    if(
is_user_bot(id) || is_user_hltv(id)) return PLUGIN_HANDLED;

    static 
xData[500]
    static 
xEnt[10], xRc[10], xCap[10], xIgnoreCase[32]


    if(
fvault_get_data(db_top15_dataPlayer[id][pl_szAuthid], xDatacharsmax(xData)))
    {
        
parse(xDataxEntcharsmax(xEnt), xRccharsmax(xRc), xCapcharsmax(xCap), xIgnoreCasecharsmax(xIgnoreCase))

        
xFlagDelivery[id] = str_to_num(xEnt)
        
xFlagRecuperated[id] = str_to_num(xRc)
        
xFlagCapturated[id] = str_to_num(xCap)
    }

    
set_task(35.0"xWarnTopPrune"id+TASKID_WARN_PRUNE__"a"2)

    
xSaveData(id)

    return 
PLUGIN_CONTINUE
}

public 
xSortData(Array:aArrayiItem1iItem2iData[], iDataSize)
{
    new 
Data1[xFvaultData]
    new 
Data2[xFvaultData]
    
    
ArrayGetArray(aArrayiItem1Data1)
    
ArrayGetArray(aArrayiItem2Data2)
    
    new 
iCount1iCount2xStrKillsxStrKills2

    
new xK[10]
    
parse(Data1[xDataTop], xKcharsmax(xK))

    
xStrKills str_to_num(xK)

    new 
xK2[10]
    
parse(Data2[xDataTop], xK2charsmax(xK2))

    
xStrKills2 str_to_num(xK2)

    
    
iCount1 xStrKills
    iCount2 
xStrKills2
    
    
return (iCount1 iCount2) ? -: ( (iCount1 iCount2) ? )
}

public 
xNtvGetUserPosTop(id)
{
    if(!
is_user_connected(id))
        return 
false

    
new Array:aKey ArrayCreate(35)
    new Array:
aData ArrayCreate(128)
    new Array:
aAll ArrayCreate(xFvaultData)
    
    
fvault_load(db_top15_dataaKeyaData)
    
    new 
iArraySize ArraySize(aKey)
    new 
Data[xFvaultData]

    new 
i
    
for(0iArraySizei++)
    {
        
ArrayGetString(aKeyiData[xAuthId], charsmax(Data[xAuthId]))
        
ArrayGetString(aDataiData[xDataTop], charsmax(Data[xDataTop]))
        
        
ArrayPushArray(aAllData)
    }
    
    
ArraySort(aAll"xSortData")

    new 
szAuthIdFromArray[64]

    static 
xGetAuth[64]
    
get_user_authid(idxGetAuthcharsmax(xGetAuth))

    new 
j
    
for(0iArraySizej++)
    {
        
ArrayGetString(aAlljszAuthIdFromArraycharsmax(szAuthIdFromArray))
        
        if(
equal(szAuthIdFromArrayxGetAuth))
            break;
    }
    
    
ArrayDestroy(aKey)
    
ArrayDestroy(aData)
    
ArrayDestroy(aAll)

    return 
j+1
}

public 
xNtvGetTotalTop()
{
    return 
fvault_size(db_top15_data)


Last edited by yagami; 08-04-2023 at 13:38. Reason: error
yagami is offline
lexzor
Veteran Member
Join Date: Nov 2020
Old 08-04-2023 , 15:16   Re: set_user_flags &
Reply With Quote #6

you could use get_stats2 at every player connect


you just copied paste my code didn't even tried to understand it

don't forget you are in scripting help section not requests section
lexzor is offline
yagami
Senior Member
Join Date: Jan 2021
Old 08-04-2023 , 15:43   Re: set_user_flags &
Reply With Quote #7

Quote:
Originally Posted by lexzor View Post
you could use get_stats2 at every player connect


you just copied paste my code didn't even tried to understand it

don't forget you are in scripting help section not requests section

I have already read, reread your entire code and did not understand I have already searched the entire forum for other similar plugins I have been trying this since 10 in the morning
yagami is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 08-05-2023 , 00:00   Re: set_user_flags & remove_user_flags & get_user_flags
Reply With Quote #8

Quote:
Originally Posted by yagami View Post
client_connect = client_putinserver?
No, these are two very different things that both happen during a normal, successful connection to the server. I think I remember there being a good post explaining the difference between client_connect(), client_putinserver(), client_authorized(), etc. You might search for that if you're needing to use any of these forwards.

One general concept is that if you need to do anything related to authentication (like using is_user_admin), it should be done AFTER client_authorized() has executed. It may also be the case that you need to make sure that particular code runs after client_putinserver() in which you'll need to make sure you account for both functions having been executed before running your code.
__________________
fysiks is online now
yagami
Senior Member
Join Date: Jan 2021
Old 08-05-2023 , 06:45   Re: set_user_flags &
Reply With Quote #9

Quote:
Originally Posted by lexzor View Post
you could use get_stats2 at every player connect


you just copied paste my code didn't even tried to understand it

don't forget you are in scripting help section not requests section

I tried my best since yesterday

PHP Code:
enum _:xFvaultData
{
    
xAuthId[64],
    
xDataTop[128]
}

enum _:PlayerData
{
    
pl_szAuthid[MAX_AUTHID_LENGTH],
}

enum _:xMaxCvars
{
    
CVAR_LIST_RANK_TYPE,
    
CVAR_TOP15_SHOW_AMOUNT,
    
CVAR_MOTD_CSS,
    
CVAR_PRUNE,
    
CVAR_PREFIXCHAT,
    
CVAR_FULL_TO_SHOW,
    
CVAR_MIN_PLAYERS,
    
CVAR_VIP_PLAYER,
    
CVAR_FLAGS_GIVE[12]
}

new 
xCvars[xMaxCvars]
new 
xFlagDelivery[33], xFlagCapturated[33], xFlagRecuperated[33], xMotd[2000],  Player[MAX_PLAYERS 1][PlayerData];
new 
bool:isTop[33], bool:isAdmin[33]
new 
szLeFlags[32]

new 
db_top15_data[] = "db_top15_flags"

public plugin_init()
{
    
register_plugin(PLUGINAUTHORVERSION)
    
    
xCvars[CVAR_TOP15_SHOW_AMOUNT] = create_cvar("csr_top15f_show_amount""10", .has_min true, .min_val 5.0, .has_max true, .max_val 15.0)
    
xCvars[CVAR_PRUNE] = create_cvar("csr_top15f_prune_days""0")            // Tempo Ate Rank Reseta 
    
xCvars[CVAR_FULL_TO_SHOW] = create_cvar("csr_top15f_full_to_show""0"// Shows MODT only complete  
    
xCvars[CVAR_MIN_PLAYERS] = create_cvar("csr_top15f_min_players""0")    // Minimum number of players for the ranking to be activated 
    
xCvars[CVAR_VIP_PLAYER] = create_cvar("cx_vip_players""15")            // How much player rank can be VIP 
    
xCvars[CVAR_FLAGS_GIVE] = create_cvar("cx_vip_flags_give""bst")        // Which VIP Flags do you receive 
    

    
set_task(60.0"CheckPlayerRank", .flags "b")    


    
register_clcmd("amx_resetflag""xResetTop15")

    
xRegisterSay("topflag""xShowMotdTop")    
    
xRegisterSay("topflag""xShowMotdTop")
    
xRegisterSay("topb""xShowMotdTop")
    
xRegisterSay("pbtop""xShowMotdTop")
    
xRegisterSay("rankpb""xSkillTop")
    
xRegisterSay("rankb""xSkillTop")
    
xRegisterSay("pbrank""xSkillTop")
}

public 
client_disconnected(id)
{

    
Player[id][pl_szAuthid][0] = 0;
    
xFlagDelivery[id] = false
    xFlagCapturated
[id] = false
    xFlagRecuperated
[id] = false

    xSaveData
(id);
}

public 
client_putinserver(id)
{
    if(
is_user_admin(id))
        
isAdmin[id] = true

    isTop
[id] = false

    
if(!Player[id][pl_szAuthid][0])
    {
        
set_task(1.5"client_putinserver"id);
    }
    
get_flags(get_user_flags(id), szLeFlagscharsmax(szLeFlags));
    
//server_print("Player (%d) Flags: %s", id, szLeFlags);/*skill issue*/
    
    
set_task(4.0"CheckPlayerRank"id)
    
set_task(1.0"xSaveData"id__"b")
    
xLoadData(id)
}

public 
client_authorized(id, const authid[])
{
    
copy(Player[id][pl_szAuthid], charsmax(Player[][pl_szAuthid]), authid);
}


public 
CheckPlayerRank(id)
{
    if(!
is_user_connected(id))
        return 
PLUGIN_HANDLED

    
// SET VIP ACESS
    
new szFlags[64
    
get_pcvar_string(xCvars[CVAR_FLAGS_GIVE], szFlags63)

    new 
g_Flag_ziFlag_Vip

    g_Flag_z 
read_flags("z")
    
remove_user_flags(idg_Flag_z)

    
iFlag_Vip read_flags(szFlags)
    
set_user_flags(idiFlag_Vip)

    new 
iStats[8], iBodyHits[8], iRankszName[MAX_NAME_LENGTH]
    
iRank get_user_stats(idiStatsiBodyHits)

    new 
iPlayers[MAX_PLAYERS], iNum
    get_players
(iPlayersiNum"chi")


    for(new 
0iPlayeriNumi++)
    {
        
iPlayer iPlayers[i]

        if(!
is_user_connected(iPlayer))
            continue;

        if(
<= iRank <= get_pcvar_num(xCvars[CVAR_VIP_PLAYER]))
        {
            
get_user_name(iPlayerszNamecharsmax(szName))

            if(!
g_bTop[iPlayer])

            if(
get_user_flags(iPlayer) & ADMIN_USER)
            {
                
remove_user_flags(iPlayerADMIN_USER)
            }
            
server_print("Do %s have the flags? [%s]"szName,bool:(get_user_flags(iPlayer) & read_flags(szFlags)) ? "Yes" "No")

        }
        else 
        {
            
server_print("User %s is already top"szName)
        }
    }
    return 
PLUGIN_HANDLED
}



Last edited by yagami; 08-05-2023 at 06:45.
yagami is offline
lexzor
Veteran Member
Join Date: Nov 2020
Old 08-05-2023 , 09:09   Re: set_user_flags &
Reply With Quote #10

Code:
#include <amxmodx> #include <amxmisc> #include <csstats> #define VIP_FLAG "bst" #define SET_FLAG(%0) (set_user_flags(%0, read_flags(VIP_FLAG))) #define REMOVE_FLAG(%1) (remove_user_flags(%1, read_flags(VIP_FLAG))) static const RANK_TO_RETRIEVE = 10 enum OBJECTIVES {     TOTAL_DEFUSIONS ,     BOMBS_DEFUSED,     BOMBS_PLANTED,     BOMB_EXPLOSIONS, } static const OBJECTIVES_NAMES[OBJECTIVES][] = {     "Total defusion:",     "Total bomb defused:",     "Total bomb planted:",     "Total bomb explosions:", } new bool:g_bIsVIP[MAX_PLAYERS + 1] public plugin_init() {     //start task     set_task(60.0, "FindPlayers", .flags = "b") } public FindPlayers() {     new     iRank = 0,             szAuthID[64],             iObjectives[STATSX_MAX_OBJECTIVE],             szOutput[192],             iLen     new  iPlayers[MAX_PLAYERS], iNum     get_players(iPlayers, iNum, "ch")     //remove flags for everyone     for(new i, iPlayer; i < iNum; i++)     {         iPlayer = iPlayers[i]             if(g_bIsVIP[iPlayer] && !is_user_admin(iPlayer))         {             server_print("User %n is not a VIP anymore", iPlayer)             g_bIsVIP[iPlayer] = false;                     REMOVE_FLAG(iPlayer)         }     }     //get stats by rank num and check if user is connected     do {         get_stats2(iRank, iObjectives, szAuthID, charsmax(szAuthID))         iLen = formatex(szOutput, charsmax(szOutput), "%i. %s ", iRank, szAuthID )         for(new OBJECTIVES:iObjNum = TOTAL_DEFUSIONS; iObjNum < OBJECTIVES; iObjNum++)         {             iLen += formatex(szOutput[iLen], charsmax(szOutput), ", %s %i", OBJECTIVES_NAMES[iObjNum], iObjectives[_:iObjNum])         }         server_print("%s", szOutput)         //check user func         CheckUser(szAuthID)                 iRank++     }     while (iRank <= RANK_TO_RETRIEVE) } CheckUser(const auth[]) {     new id = find_player_ex(FindPlayer_MatchAuthId, auth)     //if user is online, set flags     if(id && !is_user_admin(id))     {         SET_FLAG(id)         g_bIsVIP[id] = true         server_print("User %n is now a VIP!", id)     } } public client_connect(id) {     g_bIsVIP[id] = false }

next time post your code in a way people can actually compile it

nobody will spend time to resolve your code if you don't bother yourself to give a compilable version
lexzor 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 04:50.


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