Raised This Month: $19 Target: $400
 4% 

[Req] XP system by name


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
morrow
Member
Join Date: Dec 2008
Old 03-29-2015 , 05:56   [Req] XP system by name
Reply With Quote #1

Can anyone help me with xp system plugin ?
I need to my gungame server kill counting.
Something like
1-99 kills = level 1
100-199= level 2
200-299=level 3
.....
And when you type in chat /level you will see in chat [GunGame XP] You have 56xp , Level 1 ... 44 xp to next level.
And when you type something in chat players see before your name your level name in green.
like: [Level 2] Player : hello world
And i want it saved in file or nvault and saved by nick , i have steam server, but in some reasons i want to saved by nickname...


Found somthing like this..
PHP Code:
/*     
    Īįłąķķīćī ņč ćīą ęņ ;)
*/
#include <amxmodx>
#include <amxmisc>
#include <colorchat>
#include <fun>
#include <cstrike>
#include <nvault>
#include <sqlx>
//
#define PLUGIN "Army Ranks"
#define VERSION "1.2fix-3"
#define AUTHOR "Arctic"
#pragma tabsize 0
#define ADM_MENU     ADMIN_IMMUNITY // menu access flag
//
new g_vault;
new 
Handle:g_SqlTuple;
new 
g_Error[512]; 
enum _:PlData
{
    
gId,gExp,gLevel,gTempKey
};
new 
UserData[33][PlData];
new 
gMessage[256];
new 
g_MsgHud,MaxPlayers,levelUp[33],gSayText;
new 
bool:restr_blocked;
new const 
gRankNames[][] = 
{
    
"I_0","I_1","I_2","I_3","I_4","I_5","I_6","I_7","I_8","I_9","I_10","I_11","I_12","I_13","I_14",        
    
"I_15","I_16","I_17","I_18","I_19","I_20"
};
new const 
gLevels[] = 
{
    
0,15,30,60,100,180,350,750,999,1500,2200,2800,3200,3900,4500,5000,5500,6000,7000,8000
};
new const 
gNades[][] =
{
    {
0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},
    {
0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1},
    {
0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1}
}
new const 
restrict_bonus[][] =
{
    
"35hp",
    
"most_wanted",
    
"ka_wintershank"
};
new 
gRestrictMaps,gAdminGMsg,gBonusLevel,gFlash,gSmoke,gHe,gHpbylevel,gApbylevel,
gHideRadar,gArmyChat,gSaveType,gTableName,gHost,gUser,gPassword,gDbName,gSlash,
gTk,gLostXpTk,gLevelUpmsg,gAllChat//,gDeleteNullRow;
//
public plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR);
    
register_cvar("army_ranks",VERSIONFCVAR_SERVER FCVAR_SPONLY);
    
set_cvar_string("army_ranks",VERSION);
//
    
gRestrictMaps     register_cvar"restrict_maps",         "0");// āźė ēąļņ įīķńīā ķą źąņ.    
    
gBonusLevel    register_cvar"level_bonus",         "0");// āźė īęč ļč ļīėķčč īāķ˙.
    
gFlash        register_cvar"flash_nades",         "0");// āźė įīķńą ōėųź
    
gSmoke        register_cvar"smoke_nades",         "1");// āźė įīķńą ūģīāū
    
gHe        register_cvar"he_nades",         "1");// āźė įīķńą īńźīėīķū
    
gHpbylevel    register_cvar"hp_by_level",         "3");// źīė-āī ļ, źīņīī ąņń˙ ēą ėāė, ńėč = 0 - ņī āūźė
    
gApbylevel    register_cvar"ap_by_level",         "5");// źīė-āī įīķč, źīņīī ąņń˙ ēą ėāė, ńėč = 0 - ņī āūźė
    
gHideRadar    register_cvar"hide_radar",         "1");// ńźūāąņ ąą  čćīźą
    
gArmyChat    register_cvar"army_chat",         "1");// čńļīėēīāąņ ąņ ļėąćčķą, ņī ńņ ļčńņąāźą ā ąņ, āņ ńīīįł. ė˙ ąģčķą
    
gAdminGMsg    register_cvar"admin_color",        "1");// 1 = ńīīįł.ąģčķą ēėķī,0 = ęėņī, 2 = āņą źīģąķū
    
gSaveType     register_cvar"save_type",         "0");// 0 - nvault, 1- mysql.
    
gSlash         register_cvar"slash_messages",         "1");// ķ īņīįąęąņ źīģąķū ńī ńėżųģ
    
gTk         register_cvar"team_kill_lost_xp",       "1");// ņ˙ņ exp ļč ņčģźčėė
    
