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

Is it posible to make such a thing?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
JuanitoAlimana
Senior Member
Join Date: Aug 2021
Old 04-22-2023 , 00:38   Is it posible to make such a thing?
Reply With Quote #1

Hi, I have a CS 1.6 server and we are using a rank system based on frags. Is there a way that, for example, a player that reaches 50,000 frags types /cash in the server chat and automatically gets vip access (i.e. "akm" flags in the users.ini file)?

I have always kwown that you have to "manually" add new users to the users.ini file, so I'm wondering if such a thing is possible.

Thanks!
JuanitoAlimana is offline
DruGzOG
Veteran Member
Join Date: Nov 2007
Location: Unknown
Old 04-22-2023 , 14:43   Re: Is it posible to make such a thing?
Reply With Quote #2

Yes it is possible
__________________
DruGzOG is offline
Send a message via AIM to DruGzOG
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 04-22-2023 , 17:27   Re: Is it posible to make such a thing?
Reply With Quote #3

You can avoid writing anything to users.ini by having your plugin itself handle the issuance of admin flags.

set_user_flags()
remove_user_flags()
__________________
Bugsy is offline
JuanitoAlimana
Senior Member
Join Date: Aug 2021
Old 04-22-2023 , 17:28   Re: Is it posible to make such a thing?
Reply With Quote #4

Well, since it's possible I'll leave the code here, I don't know if it's better to do such a thing internally in the same code or externally in another plugin.

The idea is that when the user reaches, let's say, 50,000 frags he can type /cash in chat an choose the prize from a menu like this:

Congrats! Choose your prize:
1-Skin
2-Vip

If he chooses "Skin" he gets the "n" flag in users.ini.
If he chooses "Vip" he gets the "akm" flags users.ini.

PHP Code:
/*

ChangeLog:

1.0 = Version inicial
2.0 = 
    * Correccion de errores
    * Cambio deathmsg por ham killed
    * Reescritura parcial de codigo
    * Soporte AMX 1.8.2 hasta 1.9.0
    * Cvar para activar/desactivar la modificacion del chat

*/

#include <amxmisc>
#include <hamsandwich>
#include <fakemeta>
#include <adv_vault>


#if AMXX_VERSION_NUM < 183
    #define client_disconnected client_disconnect

    #define print_team_default 0

    
