Skocz do zawartości

  • Zaloguj korzystając z Facebooka Zaloguj korzystając z Twittera Zaloguj przez Steam Zaloguj poprzez Google      Logowanie »   
  • Rejestracja

Witamy w Nieoficjalnym polskim support'cie AMX Mod X

Witamy w Nieoficjalnym polskim support'cie AMX Mod X, jak w większości społeczności internetowych musisz się zarejestrować aby móc odpowiadać lub zakładać nowe tematy, ale nie bój się to jest prosty proces w którym wymagamy minimalnych informacji.

  • Rozpoczynaj nowe tematy i odpowiedaj na inne
  • Zapisz się do tematów i for, aby otrzymywać automatyczne uaktualnienia
  • Dodawaj wydarzenia do kalendarza społecznościowego
  • Stwórz swój własny profil i zdobywaj nowych znajomych
  • Zdobywaj nowe doświadczenia

Dołączona grafika Dołączona grafika

Guest Message by DevFuse
 

Zdjęcie

[HUD] Level & Exp


  • Nie możesz napisać tematu
  • Zaloguj się, aby dodać odpowiedź
Brak odpowiedzi do tego tematu

#1 Adminek AMXX.PL

    Admin :)

  • Bot

Reputacja: 156
Profesjonalista

  • Postów:7178
  • Lokalizacja:AMXX.PL
Offline

Napisano 22.12.2014 00:07


[HUD] Level & Exp


-[ Description ]-
This Plugin Shows Your Class,Level & Exp On Hud. :)
And When Up a Level It Makes a Fade Screen and Play a Sound.
Aslo You Can Change It With Another Mod (bb,zm,...)

Code :


Code:

#include
#include
#include
#include
#include
#include

#define PLUGIN "XP/LEVEL"
#define VERSION "4.0"
#define AUTHOR "ZiZox/hisoka"

new g_level[32], g_level_data, g_frags_level, g_ScreenFade,SymbolsName
new g_level_max, g_level_num, g_levels[32]
new level_exp[32]
new g_level_exp[32], g_exp_data, g_Players, nameid[32]
new g_trime[32], g_MsgSync
new sound_level_up[] = { "misc/level_up.wav"}
const PEV_SPEC_TARGET = pev_iuser2
new SaveSystem

public plugin_init()
{
        register_plugin(PLUGIN, VERSION, AUTHOR)
       
        SaveSystem = register_cvar("fr_SaveSystem","1")
       
       
        g_frags_level =        register_cvar("fr_level_frags", "10")
        g_level_max  =        register_cvar("fr_level_max", "150")
        g_level_num =        register_cvar("fr_level_number", "1")
               
        g_level_data = nvault_open("fr_Leveling_Save")
        g_exp_data = nvault_open("fr_Exp_Save")
                               
        SymbolsName = register_cvar("fr_name_symbols", "`")
       
        register_forward(FM_ClientUserInfoChanged, "ChangeName")
                                       
        register_event("StatusValue","show_status","be","1=2","2!0");
        register_event("StatusValue","show_statusx","be","1=2","2!0");
        register_event("HLTV", "Round_Start", "a", "1=0", "2=0")
        register_event("DeathMsg", "Frags_Manager", "a", "1>0")   
        set_task(2.0,"System_Save",_,_,_,"b")
       
        g_ScreenFade = get_user_msgid( "ScreenFade" )
        g_Players =get_maxplayers()       
        g_MsgSync = CreateHudSyncObj()
}

 



//------| Change Name |------//
public ChangeName(id, buffer) {
        if(!is_user_connected(id))
        return FMRES_IGNORED;

        static Name[32], Val[32];
        get_user_name(id, Name, sizeof Name - 1);
        engfunc(EngFunc_InfoKeyValue, buffer, "name", Val, sizeof Val - 1);
       
        if(equal(Val, Name))
        return FMRES_IGNORED;
       
        set_task(0.2, "client_connect", id);
        return FMRES_SUPERCEDE;
        }
       