gLostXpTk     register_cvar"lost_xp_val",         "3");// źīė-āī ņ˙ģū exp ļč ņź
    
gLevelUpmsg    register_cvar"level_up_msg",         "1");// ńīīįłķč ļč ėāė-ąļ čćīźą : 1- āźė (āńģ), 2 - ņīėźī čćīź
    
gAllChat    register_cvar"all_chat",         "1");// 1 - ąņ ė˙ āń(ģņāū č ęčāū), 0-ęčāū ķ āč˙ņ ąņ ģņāū č ķąīįīīņ
// ė˙ mysql    
    
gHost        register_cvar"mysql_host",         "127.0.0.1");     // host
    
gUser        register_cvar"mysql_user",         "root");    // username
    
gPassword    register_cvar"mysql_password",     "qwerty");     // password
    
gDbName        register_cvar"mysql_db_name",     "test");     // database name
    
gTableName    register_cvar"mysql_table_name",     "army_ranks");     // ķąēāąķč ņąįėčū mysql
//
    
register_logevent"EventRoundStart"2"1=Round_Start" );
    
set_task(1.0,"Info",_,_,_"b")
    
register_event"DeathMsg","EventDeath","a");
    
register_message(get_user_msgid("SayText"), "msg_SayText");
    
gSayText get_user_msgid ("SayText");
//
    
g_MsgHud CreateHudSyncObj();
    
MaxPlayers get_maxplayers();
    
register_dictionary("army.txt" );
//
    
if(get_pcvar_num(gRestrictMaps))
    {
        new 
szMapName[64];
        
get_mapname(szMapName,63);
        for(new 
0sizeof restrict_bonusa++)
        {
            if(
equal(szMapNamerestrict_bonus[a]))
            {
                
restr_blocked true;
                
log_amx("[army ranks] weapon menu is blocked on map [%s].",restrict_bonus[a]);
                break;
            } else {
                
restr_blocked false;
            }    
        }
    }
//
    
switch(get_pcvar_num(gSaveType))
    {
        case 
0
        {
            
g_vault nvault_open("army_ranks");
        }
        case 
1
        {
            
set_task(0.1"sql_init");
        }
        default: 
        {
            
g_vault nvault_open("army_ranks");
        }
    }
//
    
if(get_pcvar_num(gArmyChat))
    {
        
register_clcmd("say""hookSay"
        
register_clcmd("say_team""hookSayTeam");
    }
    
register_clcmd("amx_setlevel","set_level_menu");
}
public 
plugin_cfg()
{
    new 
szCfgDir[64], szFile[192];
    
get_configsdir(szCfgDircharsmax(szCfgDir));
    
formatex(szFile,charsmax(szFile),"%s/army_ranks.cfg",szCfgDir);
    if(
file_exists(szFile))
        
server_cmd("exec %s"szFile);
}

public 
set_level_menu(id)
{
    if(
get_user_flags(id) & ADM_MENU)
    {
        
UserData[id][gTempKey] = 0;
        new 
players[32], num;
        
get_players(playersnum)
        new 
tempname[32], info[10];
        new 
players_menu menu_create("ŃŃŃ Ńŗ :""set_level_hl")
        for(new 
0numi++)
        {
            
get_user_name(players[i], tempname31);
            
num_to_str(players[i], info9);
            
menu_additem(players_menutempnameinfo0);
        }
        
menu_setprop(players_menuMPROP_EXITMEXIT_ALL);
        
menu_display(idplayers_menu0);
    }
    return 
PLUGIN_CONTINUE
}
public 
set_level_hl(idmenuitem)
{
    if(
item == MENU_EXIT)
    {
        
menu_destroy(menu);
        return 
PLUGIN_HANDLED;
    }
    new 
data[6], _accesscallback;
    
menu_item_getinfomenuitem_accessdatacharsmax(data), __callback);
    
UserData[id][gTempKey] = str_to_num(data);
    
set_level_pl(id);
    return 
PLUGIN_CONTINUE
}
public 
set_level_pl(id)
{
    static 
szText[1024];
    
formatex(szText,charsmax(szText), "%L"id"CHOOSE_RANKN");
    new 
menu menu_createszText"set_level_phl");
//======
    
for(new 1sizeof(gRankNames); i++)
    {
        new 
szItem[100],lang[10],num[5];
        
format(lang,9,"I_%d",i);
        
format(num,4,"%d",i);
        
formatex(szItem,charsmax(szItem),"%L",id,lang);
        
menu_additem(menu,szItem,num);
    }
//======
    
menu_setprop(menuMPROP_BACKNAME" ");
    
menu_setprop(menuMPROP_NEXTNAME" ");
    