stock client_print_color(indexfakevar, const input[], any:...)
    {
        
#pragma unused fakevar
        
static szMsg[191], g_iMsgSayText;
        if(!
g_iMsgSayTextg_iMsgSayText get_user_msgid("SayText");

        
vformat(szMsg190input3);

        
message_begin(index MSG_ONE_UNRELIABLE MSG_BROADCASTg_iMsgSayText, .player index);
        
write_byte(index index 33);
        
write_string(szMsg);
        
message_end();
    }
#endif


#define VERSION "2.0"

new const Web[] = "HTTPS://KIKIZON.XYZ/";      // Se Muestra en HUD
new const Prefijo[] = "^4[CS:GO] ^1";     // Prefijo en say
new const Sonido[] = "rango/up.wav";    // Sonido Rango UP
new const DataBase[] = "csgoranks";        // Nombre de la base de datos
new const CHAT_FLAG ADMIN_KICK;        // Acceso requerido para el chat de admins

enum _:DATA
{
    
NOMBRE[30],
    
FRAGS
}

new const 
Rangos[][DATA] =
{
    { 
"Sin Rango"100 },
    { 
"Silver I"200 },
    { 
"Silver II"300 },
    { 
"Silver III"500 },
    { 
"Silver IV"700 },
    { 
"Silver Elite"800 },
    { 
"Silver Elite Master"900 },
    { 
"Gold Nova I"1000 },
    { 
"Gold Nova II"1200 },
    { 
"Gold Nova III"1300 },
    { 
"Gold Nova Master"1400 },
    { 
"Master Guardian I",1500 },
    { 
"Master Guardian II"1700 },
    { 
"Master Guardian Elite"1800 },
    { 
"Distinguished Master Guardian"1900 },
    { 
"Legendary Eagle"2000 },
    { 
"Legendary Eagle Master"2100 },
    { 
"Supreme Master First Class"2200 },
    { 
"The Global Elite"2500 }
}

new 
g_rango[33], g_frags[33];
new 
SyncHUDg_maxplayersg_playername[33][32];

#define TASK_HUD 67521
#define ID_HUD (taskid - TASK_HUD)
#define is_valid_player(%0) is_user_connected(%0) || !is_user_bot(%0) || !is_user_hltv(%0)

new g_vaultg_iField_Rankg_iField_Frags;
new 
cvar_Hudcvar_knifex2cvar_hsx2cvar_hooksay;

public 
plugin_init()
{
    
register_plugin("Rangos CS:GO"VERSION"kikizon / HTTPS://KIKIZON.XYZ/");
    
    
RegisterHam(Ham_Killed"player""ham_PlayerKilledPost"true);
    
register_logevent("logevent_round_end"2"1=Round_End");
    
    
register_clcmd("say""message_saytext");
    
register_clcmd("say_team""message_sayteam");
    
    
cvar_Hud register_cvar("rangos_hud""1");             // 1 - Mostrar HUD | 0 - No Mostrar
    
cvar_knifex2 register_cvar("rangos_knifex2""1");    // 1 - x2 frags con knife | 0 - Ã‘O :v
    
cvar_hsx2 register_cvar("rangos_hsx2""1");            // 1 - x2 frags de HeadShot | 0 - Ã‘O :v
    
cvar_hooksay register_cvar("rangos_hooksay""1");    // 1 - Modifica el say | 0 Ã‘O :v
    
    
SyncHUD CreateHudSyncObj();
    
g_maxplayers get_maxplayers();
    
    
g_vault adv_vault_open(DataBasefalse);
    
g_iField_Rank adv_vault_register_field(g_vault"RANGOS");
    
g_iField_Frags adv_vault_register_field(g_vault"FRAGS");
    
adv_vault_init(g_vault);
}

public 
plugin_precache() 
{
    
precache_sound(Sonido);
}

public 
HUD(taskid)
{
    new 
id ID_HUD;
    
    if (!
is_user_alive(id))    
        
id pev(idpev_iuser2);
   
    if(
id != ID_HUD)
    {
        
set_hudmessage(2552552550.600.6716.01.0);
        
ShowSyncHudMsg(ID_HUDSyncHUD"Frags: %d  ||  Rango: %s"g_frags[id], Rangos[g_rango[id]][NOMBRE])
    }
    else
    {
        
set_hudmessage(025500.00.2016.01.0);

        if(
g_rango[id] == charsmax(Rangos))
        {
            
ShowSyncHudMsg(
            
ID_HUD,
            
SyncHUD,
            
"=======================^n\
            Frags: %d^n\
            Rango: %s^n\
            =======================^n\
            TIENES EL RANGO MAXIMO!!!^n\
            =======================^n\
            %s"
,
            
g_frags[id],
            
Rangos[g_rango[id]][NOMBRE],            
            
Web
            
);
        }
        else 
        {
            
ShowSyncHudMsg(
            
ID_HUD,
            
SyncHUD,
            
"=======================^n\
            Frags: %d^n\
            Rango: %s^n\
            =======================^n\
            Sig. Rango: %s^n\
            Frags Restantes: %d^n\
            =======================^n\
            %s"

            
g_frags[id],
            
Rangos[g_rango[id]][NOMBRE],
            
Rangos[g_rango[id]+1][NOMBRE],
            
Rangos[g_rango[id]][FRAGS] - g_frags[id],
            
Web
            
);
        }
    }
    
}

public 
client_putinserver(id)
{
    
get_user_name(idg_playername[id], 31);
    
g_rango[id] = g_frags[id] = 0;
    
    
Cargar(id);
    
    if(
get_pcvar_num(cvar_Hud)) 
        
set_task(1.0"HUD"id+TASK_HUD__"b");
}

public 
client_disconnected(id)
{
    if(
is_valid_player(id))
        
Guardar(id);
        
    
remove_task(id+TASK_HUD)
}

public 
logevent_round_end()
{
    static 
id;
    for(
id 1id <= g_maxplayers; ++id)
    {
        if(
is_valid_player(id))
            
Guardar(id);
    }
}

public 
ham_PlayerKilledPost(victimattackersg)
{
    if(!
is_user_connected(victim) || !is_user_connected(attacker) || !attacker || attacker == victim)
        return 
HAM_IGNORED;

    
SetFrags(attacker1);

    if(
get_pcvar_num(cvar_knifex2) == && get_user_weapon(attacker) == CSW_KNIFE)
        
SetFrags(attacker1);

    if(
get_pcvar_num(cvar_hsx2) == && get_pdata_int(victim755) == HIT_HEAD)
        
SetFrags(attacker1);

    return 
HAM_IGNORED;
}

SetFrags(indexfrags)
{
    
g_frags[index] += frags;

    static 
iRankiRank g_rango[index];
    while( 
g_frags[index] >= Rangos[g_rango[index]][FRAGS] && g_rango[index] < charsmax(Rangos))
        ++
g_rango[index];

    if(
iRank g_rango[index])
    {
        
client_print_color(indexprint_team_default"%s Felicidades subiste al rango: ^4%s"PrefijoRangos[g_rango[index]][NOMBRE]);
        
client_cmd(index"spk ^"%s^""Sonido);
    }
}

public 
message_saytext(id)
{
    if(!
get_pcvar_num(cvar_hooksay))    
        return 
PLUGIN_CONTINUE;

    static 
said[192]; read_args(saidcharsmax(said)); remove_quotes(said);
    
    if (
said[0] == '@' || said[0] == '%' || said[0] == '/' || said[0] == '.' || said[0] == '!' || equal (said""))
        return 
PLUGIN_HANDLED;

    if (!
ValidMessage(said1)) return PLUGIN_CONTINUE;
    
    static 
color[11], iteam[11];
    
get_user_team(id,color,charsmax(color));
    
    if(
get_user_flags(id) & CHAT_FLAG)
    {
        
format(saidcharsmax(said), "^x01%s^x04%s ^x03%s ^x01: ^x04%s",
        
is_user_alive(id) ? "" "[MUERTO]",
        
Rangos[g_rango[id]][NOMBRE],
        
g_playername[id],
        
said);
    }
    else
    {
        
format(saidcharsmax(said), "^x01%s^04%s ^x03%s ^x01: %s",
        
is_user_alive(id) ? "" "[MUERTO]",
        
Rangos[g_rango[id]][NOMBRE],
        
g_playername[id],
        
said);
    }
    
    for (
1<= g_maxplayersi++)
    {
        if (!
is_user_connected(i)) continue;
        
        if(
get_user_flags(i) & CHAT_FLAG || is_user_alive(id) && is_user_alive(i) || !is_user_alive(id) && !is_user_alive(i))
        {
            
get_user_team(iteamcharsmax(team));
            
changeTeamInfo(icolor);
            
writeMessage(isaid);
            
changeTeamInfo(iteam);
        }
    }

    return 
PLUGIN_HANDLED_MAIN;
}

public 
message_sayteam(id)
{
    if(!
get_pcvar_num(cvar_hooksay))    
        return 
PLUGIN_CONTINUE;

    static 
said[192]; read_args(saidcharsmax(said)); remove_quotes(said);
    
    if (
said[0] == '@' || said[0] == '%' || said[0] == '/' || said[0] == '.' || said[0] == '!' || equal (said""))
        return 
PLUGIN_HANDLED;

    if (!
ValidMessage(said1)) return PLUGIN_CONTINUE
    
    static 
playerTeamplayerTeamName[19]; playerTeam get_user_team(id);
    switch (
playerTeam)
    {
        case 
1copy (playerTeamName6"TE")
        case 
2copy (playerTeamName8"CT"
        default: 
copy (playerTeamName11"SPEC"
    }

    static 
color[11], iteam[11];
    
get_user_team(id,color,charsmax(color));

    if (
get_user_flags(id) & CHAT_FLAG)
    {
        
format(saidcharsmax(said), "^x01%s [ %s ] ^x04%s ^x03%s ^x01: ^x04%s",
        
is_user_alive(id) ? "" "[MUERTO]",
        
playerTeam,
        
Rangos[g_rango[id]],
        
g_playername[id],
        
said);
    }
    else
    {
        
format(saidcharsmax(said), "^x01%s [ %s ] ^04%s ^x03%s ^x01: %s",
        
is_user_alive(id) ? "" "[MUERTO]",
        
playerTeam,
        
Rangos[g_rango[id]],
        
g_playername[id],
        
said);
    }

    for (
1<= g_maxplayersi++)
    {
        if (!
is_user_connected(i)) continue;
        
        if (
get_user_team(i) == playerTeam || get_user_flags(i) & CHAT_FLAG)
        {
            if (
is_user_alive(id) && is_user_alive(i) || !is_user_alive(id) && !is_user_alive(i))
            {
                
get_user_team(iteamcharsmax(team));
                
changeTeamInfo(icolor);
                
writeMessage(isaid);
                
changeTeamInfo(iteam);
            }
        }
    }

    return 
PLUGIN_HANDLED_MAIN;
}

public 
changeTeamInfo(playerteam[])
{
    static 
g_msgTeamInfo;
    if(!
g_msgTeamInfog_msgTeamInfo get_user_msgid("TeamInfo");

    
message_begin(MSG_ONEg_msgTeamInfo_player);
    
write_byte(player);
    
write_string(team);
    
message_end();
}

public 
writeMessage(playermessage[])
{
    static 
g_msgSayText;
    if(!
g_msgSayTextg_msgSayText get_user_msgid("SayText");
    
    
message_begin(MSG_ONEg_msgSayText, {000}, player);
    
write_byte(player);
    
write_string(message);
    
message_end();
}

Guardar(id)
{    
    
adv_vault_set_start(g_vault);

    
adv_vault_set_field(g_vaultg_iField_Rankg_rango[id]);
    
adv_vault_set_field(g_vaultg_iField_Fragsg_frags[id]);
    
    
adv_vault_set_end(g_vault0g_playername[id]);
}

Cargar(id)
{
    if(!
adv_vault_get_prepare(g_vault_g_playername[id])) 
        return;
    
    
g_rango[id] = adv_vault_get_field(g_vaultg_iField_Rank);
    
g_frags[id] = adv_vault_get_field(g_vaultg_iField_Frags);


stock ValidMessage(text[], maxcount)
{
    static 
lenicountlen strlen(text);count 0;
    if (!
len) return false;
    
    for (
0leni++)
    {
        if (
text[i] != ' ')
        {
            
count++;
            if (
count >= maxcount) return true;
        }
    }
    return 
false;

Hopefully someone can help me and thanks!
JuanitoAlimana is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 04-22-2023 , 20:30   Re: Is it posible to make such a thing?
Reply With Quote #5

Not tested
PHP Code:
/*

ChangeLog:

1.0 = Version inicial
2.0 = 
    * Correccion de errores
    * Cambio deathmsg por ham killed
    * Reescritura parcial de codigo
    * Soporte AMX 1.8.2 hasta 1.9.0
    * Cvar para activar/desactivar la modificacion del chat

*/

#include <amxmisc>
#include <hamsandwich>
#include <fakemeta>
#include <adv_vault>


#if AMXX_VERSION_NUM < 183
    #define client_disconnected client_disconnect

    #define print_team_default 0

    
stock client_print_color(indexfakevar, const input[], any:...)
    {
        
#pragma unused fakevar
        
static szMsg[191], g_iMsgSayText;
        if(!
g_iMsgSayTextg_iMsgSayText get_user_msgid("SayText");

        
vformat(szMsg190input3);

        
message_begin(index MSG_ONE_UNRELIABLE MSG_BROADCASTg_iMsgSayText, .player index);
        
write_byte(index index 33);
        
write_string(szMsg);
        
message_end();
    }
#endif


#define VERSION "2.0"

new const Web[] = "HTTPS://KIKIZON.XYZ/";      // Se Muestra en HUD
new const Prefijo[] = "^4[CS:GO] ^1";     // Prefijo en say
new const Sonido[] = "rango/up.wav";    // Sonido Rango UP
new const DataBase[] = "csgoranks";        // Nombre de la base de datos
new const CHAT_FLAG ADMIN_KICK;        // Acceso requerido para el chat de admins

enum _:DATA
{
    
NOMBRE[30],
    
FRAGS
}

new const 
Rangos[][DATA] =
{
    { 
"Sin Rango"100 },
    { 
"Silver I"200 },
    { 
"Silver II"300 },
    { 
"Silver III"500 },
    { 
"Silver IV"700 },
    { 
"Silver Elite"800 },
    { 
"Silver Elite Master"900 },
    { 
"Gold Nova I"1000 },
    { 
"Gold Nova II"1200 },
    { 
"Gold Nova III"1300 },
    { 
"Gold Nova Master"1400 },
    { 
"Master Guardian I",1500 },
    { 
"Master Guardian II"1700 },
    { 
"Master Guardian Elite"1800 },
    { 
"Distinguished Master Guardian"1900 },
    { 
"Legendary Eagle"2000 },
    { 
"Legendary Eagle Master"2100 },
    { 
"Supreme Master First Class"2200 },
    { 
"The Global Elite"2500 }
}

new 
g_rango[33], g_frags[33];
new 
SyncHUDg_maxplayersg_playername[33][32];

#define TASK_HUD 67521
#define ID_HUD (taskid - TASK_HUD)
#define is_valid_player(%0) is_user_connected(%0) || !is_user_bot(%0) || !is_user_hltv(%0)

new g_vaultg_iField_Rankg_iField_Frags;
new 
cvar_Hudcvar_knifex2cvar_hsx2cvar_hooksay;

public 
plugin_init()
{
    
register_plugin("Rangos CS:GO"VERSION"kikizon / HTTPS://KIKIZON.XYZ/");
    
    
RegisterHam(Ham_Killed"player""ham_PlayerKilledPost"true);
    
register_logevent("logevent_round_end"2"1=Round_End");
    
    
register_clcmd("say""message_saytext");
    
register_clcmd("say_team""message_sayteam");
    
    
register_clcmd("say /cash""Cash");
    
register_clcmd("say_team /cash""Cash");    
    
    
cvar_Hud register_cvar("rangos_hud""1");             // 1 - Mostrar HUD | 0 - No Mostrar
    
cvar_knifex2 register_cvar("rangos_knifex2""1");    // 1 - x2 frags con knife | 0 - Ã‘O :v
    
cvar_hsx2 register_cvar("rangos_hsx2""1");            // 1 - x2 frags de HeadShot | 0 - Ã‘O :v
    
cvar_hooksay register_cvar("rangos_hooksay""1");    // 1 - Modifica el say | 0 Ã‘O :v
    
    
SyncHUD CreateHudSyncObj();
    
g_maxplayers get_maxplayers();
    
    
g_vault adv_vault_open(DataBasefalse);
    
g_iField_Rank adv_vault_register_field(g_vault"RANGOS");
    
g_iField_Frags adv_vault_register_field(g_vault"FRAGS");
    
adv_vault_init(g_vault);
}

public 
plugin_precache() 
{
    
precache_sound(Sonido);
}

public 
HUD(taskid)
{
    new 
id ID_HUD;
    
    if (!
is_user_alive(id))    
        
id pev(idpev_iuser2);
   
    if(
id != ID_HUD)
    {
        
set_hudmessage(2552552550.600.6716.01.0);
        
ShowSyncHudMsg(ID_HUDSyncHUD"Frags: %d  ||  Rango: %s"g_frags[id], Rangos[g_rango[id]][NOMBRE])
    }
    else
    {
        
set_hudmessage(025500.00.2016.01.0);

        if(
g_rango[id] == charsmax(Rangos))
        {
            
ShowSyncHudMsg(
            
ID_HUD,
            
SyncHUD,
            
"=======================^n\
            Frags: %d^n\
            Rango: %s^n\
            =======================^n\
            TIENES EL RANGO MAXIMO!!!^n\
            =======================^n\
            %s"
,
            
g_frags[id],
            
Rangos[g_rango[id]][NOMBRE],            
            
Web
            
);
        }
        else 
        {
            
ShowSyncHudMsg(
            
ID_HUD,
            
SyncHUD,
            
"=======================^n\
            Frags: %d^n\
            Rango: %s^n\
            =======================^n\
            Sig. Rango: %s^n\
            Frags Restantes: %d^n\
            =======================^n\
            %s"

            
g_frags[id],
            
Rangos[g_rango[id]][NOMBRE],
            
Rangos[g_rango[id]+1][NOMBRE],
            
Rangos[g_rango[id]][FRAGS] - g_frags[id],
            
Web
            
);
        }
    }
    
}

public 
client_putinserver(id)
{
    
get_user_name(idg_playername[id], 31);
    
g_rango[id] = g_frags[id] = 0;
    
    
Cargar(id);
    
    if(
get_pcvar_num(cvar_Hud)) 
        
set_task(1.0"HUD"id+TASK_HUD__"b");
}

public 
client_disconnected(id)
{
    if(
is_valid_player(id))
        
Guardar(id);
        
    
remove_task(id+TASK_HUD)
}

public 
logevent_round_end()
{
    static 
id;
    for(
id 1id <= g_maxplayers; ++id)
    {
        if(
is_valid_player(id))
            
Guardar(id);
    }
}

public 
ham_PlayerKilledPost(victimattackersg)
{
    if(!
is_user_connected(victim) || !is_user_connected(attacker) || !attacker || attacker == victim)
        return 
HAM_IGNORED;

    
SetFrags(attacker1);

    if(
get_pcvar_num(cvar_knifex2) == && get_user_weapon(attacker) == CSW_KNIFE)
        
SetFrags(attacker1);

    if(
get_pcvar_num(cvar_hsx2) == && get_pdata_int(victim755) == HIT_HEAD)
        
SetFrags(attacker1);

    return 
HAM_IGNORED;
}

SetFrags(indexfrags)
{
    
g_frags[index] += frags;

    static 
iRankiRank g_rango[index];
    while( 
g_frags[index] >= Rangos[g_rango[index]][FRAGS] && g_rango[index] < charsmax(Rangos))
        ++
g_rango[index];

    if(
iRank g_rango[index])
    {
        
client_print_color(indexprint_team_default"%s Felicidades subiste al rango: ^4%s"PrefijoRangos[g_rango[index]][NOMBRE]);
        
client_cmd(index"spk ^"%s^""Sonido);
    }
    
    if ( ( 
g_frags[index] >= 50000 ) && !( get_user_fragsindex ) & read_flags"akmn" ) ) )
    {
        
client_print_color(indexprint_team_default"Say /cash to choose a prize" );
    }
}

public 
Cashindex )
{
    if ( ( 
g_frags[index] >= 50000 ) && !( get_user_flagsindex ) & read_flags"akmn" ) ) )
    {
        new 
iMenu menu_create"Select Stuff" "SelectHandler" );
        
        
menu_additemiMenu "Skin" );
        
menu_additemiMenu "Vip" );
        
menu_displayindex iMenu );
    }
    else
    {
        if ( 
g_frags[index] < 50000 )
        {
            
client_print_color(indexprint_team_default"You do not have 50,000 frags" );
        }
        else
        {
            
client_print_color(indexprint_team_default"You already redeemed your prize" );
        }
    }
    
    return 