public client_putinserver(id)
{

        if(get_pcvar_num(SaveSystem))
        System_Load(id)
        g_level_exp[id] = get_pcvar_num(g_frags_level)
        new name[32]
        g_trime[id] = false;
        nameid[id] = get_user_name(id, name, sizeof name - 1)
        if(is_user_alive(id))
        {
                g_trime[id] = false;
                new n = 1;
                while( n != g_level[id] )
                {
                        n = n + 1;
                }
        }
        if( g_level[id] == 0) g_level[id] = 1;
        if( level_exp[id] == g_level[id] ) level_exp[id] = 0;
        if(g_level[id] < get_pcvar_num(g_level_num))
                g_levels[id] = get_pcvar_num(g_level_num);
        else
        {
                if(g_level[id] != g_levels[id])
                {
                        new x = 1;
                        while( g_level[id] > ( x * get_pcvar_num(g_level_num)) )
                        {
                                x = x + 1;
                                g_levels[id] = x * get_pcvar_num(g_level_num);
                        }
                }
        }
        new y = 1;
        while( g_level[id] != y )
        {
                y = y + 1;
                g_level_exp[id] = y * get_pcvar_num(g_frags_level);
        }
}

public client_connected(id) {
        System_Load(id)
        }
public client_authorized(id) {
        System_Load(id)
        }       
public client_disconnect(id){
       
        System_Save(id)
        remove_task(id)       
        new name[32], player_nick[32]
        player_nick[id] = get_user_name(id, name, sizeof name - 1)
        if(player_nick[id] == nameid[id])
        g_trime[id] = false;

        static sName[32];
        get_user_name(id, sName, sizeof sName - 1);
        static sChars[32];
        get_pcvar_string(SymbolsName, sChars, sizeof sChars - 1);       
        for(new i = 0 ; i < strlen(sName) ; i++) {
        for(new j = 0 ; j < strlen(sChars) ; j++) {
        if(sName[i] == sChars[j]) {
        server_cmd("kick #%d ^"Numele tau contine caractere nepermise.^"", get_user_userid(id));
        break;
        }
        }
        }
}