menu_setprop(menuMPROP_EXITNAME"ŃŃ ");
    
menu_displayidmenu,0);
    return 
PLUGIN_CONTINUE;
}
public 
set_level_phl(id,menu,item)
{
    if(
item == MENU_EXIT)
    {
        
menu_destroy(menu);
        return 
PLUGIN_HANDLED;
    }
    new 
data[6], _accesscallback;
    
menu_item_getinfomenuitem_accessdatacharsmax(data), __callback);
    new 
level str_to_num(data);
    if(
UserData[id][gTempKey] >= && UserData[id][gTempKey] <= 32)
    {
        
UserData[UserData[id][gTempKey]][gLevel] = level;
        
UserData[UserData[id][gTempKey]][gExp] = gLevels[level-1];
        new 
szName[2][32];
        
get_user_name(idszName[0], 31);
        
get_user_name(UserData[id][gTempKey], szName[1], 31);
        
ColorChat(0,NORMAL,"%s give %L level to %s.",szName[0],LANG_PLAYER,gRankNames[level],szName[1])
    } else {
        
set_level_menu(id);
    }
    
UserData[id][gTempKey] = 0;
    return 
PLUGIN_HANDLED;
}

//
public sql_init()
{
    new 
szTableName[64],szHost[64],szUser[64],szPassword[64],szDbName[64],ErrorCode;
    
get_pcvar_string(gTableName,szTableName,63);
    
get_pcvar_string(gHost,szHost,63);
    
get_pcvar_string(gUser,szUser,63);
    
get_pcvar_string(gPassword,szPassword,63);
    
get_pcvar_string(gDbName,szDbName,63);
    
g_SqlTuple SQL_MakeDbTuple(szHost,szUser,szPassword,szDbName);
    new 
Handle:SqlConnection SQL_Connect(g_SqlTuple,ErrorCode,g_Error,511)
    if(
SqlConnection == Empty_Handle)
        
set_fail_state(g_Error);

    new 
Handle:Queries SQL_PrepareQuery(SqlConnection,"CREATE TABLE IF NOT EXISTS `%s`(`id` INT(10) NOT NULL AUTO_INCREMENT,`name` VARCHAR(32) NOT NULL,`exp` INT(10) NOT NULL,`level` INT(10) NOT NULL,PRIMARY KEY (id));"szTableName)
    if(!
SQL_Execute(Queries))
    {
        
SQL_QueryError(Queries,g_Error,charsmax(g_Error))
        
set_fail_state(g_Error);
    }
    
SQL_QueryAndIgnore(SqlConnection"DELETE FROM %s WHERE exp=0 and level=1;",szTableName); // 24.10.12
    
SQL_FreeHandle(Queries)
    
SQL_FreeHandle(SqlConnection);
}
//
public plugin_end()
{
    switch(
get_pcvar_num(gSaveType))
    {
        case 
0
        {
            
nvault_close(g_vault);
        }
        case 
1
        {
            if(
g_SqlTuple != Empty_Handle)
                
SQL_FreeHandle(g_SqlTuple);
        }
        default: 
        {
            
nvault_close(g_vault);
        }
    }
}
//
public client_putinserver(id// ļņčķńā)
{
    if(
get_pcvar_num(gHideRadar))
        
client_cmd(id,"hideradar 1");
        
    
UserData[id] = UserData[0];
    
load_data(id);
}
//
public client_disconnect(id)
{
    
save_usr(id);
    
UserData[id] = UserData[0];
}
//
public check_level(id)
{
    if(
UserData[id][gLevel] <= 0)
        
UserData[id][gLevel] = 1;
        
    if(
UserData[id][gExp] < 0)
        
UserData[id][gExp] = 0;

    while(
UserData[id][gExp] >= gLevels[UserData[id][gLevel]]) 
    {
        
UserData[id][gLevel]++;
        
levelUp[id] = 1;
        switch(
get_pcvar_num(gLevelUpmsg))
        {
            case 
1
            {
                new 
szName[33];
                
get_user_name(idszName32);
                static 
buffer[192],len;
                
len format(buffercharsmax(buffer), "^4[^3Army Ranks^4]^1 %L ^4%s^1",LANG_PLAYER,"PLAYER",szName);
                
len += format(buffer[len], charsmax(buffer) - len" %L",LANG_PLAYER,"NEW_LEVEL"); 
                
len += format(buffer[len], charsmax(buffer) - len" ^4%L^1.",LANG_PLAYER,gRankNames[UserData[id][gLevel]]);
                
len += format(buffer[len], charsmax(buffer) - len"%L",LANG_PLAYER,"CONTR");
                
ColorChat(0,NORMAL,buffer);
            }
            case 
2:
            {
                new 
szName[33];
                
get_user_name(idszName32);
                static 
buffer[192],len;
                
len format(buffercharsmax(buffer), "^4[^3Army Ranks^4]^1 %L ^4%s^1",LANG_PLAYER,"PLAYER",szName);
                
len += format(buffer[len], charsmax(buffer) - len" %L",LANG_PLAYER,"NEW_LEVEL"); 
                
len += format(buffer[len], charsmax(buffer) - len" ^4%L^1.",LANG_PLAYER,gRankNames[UserData[id][gLevel]]);
                
len += format(buffer[len], charsmax(buffer) - len"%L",LANG_PLAYER,"CONTR");
                
ColorChat(id,NORMAL,buffer);
            }
        }
    }
}
public 
EventDeath()
{
    new 
iKiller read_data(1);
    new 
iVictim read_data(2);
    new 
head read_data(3);
    if(
iKiller != iVictim && is_user_connected(iKiller) && is_user_connected(iVictim) && UserData[iKiller][gLevel] <= 19)
    {
        
// if tk?
        
if(get_pcvar_num(gTk) && get_user_team(iKiller) == get_user_team(iVictim))
        {
            
UserData[iKiller][gExp] -= get_pcvar_num(gLostXpTk);
            return 
PLUGIN_CONTINUE;
        }
        new 
weapon get_user_weapon(iKiller);
        
UserData[iKiller][gExp] += 1;
        if(
weapon == CSW_KNIFE)
            
UserData[iKiller][gExp] += 3;
            
        if(
head)
            
UserData[iKiller][gExp] += 2;

        if(
weapon == CSW_HEGRENADE)
            
UserData[iKiller][gExp] += 1;

        
check_level(iKiller);
    }
    return 
PLUGIN_CONTINUE;
}
public 
EventRoundStart()
{
    for(new 
id 1id <= MaxPlayersid++)
    {
        if(
is_user_alive(id) && is_user_connected(id))
        {
            if(
restr_blocked)
                return 
PLUGIN_CONTINUE;
            
            if(
get_pcvar_num(gFlash) && gNades[0][UserData[id][gLevel]])
                
give_item(id,"weapon_flashbang");
            
            if(
get_pcvar_num(gSmoke) && gNades[1][UserData[id][gLevel]])
                
give_item(id,"weapon_smokegrenade");
                
            if(
get_pcvar_num(gHe) && gNades[2][UserData[id][gLevel]])
                
give_item(id,"weapon_hegrenade");
            
            if(
get_pcvar_num(gHpbylevel) != 0)
                
set_user_health(id,get_user_health(id)+get_pcvar_num(gHpbylevel)*UserData[id][gLevel]);
                
            if(
get_pcvar_num(gApbylevel) != 0)
                
set_user_armor(id,get_user_armor(id)+get_pcvar_num(gApbylevel)*UserData[id][gLevel]);    
                
            if(
levelUp[id] == && get_pcvar_num(gBonusLevel))
            {
                
GetWeapon(id);
                
levelUp[id] = 0;
            }
        }
    }
    return 
PLUGIN_CONTINUE;
}
////////// save
public load_data(id)
{
    new 
szName[33];
    
get_user_name(id,szName,32);
    switch(
get_pcvar_num(gSaveType))
    {
        case 
0
        {
            static 
data[256], timestamp;
            if(
nvault_lookup(g_vaultszNamedatasizeof(data) - 1timestamp) )
            {
                
next_load_data(iddatasizeof(data) - 1);
                return;
            } else {
                
register_player(id,"");
            }
        }
        case 
1
        {
            new 
szTableName[32],ErrorCode;
            new 
Handle:SqlConnection SQL_Connect(g_SqlTuple,ErrorCode,g_Error,511)
            
SQL_QuoteString(SqlConnectionszName32szName);
            
get_pcvar_string(gTableName,szTableName,31);
            if(
SqlConnection == Empty_Handle)
            {
                
log_amx(g_Error);
                return ;
            }
            new 
Handle:Query SQL_PrepareQuery(SqlConnection,"SELECT id FROM %s WHERE name = '%s';",szTableName,szName)
            if(!
SQL_Execute(Query))
            {
                
SQL_QueryError(Query,g_Error,511);
                
log_amx(g_Error);
                return ;
            }
            if(
SQL_NumResults(Query) > )
            {
                
next_load_data(id""0);
            } else {
                
register_player(id,"");
            }
            
SQL_FreeHandle(Query);
            
SQL_FreeHandle(SqlConnection);
        }
        default: 
        {
            static 
data[256], timestamp;
            if(
nvault_lookup(g_vaultszNamedatasizeof(data) - 1timestamp) )
            {
                
next_load_data(iddatasizeof(data) - 1);
                return;
            } else {
                
register_player(id,"");
            }
        }
    }
}
public 
next_load_data(id,data[],len)
{
    new 
szName[33];
    
get_user_name(id,szName,32);
    switch(
get_pcvar_num(gSaveType))
    {
        case 
0
        {
            
replace_all(data,len,"|"," ");
            new 
exp[5],level[5];
            
parse(data,exp,4,level,4);
            
UserData[id][gExp]= str_to_num(exp);
            
UserData[id][gLevel]= str_to_num(level);
        }
        case 
1
        {
            new 
szTableName[32],ErrorCode;
            new 
Handle:SqlConnection SQL_Connect(g_SqlTuple,ErrorCode,g_Error,511)
            
SQL_QuoteString(SqlConnectionszName32szName);
            
get_pcvar_string(gTableName,szTableName,31);
            if(
SqlConnection == Empty_Handle)
            {
                
log_amx(g_Error);
                return ;
            }
            new 
Handle:Query SQL_PrepareQuery(SqlConnection,"SELECT id,exp,level FROM %s WHERE name = '%s';",szTableName,szName)
            if(!
SQL_Execute(Query))
            {
                
SQL_QueryError(Query,g_Error,511)
                
log_amx(g_Error)
            }
            if( 
SQL_NumResults(Query) > 0)
            {
                
UserData[id][gId]= SQL_ReadResult(Query,0); 
                
UserData[id][gExp]= SQL_ReadResult(Query,1); 
                
UserData[id][gLevel]= SQL_ReadResult(Query,2); 
            }
            
SQL_FreeHandle(Query);
            
SQL_FreeHandle(SqlConnection);
        }
        default: 
        {
            
replace_all(data,len,"|"," ");
            new 
exp[5],level[5];
            
parse(data,exp,4,level,4);
            
UserData[id][gExp]= str_to_num(exp);
            
UserData[id][gLevel]= str_to_num(level);
        }
    }
// mini-check lvl_up
    
if(UserData[id][gLevel] <= 0)
        
UserData[id][gLevel] = 1;

    while(
UserData[id][gExp] >= gLevels[UserData[id][gLevel]]) 
        
UserData[id][gLevel]++;
}
public 
register_player(id,data[])
{
    new 
szName[33];
    
get_user_name(id,szName,32);
    switch(
get_pcvar_num(gSaveType))
    {
        case 
0
        {
            
UserData[id][gExp]= 0
            UserData
[id][gLevel]= 1;
        }
        case 
1
        {
            new 
szTableName[32],ErrorCode;
            new 
Handle:SqlConnection SQL_Connect(g_SqlTuple,ErrorCode,g_Error,511)
            
SQL_QuoteString(SqlConnectionszName32szName);
            
get_pcvar_string(gTableName,szTableName,31);
            if(
SqlConnection == Empty_Handle)
            {
                
log_amx(g_Error);
                return ;
            }
            new 
Handle:Query SQL_PrepareQuery(SqlConnection,"INSERT INTO %s (`id`,`name`,`exp`,`level`) VALUES (NULL,'%s','0','1');",szTableName,szName);
            if(!
SQL_Execute(Query))
            {
                
SQL_QueryError(Query,g_Error,511)
                
log_amx(g_Error)
            }
            
SQL_FreeHandle(Query);
            
SQL_FreeHandle(SqlConnection);
            
UserData[id][gExp] = 0;
            
UserData[id][gLevel] = 1;
        }
        default: 
        {
            
UserData[id][gExp]= 0
            UserData
[id][gLevel]= 1;
        }
    }
}
public 
save_usr(id)
{
    new 
szName[33];
    
get_user_name(id,szName,32);
    switch(
get_pcvar_num(gSaveType))
    {
        case 
0
        {
            static 
data[256];
            
formatex(data255"|%i|%i|"UserData[id][gExp],UserData[id][gLevel]);
            
nvault_set(g_vaultszNamedata);
        }
        case 
1
        {
            new 
saveq[256],szTableName[32];
            
get_pcvar_string(gTableName,szTableName,31);
            
format(saveq,255,"UPDATE `%s` SET `exp`='%d',`level`='%d' WHERE `id`='%d';"szTableName,UserData[id][gExp],UserData[id][gLevel],UserData[id][gId])
            
SQL_ThreadQuery(g_SqlTuple,"QueryHandler",saveq);
        }
        default: 
        {
            static 
data[256];
            
formatex(data255"|%i|%i|"UserData[id][gExp],UserData[id][gLevel]);
            
nvault_set(g_vaultszNamedata);
        }
    }
}
///////// chat event
public hookSay(id)
{
    if(
is_user_hltv(id) || is_user_bot(id) || !is_user_connected(id))
        return 
PLUGIN_CONTINUE;

    new 
message[192],Len;
    
read_args(message191);
    
remove_quotes(message);
    if(
is_admin_msg(message))
        return 
PLUGIN_CONTINUE;
    
    if(
is_empty_message(message))
    {
        
ColorChat(id,NORMAL,"^4[^3Army Ranks^4]^1 %L",LANG_PLAYER,"EMPTY_MSG")
        return 
PLUGIN_HANDLED
    
}
    if(
get_pcvar_num(gSlash))
    {
        if(
is_has_slash(message))
            return 
PLUGIN_HANDLED_MAIN
    
}
    new 
szName[32];
    
get_user_name(id,szName,31);
    if(
is_user_admin(id))
    {
        
Len format(gMessage[Len], charsmax(gMessage) - 1"^4[^3%L^4] ",LANG_PLAYER,gRankNames[UserData[id][gLevel]]);
        switch(
get_pcvar_num(gAdminGMsg))
        {
            case 
1:
            {
                
Len += format(gMessage[Len], charsmax(gMessage) - 1"^3%s^4 : ",szName);
                
Len += format(gMessage[Len], charsmax(gMessage) - 1"%s",message);
            }
            case 
2:
            {
                
Len += format(gMessage[Len], charsmax(gMessage) - 1"^3%s^4 : ",szName);
                
Len += format(gMessage[Len], charsmax(gMessage) - 1"^3%s",message);
            }
            default:
            {
                
Len += format(gMessage[Len], charsmax(gMessage) - 1"^3%s^4 : ",szName);
                
Len += format(gMessage[Len], charsmax(gMessage) - 1"^1%s",message);
            }
        }
        
Chat(id,0,get_pcvar_num(gAllChat));
    }
    else 
    {
        
Len format(gMessage[Len], charsmax(gMessage) - 1"^4[^3%L^4] ",LANG_PLAYER,gRankNames[UserData[id][gLevel]]);
        
Len += format(gMessage[Len], charsmax(gMessage) - 1"^3%s^4 : ",szName);
        
Len += format(gMessage[Len], charsmax(gMessage) - 1"^1%s",message);
        
Chat(id,0,get_pcvar_num(gAllChat));
    }
    return 
PLUGIN_HANDLED_MAIN
}
public 
hookSayTeam(id)
{
    if(
is_user_hltv(id) || is_user_bot(id) || !is_user_connected(id))
        return 
PLUGIN_CONTINUE;

    new 
message[192],Len;
    
read_args(message191);
    
remove_quotes(message);
    if(
is_admin_msg(message))
        return 
PLUGIN_CONTINUE;
        
    if(
is_empty_message(message))
    {
        
ColorChat(id,NORMAL,"^4[^3Army Ranks^4]^1 %L",LANG_PLAYER,"EMPTY_MSG");
        return 
PLUGIN_HANDLED
    
}
    if(
get_pcvar_num(gSlash))
    {
        if(
is_has_slash(message))
            return 
PLUGIN_HANDLED_MAIN
    
}
    new 
szName[32];
    
get_user_name(id,szName,31);
    if(
is_user_admin(id))
    {
        
Len format(gMessage[Len], charsmax(gMessage) - 1"^3%L^1 ^4[^3%L^4] ^3%s^4 : ",LANG_PLAYER,"SEND_TEAM",LANG_PLAYER,gRankNames[UserData[id][gLevel]],szName);        
        switch(
get_pcvar_num(gAdminGMsg))
        {
            case 
1:
            {
                
Len += format(gMessage[Len], charsmax(gMessage) - 1"%s",message);
            }
            case 
2:
            {
                
Len += format(gMessage[Len], charsmax(gMessage) - 1"^3%s",message);
            }
            default:
            {
                
Len += format(gMessage[Len], charsmax(gMessage) - 1"^1%s",message);
            }
        }
        
Chat(id,1,get_pcvar_num(gAllChat));
    }
    else 
    {
        
Len format(gMessage[Len], charsmax(gMessage) - 1"^3%L^1 ^4[^3%L^4] ",LANG_PLAYER,"SEND_TEAM",LANG_PLAYER,gRankNames[UserData[id][gLevel]]);
        
Len += format(gMessage[Len], charsmax(gMessage) - 1"^3%s^4 : ",szName);
        
Len += format(gMessage[Len], charsmax(gMessage) - 1"^1%s",message);
        
Chat(id,1,get_pcvar_num(gAllChat));
    }
    return 
PLUGIN_HANDLED_MAIN
}
stock is_admin_msg(const Message[])
{
    if(
Message[0] == '@')
        return 
true;
        
    return 
false;
}
stock is_empty_message(const Message[])
{
    if(
equal(Message"") || !strlen(Message))
        return 
true;
        
    return 
false;
}
stock Chat(id,team,chat_type)
{
    if(
team)
    {
        if(
chat_type)
        {
            for(new 
1<= MaxPlayersi++)
            {
                if(!
is_user_connected(i))
                    continue
            
                if(
get_user_team(id) == get_user_team(i))
                    
send_message(gMessageidi);
            }
        } else {
            if(
is_user_alive(id))
            {
                for(new 
1<= MaxPlayersi++)
                {
                    if(!
is_user_connected(i) || !is_user_alive(i))
                        continue
                
                    if(
get_user_team(id) == get_user_team(i))
                        
send_message(gMessageidi);
                }
            } else if(!
is_user_alive(id)){
                for(new 
1<= MaxPlayersi++)
                {
                    if(!
is_user_connected(i) || is_user_alive(i))
                        continue
                
                    if(
get_user_team(id) == get_user_team(i))
                        
send_message(gMessageidi);
                }
            }
        }
    } else{
        if(
chat_type)
        {
            for(new 
1<= MaxPlayersi++)
            {
                if(!
is_user_connected(i))
                    continue
            
                
send_message(gMessageidi);
            }
        } else {
            if(
is_user_alive(id))
            {
                for(new 
1<= MaxPlayersi++)
                {
                    if(!
is_user_connected(i) || !is_user_alive(i))
                        continue
                
                    
send_message(gMessageidi);
                }
            } else if(!
is_user_alive(id)){
                for(new 
1<= MaxPlayersi++)
                {
                    if(!
is_user_connected(i) || is_user_alive(i))
                        continue
                
                    
send_message(gMessageidi);
                }
            }
        }
    }
}
stock send_message(const message[], const id, const i)
{
    
message_begin(MSG_ONEgSayText, {000}, i)
    
write_byte(id)
    
write_string(message)
    
message_end()
}
stock is_has_slash(const Message[])
{
    if(
Message[0] == '/')
        return 
true;
        
    return 
false;
}

public 
client_infochanged(id)
{
    new 
newname[32],oldname[32]
    
get_user_info(id"name"newname,31)
    
get_user_name(id,oldname,31)
    if(!
is_user_connected(id) || is_user_bot(id)) 
        return 
PLUGIN_CONTINUE
        
    
if(!equali(newnameoldname))
    {
        
set_user_info(id,"name",oldname);
        
log_amx("namechange BLOCKED.");
        return 
PLUGIN_HANDLED
    
}
    return 
PLUGIN_CONTINUE
}
public 
msg_SayText()
{
    new 
arg[32]
    
get_msg_arg_string(2arg31)
    if(
containi(arg,"name")!=-1)
        return 
PLUGIN_HANDLED

    
return PLUGIN_CONTINUE
}
/////////// natives
public plugin_natives()
{
    
register_native("get_user_exp""native_get_user_exp"1);
    
register_native("get_user_lvl""native_get_user_lvl"1);
    
register_native("set_user_exp""native_set_user_exp"1);
    
register_native("set_user_lvl""native_set_user_lvl"1);
    
register_native("get_user_rankname""native_get_user_rankname"1);
}
public 
native_set_user_exp(id,num)
{
    
UserData[id][gExp] = num;
}
public 
native_set_user_lvl(id,num)
{
    
UserData[id][gLevel] = num;
}
public 
native_get_user_exp(id)
{
    return 
UserData[id][gExp];
}
public 
native_get_user_lvl(id)
{
    return 
UserData[id][gLevel];
}
public 
native_get_user_rankname(id)
{
    static 
szRankName[64];
    
format(szRankNamecharsmax(szRankName), "%L",LANG_PLAYER,gRankNames[UserData[id][gLevel]]);
    return 
szRankName;
}
//////// informer
public Info()
{
    for(new 
id 1id <= MaxPlayersid++)
    {
        if(!
is_user_bot(id) && is_user_connected(id))
        {
            if(
get_pcvar_num(gHideRadar))
                
set_hudmessage(1001001000.010.0101.01.0__, -1);
            else
                
set_hudmessage(1001001000.010.1301.01.0__, -1)
            
            static 
buffer[192], len;
            
len format(buffercharsmax(buffer), "%L",LANG_PLAYER,"ZVANIE");
            
len += format(buffer[len], charsmax(buffer) - len" %L",LANG_PLAYER,gRankNames[UserData[id][gLevel]]);
            if(
UserData[id][gLevel] <= 19)
            {
                
len += format(buffer[len], charsmax(buffer) - len"^n%L",LANG_PLAYER,"PL_XP",UserData[id][gExp],gLevels[UserData[id][gLevel]]);
            } else {
                
len += format(buffer[len], charsmax(buffer) - len"^n%L",LANG_PLAYER,"PL_MAX");
            }
            
ShowSyncHudMsg(idg_MsgHud"%s"buffer);
        }
    }
    return 
PLUGIN_CONTINUE
}
/////// weap menu per lvl
public GetWeapon(id)
{
    new 
szText[700 char];
    
formatexszTextcharsmaxszText ), "%L"id"GW_TITLE");
    new 
