AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Help with lvls (https://forums.alliedmods.net/showthread.php?t=255155)

Snitch 01-11-2015 09:08

Help with lvls
 
can someone pls help me with public EventDeathMsg()
change it to only Terrorists will gain kills (block ct kill gain kills to top)

and add message to all in chat, when someone up level?

and what the problem with dead in top?

thank ^^
Code:

#include <amxmodx>
#include <amxmisc>
#include <csx>
#include <nvault>
#include <fakemeta>

new const LEVELS[17] =
{
    0,    // 1
    30,    // 2
    200,    // 3
    500,    // 4
    1000,    // 5
    1500,    // 6
    1000,    // 7
    2500,    // 8
    5000,    // 9
    7500,    // 10
    10000,    // 11
    10500,    // 12
    20000,    // 13
    30000,    // 14
    50000,    // 15
    100000    // 16
}

new PFRAGS[ 33 ]
new PLEVEL[ 33 ]
new PDEADS[ 33 ]

public plugin_init()

    register_event( "DeathMsg", "EventDeathMsg", "a" );
   
    register_clcmd("say /level", "printLevel", -1, "Print player level" );
}


public client_putinserver( id )
{
    PDEADS[id] = 0
    PLEVEL[id] = 0
    PFRAGS[id] = 0
    Load(id)
}

public client_disconnect( id )
{
    Save(id)
    PDEADS[id] = 0
    PLEVEL[id] = 0
    PFRAGS[id] = 0
}


public EventDeathMsg()
{
    new killer = read_data( 1 )
    new victim = read_data( 2 )
   
         
    if( victim == killer )
    {
        return PLUGIN_CONTINUE
    }
   
    if(victim)
        PDEADS[victim]++
       
    if(killer)
        PFRAGS[killer]++
                 
    check_level(killer)
   
    return PLUGIN_CONTINUE
}

public check_level( id )
{
    if(PFRAGS[ id ] >= LEVELS[PLEVEL[ id ]])
    {
        PLEVEL[ id ]++
        print_color(id,"!nYour Current Level: !t%d", PLEVEL[ id ])
    }
}

public printLevel( id )
{
    new newlevel = LEVELS[PLEVEL[ id ]]-PFRAGS[ id ]
    print_color(id, "!nYour level is !t%d !nAnd you are missing !t%d !nFrags To Top", PLEVEL[id],newlevel)
}

public Load(id)
{
    new timestamp
    new g_vault = nvault_open("mro")
    new name[32], key[40], data[200], szfrags[15], szLevel[15], szMuertes[15]
    get_user_name(id, name, charsmax(name))
    formatex(key, charsmax(key), "^"%s^"", name)
   
    if(nvault_lookup(g_vault, key, data, charsmax(data), timestamp))
    {
        parse(data, szfrags, 14, szLevel, 14, szMuertes, 14)
        PFRAGS[id] = str_to_num(szfrags)
        PLEVEL[id] = str_to_num(szLevel)
        PDEADS[id] = str_to_num(szMuertes)
    }
    nvault_close(g_vault)
}
public Save(id)
{
    new g_vault = nvault_open("mro")
    new name[32], key[40], szValue[64]
    get_user_name(id,name,charsmax(name))
    formatex(key, charsmax(key), "^"%s^"", name)
    formatex(szValue, charsmax(szValue), "%d %d %d", PFRAGS[id], PLEVEL[id], PDEADS[id])
    nvault_set(g_vault, key, szValue)
    nvault_close(g_vault)
}

public show_top(id)
{
    static Sort[33][4];
    new players[32],num,count,index;
    get_players(players,num);
   
    for(new i = 0; i < num; i++)
    {
        index = players[i];
        Sort[count][0] = index;
        Sort[count][1] = PLEVEL[index];
        Sort[count][2] = PFRAGS[index];
        Sort[count][3] = PDEADS[index];
        count++;
    }
   
    SortCustom2D(Sort,count,"compare_xp");
    new motd[1501],iLen;
    iLen = format(motd, sizeof motd - 1,"<body bgcolor=#000000><font color=#98f5ff><pre>");
    iLen += format(motd[iLen], (sizeof motd - 1) - iLen,"%s %-22.22s %3s %6s %6s^n", "#", "Name", "Level", "Kills/Frags", "Deads");
   
    new y = clamp(count,0,10);
    new name[32],kindex;
   
    for(new x = 0; x < y; x++)
    {
        kindex = Sort[x][0];
        get_user_name(kindex,name,sizeof name - 1);
        iLen += format(motd[iLen], (sizeof motd - 1) - iLen,"%d %-22.22s %6d %6d %6d^n", x + 1, name, Sort[x][1],Sort[x][2],Sort[x][3]);
    }
    iLen += format(motd[iLen], (sizeof motd - 1) - iLen,"</body></font></pre>");
    show_motd(id,motd, "Top 10");
}

public compare_xp(elem1[], elem2[])
{
    if(elem1[1] > elem2[1])
        return -1;
    else if(elem1[1] < elem2[1])
        return 1;
 
    return 0;
}

stock print_color(id, const msg[], any:...) {
   
    static buffer[512], msg_SayText = 0
   
    if(!msg_SayText)
        msg_SayText = get_user_msgid("SayText")
       
    vformat(buffer, charsmax(buffer), msg, 3)
    replace_all( buffer, charsmax( buffer ), "!n", "^1" ); // Default Color
    replace_all( buffer, charsmax( buffer ), "!g", "^4" ); // Green Color
    replace_all( buffer, charsmax( buffer ), "!t", "^3" ); // Team Color
           
    message_begin(MSG_ONE_UNRELIABLE, msg_SayText, _, id)
    write_byte(id)
    write_string(buffer)
    message_end()
   
}


Snitch 02-03-2015 09:38

Re: Help with lvls
 
bump

Snitch 02-20-2015 15:31

Re: Help with lvls
 
bump !

Snitch 04-03-2015 20:05

Re: Help with lvls
 
Bump

Obada 04-03-2015 23:30

Re: Help with lvls
 
Wrong section.


All times are GMT -4. The time now is 15:22.

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