PLUGIN_HANDLED;
}

public 
SelectHandlerindex iMenu iItem )
{    
    switch ( 
iItem )
    {
        case 
MENU_EXIT:
        {
            
menu_destroyiMenu );
        }
        case 
0:
        {
            
set_user_flagsindex ADMIN_LEVEL_B );
            
client_print_color(indexprint_team_default"Skin has been awarded" );
        }
        case 
1
        {
            
set_user_flagsindex ADMIN_IMMUNITY ADMIN_PASSWORD ADMIN_LEVEL_A );    
            
client_print_color(indexprint_team_default"Vip has been awarded" );
        }
    }
}
        
public 
message_saytext(id)
{
    if(!
get_pcvar_num(cvar_hooksay))    
        return 
PLUGIN_CONTINUE;

    static 
said[192]; read_args(saidcharsmax(said)); remove_quotes(said);
    
    if (
said[0] == '@' || said[0] == '%' || said[0] == '/' || said[0] == '.' || said[0] == '!' || equal (said""))
        return 
PLUGIN_HANDLED;

    if (!
ValidMessage(said1)) return PLUGIN_CONTINUE;
    
    static 
color[11], iteam[11];
    
get_user_team(id,color,charsmax(color));
    
    if(
get_user_flags(id) & CHAT_FLAG)
    {
        
format(saidcharsmax(said), "^x01%s^x04%s ^x03%s ^x01: ^x04%s",
        
is_user_alive(id) ? "" "[MUERTO]",
        
Rangos[g_rango[id]][NOMBRE],
        
g_playername[id],
        
said);
    }
    else
    {
        
format(saidcharsmax(said), "^x01%s^04%s ^x03%s ^x01: %s",
        
is_user_alive(id) ? "" "[MUERTO]",
        
Rangos[g_rango[id]][NOMBRE],
        
g_playername[id],
        
said);
    }
    
    for (
1<= g_maxplayersi++)
    {
        if (!
is_user_connected(i)) continue;
        
        if(
get_user_flags(i) & CHAT_FLAG || is_user_alive(id) && is_user_alive(i) || !is_user_alive(id) && !is_user_alive(i))
        {
            
get_user_team(iteamcharsmax(team));
            
changeTeamInfo(icolor);
            
writeMessage(isaid);
            
changeTeamInfo(iteam);
        }
    }

    return 
PLUGIN_HANDLED_MAIN;
}