menu menu_createszText"gw_menu" );
//
    
formatexszTextcharsmaxszText ), "awp");
    
menu_additemmenuszText"1");
//
    
formatexszTextcharsmaxszText ), "ak-47");
    
menu_additemmenuszText"2");
//
    
formatexszTextcharsmaxszText ), "m4a1");
    
menu_additemmenuszText"3");
//
    
formatexszTextcharsmaxszText ), "famas");
    
menu_additemmenuszText"4");
//
    
menu_setpropmenuMPROP_EXITMEXIT_ALL );
    
menu_displayidmenu,0);
    return 
PLUGIN_CONTINUE;
}
public 
gw_menu(id,menu,item)
{
    if( 
item == MENU_EXIT )
    {
        return 
PLUGIN_HANDLED;
    }
    
    new 
data], iName64 ], accesscallback;
    
menu_item_getinfomenuitemaccessdatacharsmaxdata ), iNamecharsmaxiName ), callback );
    new 
key str_to_numdata );
    switch( 
key )
    {
        case 
1:
        {
            
give_item(id,"weapon_awp");
            
cs_set_user_bpammoidCSW_AWP100);
        }
        case 
2:
        {
            
give_item(id,"weapon_ak47");
            
cs_set_user_bpammoidCSW_AK47200);
        }
        case 