// Save System When Pausing The Plugin
public plugin_pause()
{
        new iPlayers[32], iNum
        get_players(iPlayers, iNum)
        for(new i; i                System_Save(iPlayers[i])
}

// Load System After Unpause The Plugin
public plugin_unpause()
{
        new iPlayers[32], iNum
        get_players(iPlayers, iNum)
        for(new i; i                System_Load(iPlayers[i])
}
public System_Save(id){
        new key[64], data[256], data_exp[256], key_exp[64]
        new name[33]
        get_user_name(id,name,32)
       
        format(key, 63, "%s-/", name)
        format(data, 255, "%i#", g_level[id])
       
        format(key_exp, 63, "%s-/", name)
        format(data_exp, 255, "%i#", level_exp[id])                       
       
        nvault_set(g_level_data, key, data)
        nvault_set(g_exp_data, key_exp, data_exp)
       
        return PLUGIN_CONTINUE;

}

public System_Load(id)
{

        new key[64], data[256], data_exp[256], key_exp[64]
        new name[33]
        get_user_name(id,name,32)
       
        format(key, 63, "%s-/", name)
        format(data, 255, "%i#", g_level[id])
       
        format(key_exp, 63, "%s-/", name)
        format(data_exp, 255, "%i#", level_exp[id])
               
        nvault_get(g_level_data, key, data, 255)
        nvault_get(g_exp_data, key_exp, data_exp, 255)
       
        replace_all(data, 255, "#", " ")
        replace_all(data_exp, 255, "#", " ")
       
        new givelevel[32], give_exp[32]
        parse(data, givelevel, 31)
        parse(data_exp, give_exp, 31)

        g_level[id] = str_to_num(givelevel)
        level_exp[id] = str_to_num(give_exp)
               
        set_task(1.0 ,"level_status", id, _, _, "b")
        return PLUGIN_CONTINUE;       
}
/*------------------------------------- Level System ---------------------------------------------------------*/
public Round_Start()
{
for(new id=1;id<=g_Players;id++)
        set_task(3.0, "Level", id)
       
}

public Level(id)
{
        if(is_user_alive(id) )
        {
                g_trime[id] = false;
                new n = 1;
                while( n < g_level[id] )
                {
                        n = n + 1
                }
        }
}

public Frags_Manager()
{
        new aname[32], attacker; attacker = read_data(1)
        new y; y = 1;
        get_user_name(attacker, aname, sizeof aname - 1)
        if( ( level_exp[attacker] >= (g_level_exp[attacker] - 1) ) && (g_level[attacker] <= get_pcvar_num(g_level_max)) && is_user_alive(attacker) )
        {
                g_level[attacker] = g_level[attacker] + 1;
                level_exp[attacker] = 0;
                while( g_level[attacker] != y )
                {
                        y = y + 1;
                        g_level_exp[attacker] = y * get_pcvar_num(g_frags_level);
                }
                message_begin(MSG_ONE_UNRELIABLE, g_ScreenFade, _, attacker)
                write_short(1<<12) // duration
                write_short(1) // hold time
                write_short(0x0000) // fade type
                write_byte(1) // red
                write_byte(200) // green
                write_byte(0) // blue
                write_byte(205) // alpha
                message_end()
                emit_sound(attacker, CHAN_STREAM, sound_level_up, 1.0, ATTN_NORM, 0, PITCH_HIGH )
                set_hudmessage(0, 200, 0, 0.65, 0.5, 0, 0.0, 3.0, 2.0, 1.0, -1)
                show_hudmessage(0, "%s has cut down %i level", aname, g_level[attacker])
                System_Save(attacker);
        }
        else
        {               
                if(g_level[attacker] == get_pcvar_num(g_level_max))
                Chat9olor(attacker, "^x04you have reached a maximum level: ^4%i", g_level[attacker] )
                level_exp[attacker] = level_exp[attacker] + 1;
                if(get_pcvar_num(SaveSystem))
                System_Save(attacker);
        }
}

/*-----------------------------------------Hud Message----------------------------------------------------------*/

public level_status(id)
{
        new Spec
        Spec = pev(id, PEV_SPEC_TARGET)
        new PlayerName[32]
        get_user_name(Spec, PlayerName, 31)
       
        if(is_user_alive(id))
        {
               
        if(cs_get_user_team(id) == CS_TEAM_CT)
        {
        set_hudmessage(10, 180, 10, -1.0, 0.87, 0, 6.0, 1.1)
        ShowSyncHudMsg(id, g_MsgSync, "[ Class : Counter-Terrorist ]^n [ Level : %d ] - [ Exp %d/%d ]",g_level[id],level_exp[id],g_level_exp[id])
        }
       
        if(cs_get_user_team(id) == CS_TEAM_T)
        {
        set_hudmessage(10, 180, 10, -1.0, 0.87, 0, 6.0, 1.1)
        ShowSyncHudMsg(id, g_MsgSync, "[ Class : Terrorist ]^n [ Level : %d ] - [ Exp %d/%d ]",g_level[id],level_exp[id],g_level_exp[id])
        }       
       
        }
       
        else
       
        if(is_user_alive(Spec))
        {
               
        if(cs_get_user_team(id) == CS_TEAM_CT)
        {               
        set_hudmessage(200, 30, 200, -1.0, 0.79, 0, 6.0, 1.1)
        ShowSyncHudMsg(id, g_MsgSync, "Spectating: %s ^n [ Class : Counter-Terrorist ]^n [ Level : %d ] - [ Exp %d/%d ]",PlayerName,g_level[Spec],level_exp[Spec],g_level_exp[Spec])
        }
       
        if(cs_get_user_team(id) == CS_TEAM_T)
        {               
        set_hudmessage(200, 30, 200, -1.0, 0.79, 0, 6.0, 1.1)
        ShowSyncHudMsg(id, g_MsgSync, "Spectating: %s ^n [ Class : Terrorist ]^n [ Level : %d ] - [ Exp %d/%d ]",PlayerName,g_level[Spec],level_exp[Spec],g_level_exp[Spec])
        }
       
        }
}
public show_status(id)
{
            new name[32],pid = read_data(2)
            get_user_name(pid,name,31)
        new idAiming, iBodyPart
        get_user_aiming(id, idAiming, iBodyPart)
       
        if(is_user_alive(idAiming) && is_user_alive(id))
        {
                if(cs_get_user_team(id) == CS_TEAM_CT && cs_get_user_team(idAiming) == CS_TEAM_CT)
                {
                        set_hudmessage(238,201,0,-1.0,0.60,1, 0.01, 3.0, 0.01, 0.01, -1)
                        show_hudmessage(id, "%s ^n [ Health: %d - Class: Counter-Terrorist - Armor: %d - Money: %d ]^n Level : %i - Exp : %i/%i", name,get_user_health(pid),get_user_armor(pid),cs_get_user_money(pid),g_level[pid],level_exp[pid],g_level_exp[pid])
                }
                else
                if(cs_get_user_team(id) == CS_TEAM_T && cs_get_user_team(idAiming) == CS_TEAM_T)
                {
                        set_hudmessage(255,0,0,-1.0,0.60,1, 0.01, 3.0, 0.01, 0.01, -1)
                        show_hudmessage(id, "%s ^n [ Health: %d - Class: Terrorist - Armor: %d - Money: %d ]^n Level : %i - Exp : %i/%i", name,get_user_health(pid),get_user_armor(pid),cs_get_user_money(pid),g_level[pid],level_exp[pid],g_level_exp[pid])
                }
        }
}
public show_statusx(id)
{
            new name[32],pid = read_data(2)
            get_user_name(pid,name,31)
        new idAiming, iBodyPart
        get_user_aiming(id, idAiming, iBodyPart)
   
        if(is_user_alive(idAiming) && is_user_alive(id))
        {
                if(cs_get_user_team(id) == CS_TEAM_T && cs_get_user_team(idAiming) == CS_TEAM_CT)
                {
                        set_hudmessage(238, 201, 0,-1.0,0.60,1, 0.01, 3.0, 0.01, 0.01, -1)
                        show_hudmessage(id, "%s ^n [ Health: %d - Class: Counter-Terrorist - Armor: %d - Money: %d ]^n Level : %i - Exp : %i/%i", name,get_user_health(pid),get_user_armor(pid),cs_get_user_money(pid),g_level[pid],level_exp[pid],g_level_exp[pid])
                }
        }
}
stock Chat9olor(const id, const input[], any:...)
{
        new count = 1, players[ 32 ]
        static msg[ 191 ]
        vformat( msg, 190, input, 3 )       
        replace_all( msg, 190, "!g", "^4" )
        replace_all( msg, 190, "!y", "^1" )
        replace_all( msg, 190, "!t", "^3" )       
        if(id) players[ 0 ] = id; else get_players( players, count, "ch" )
        {
        for(new i = 0; i < count; i++)
        {
                if( is_user_connected( players[ i ] ) )
                {
                        message_begin( MSG_ONE_UNRELIABLE, get_user_msgid("SayText"), _, players[ i ] ) 
                        write_byte( players[ i ] )
                        write_string( msg )
                        message_end( )
                }
        }
}
}


-[ Cvars ]-
fr_level_frags - Set Level Frags
fr_level_max - Max Levels
fr_level_number - Number Of Level When Connecting


Credit :
https://forums.alliedmods.net/member.php?u=253447" target="_blank">Linkin Hisoka

-[ Screenshots ]-
http://imageshack.com/a/img673/4258/3l5wyP.png" border="0" alt="" />
http://imageshack.com/a/img540/5571/NpbNjE.png" border="0" alt="" />













Attached Files







https://forums.alliedmods.net/images/attach/zip.gif" alt="File Type: zip" width="16" height="16" border="0" style="vertical-align:baseline" />


https://forums.alliedmods.net/attachment.php?attachmentid=140945&d=1419203616">Hud-Level-Exp.zip (22.7 KB)









Wyświetl pełny artykuł






Użytkownicy przeglądający ten temat: 0

0 użytkowników, 0 gości, 0 anonimowych