public 
message_sayteam(id)
{
    if(!
get_pcvar_num(cvar_hooksay))    
        return 
PLUGIN_CONTINUE;

    static 
said[192]; read_args(saidcharsmax(said)); remove_quotes(said);
    
    if (
said[0] == '@' || said[0] == '%' || said[0] == '/' || said[0] == '.' || said[0] == '!' || equal (said""))
        return 
PLUGIN_HANDLED;

    if (!
ValidMessage(said1)) return PLUGIN_CONTINUE
    
    static 
playerTeamplayerTeamName[19]; playerTeam get_user_team(id);
    switch (
playerTeam)
    {
        case 
1copy (playerTeamName6"TE")
        case 
2copy (playerTeamName8"CT"
        default: 
copy (playerTeamName11"SPEC"
    }

    static 
color[11], iteam[11];
    
get_user_team(id,color,charsmax(color));

    if (
get_user_flags(id) & CHAT_FLAG)
    {
        
format(saidcharsmax(said), "^x01%s [ %s ] ^x04%s ^x03%s ^x01: ^x04%s",
        
is_user_alive(id) ? "" "[MUERTO]",
        
playerTeam,
        
Rangos[g_rango[id]],
        
g_playername[id],
        
said);
    }
    else
    {
        
format(saidcharsmax(said), "^x01%s [ %s ] ^04%s ^x03%s ^x01: %s",
        
is_user_alive(id) ? "" "[MUERTO]",
        
playerTeam,
        
Rangos[g_rango[id]],
        
g_playername[id],
        
said);
    }

    for (
1<= g_maxplayersi++)
    {
        if (!
is_user_connected(i)) continue;
        
        if (
get_user_team(i) == playerTeam || get_user_flags(i) & CHAT_FLAG)
        {
            if (
is_user_alive(id) && is_user_alive(i) || !is_user_alive(id) && !is_user_alive(i))
            {
                
get_user_team(iteamcharsmax(team));
                
changeTeamInfo(icolor);
                
writeMessage(isaid);
                
changeTeamInfo(iteam);
            }
        }
    }

    return 
PLUGIN_HANDLED_MAIN;
}

public 
changeTeamInfo(playerteam[])
{
    static 
g_msgTeamInfo;
    if(!
g_msgTeamInfog_msgTeamInfo get_user_msgid("TeamInfo");

    
message_begin(MSG_ONEg_msgTeamInfo_player);
    
write_byte(player);
    
write_string(team);
    
message_end();
}

public 
writeMessage(playermessage[])
{
    static 
g_msgSayText;
    if(!
g_msgSayTextg_msgSayText get_user_msgid("SayText");
    
    
message_begin(MSG_ONEg_msgSayText, {000}, player);
    
write_byte(player);
    
write_string(message);
    
message_end();
}

Guardar(id)
{    
    
adv_vault_set_start(g_vault);

    
adv_vault_set_field(g_vaultg_iField_Rankg_rango[id]);
    
adv_vault_set_field(g_vaultg_iField_Fragsg_frags[id]);
    
    
adv_vault_set_end(g_vault0g_playername[id]);
}

Cargar(id)
{
    if(!
adv_vault_get_prepare(g_vault_g_playername[id])) 
        return;
    
    
g_rango[id] = adv_vault_get_field(g_vaultg_iField_Rank);
    
g_frags[id] = adv_vault_get_field(g_vaultg_iField_Frags);


stock ValidMessage(text[], maxcount)
{
    static 
lenicountlen strlen(text);count 0;
    if (!
len) return false;
    
    for (
0leni++)
    {
        if (
text[i] != ' ')
        {
            
count++;
            if (
count >= maxcount) return true;
        }
    }
    return 
false;

__________________
Bugsy is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 04-23-2023 , 00:24   Re: Is it posible to make such a thing?
Reply With Quote #6

FYI - This will not re-apply what was selected with /cash when they disconnect / re-connect. It can be done if needed.
__________________
Bugsy is offline
JuanitoAlimana
Senior Member
Join Date: Aug 2021
Old 04-23-2023 , 00:52   Re: Is it posible to make such a thing?
Reply With Quote #7

Please, it must be saved until I manually remove it from the users.ini file.
JuanitoAlimana is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 04-23-2023 , 01:09   Re: Is it posible to make such a thing?
Reply With Quote #8

This method doesn't use users.ini. Can it expire after a certain time frame?
__________________
Bugsy is offline
JuanitoAlimana
Senior Member
Join Date: Aug 2021
Old 04-23-2023 , 01:22   Re: Is it posible to make such a thing?
Reply With Quote #9

30 days if possible or whenever I reset the frags by deleting the adv_vault file (which is every 30 days).
JuanitoAlimana is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 04-23-2023 , 16:47   Re: Is it posible to make such a thing?
Reply With Quote #10

How are you saving data for individual players?

It looks to me that you are using a single vault record and it gets over-written each time a new player stores data. You should be using steam-id as the key so that each player has their own data saved.
PHP Code:
g_iField_Rank adv_vault_register_field(g_vault"RANGOS");
//...
g_rango[id] = adv_vault_get_field(g_vaultg_iField_Rank); 
__________________
Bugsy 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 11:53.


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