3:
        {
            
give_item(id,"weapon_m4a1");
            
cs_set_user_bpammoidCSW_M4A1200);
        }
        case 
4:
        {
            
give_item(id,"weapon_famas");
            
cs_set_user_bpammoidCSW_FAMAS200);
        }
    }
    
    return 
PLUGIN_HANDLED;
}
public 
QueryHandler(FailState,Handle:Query,Error[],Errcode,Data[],DataSize)
{
    switch(
FailState)
    {
        case -
2log_amx("[Army Ranks] Failed to connect (%d): %s"ErrcodeError);
        case -
1log_amx("[Army Ranks] (%d): %s"ErrcodeError);
    }
    return 
PLUGIN_HANDLED

morrow is offline
Obada
Senior Member
Join Date: Dec 2014
Location: Abu Dhabi
Old 03-29-2015 , 08:51   Re: [Req] XP system by name
Reply With Quote #2

Why do you need it by name?
Obada is offline
morrow
Member
Join Date: Dec 2008
Old 03-29-2015 , 10:44   Re: [Req] XP system by name
Reply With Quote #3

cuz when i make top , i need top by name
just like stuff by name, because if i play cs @ friends place i just change the name and collect my xp
morrow is offline
Mordekay
Squirrel of Fortune
Join Date: Apr 2006
Location: Germany
Old 03-29-2015 , 12:10   Re: [Req] XP system by name
Reply With Quote #4

Quote:
Originally Posted by morrow View Post
cuz when i make top , i need top by name
just like stuff by name, because if i play cs @ friends place i just change the name and collect my xp
And anyone else using your name can use it. That's why it is the stupiest idea ever to save it by name.
Names, IPs, everything can change, the only stable thing is the STEAM_ID.
__________________

Mordekay is offline
morrow
Member
Join Date: Dec 2008
Old 03-30-2015 , 16:52   Re: [Req] XP system by name
Reply With Quote #5

i know, but i have my own reasons for save by name
i can't explane, because i dont speak english as well as you
So , can somebody make this plugin ? i can pay , but only with paypal .
morrow is offline
Obada
Senior Member
Join Date: Dec 2014
Location: Abu Dhabi
Old 03-31-2015 , 09:42   Re: [Req] XP system by name
Reply With Quote #6

Quote:
Originally Posted by morrow View Post
i know, but i have my own reasons for save by name
i can't explane, because i dont speak english as well as you
So , can somebody make this plugin ? i can pay , but only with paypal .
SteamIDs are more reliable than names.

What are your reasons that don't allow you to make it save by SteamIDs?

Last edited by Obada; 03-31-2015 at 09:43.
Obada is offline
Reply


Thread Tools
Display Modes

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:09.


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