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

[HELP] LevelUP System XP


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
MorrocoAmxx
Member
Join Date: Apr 2014
Old 04-27-2014 , 22:43   [HELP] LevelUP System XP
Reply With Quote #1

Hi ,I want to add this:
1 - when a player join team spectator it looks on a player ct or tero a hud Message example:
[Spectating: Name Player]
[Level : 1 | Exp : 1/10]

In this Sma :
PHP Code:
#include <amxmodx> #include <fvault> #include <ColorChat>  new const g_vault_name[] = "EXP_MOD"; new const g_vault_lvl[] = "LVL_MOD"; new const LEVELS[25] = {     10, //lvl 0      20, //lvl 1     30, //lvl 2     70, //lvl 3     90, //lvl 4     130, //lvl 5     170, //lvl 6     200, //lvl 7      230, //lvl 8     250, //lvl 9     200, //lvl 10 }  new g_exp[33],g_lvl[33]; new XP_Kill,XP_Knife,XP_Hs,syncObj  public plugin_init() {     register_plugin("XpMod", "1.0", "JustGo")     register_event("DeathMsg", "eDeath", "a")     XP_Kill=register_cvar("XP_per_kill", "5")     XP_Hs=register_cvar("XP_hs_bonus","6")     XP_Knife=register_cvar("XP_knife_bonus","7")     syncObj = CreateHudSyncObj() }  public eDeath() //function name  {      // Create a variable to store the attacker's id     new attacker = read_data( 1 )     // We create the victim variable, so that this function can check      // if a player was killed      new iVictim = read_data( 2 )     // If a player was killed by a HeadShot, this will be used for the cvar Xp_Hs     new headshot = read_data( 3 )     if(attacker == iVictim)     {         return PLUGIN_HANDLED     }     //which weapon was used     new clip, ammo, weapon = get_user_weapon(attacker,clip,ammo);      // used for the xp_hs cvar      // it checks if the victim was killed by a headshot      if(headshot)      {     g_exp[attacker] += get_pcvar_num(XP_Hs)      }     else if(weapon == CSW_KNIFE)      {      g_exp[attacker] += get_pcvar_num(XP_Knife)         }     else     {         g_exp[attacker] += get_pcvar_num(XP_Kill)     }     while(g_exp[attacker] >= LEVELS[g_lvl[attacker]])      {         g_lvl[attacker] += 1          ColorChat(attacker, RED, "^3[HK] ^4Congratulations! ^3You are level ^4%i ", g_lvl[attacker])      }     SaveExp(attacker)     return PLUGIN_HANDLED }    public show(id)  {      set_hudmessage(0, 255, 0, -1.0, 0.9, 0, 6.0, 12.0)      ShowSyncHudMsg(id,syncObj, "[ Level: %i| Exp: %i/%i]",g_lvl[id],g_exp[id],LEVELS[g_lvl[id]])  }  public client_putinserver(plr) {     if( !is_user_hltv(plr) && !is_user_bot(plr) )     {         LoadExp(plr);     }     set_task(1.0, "show", plr, _, _, "b") }  public client_disconnect(plr) {     if( g_exp[plr] > 0 )     {         SaveExp(plr);                  g_exp[plr] = 0;     } }  SaveExp(plr) {     new authid[35];     get_user_authid(plr, authid, sizeof(authid) - 1);     new data2[16];     num_to_str(g_lvl[plr], data2, sizeof(data2) - 1);          fvault_set_data(g_vault_lvl, authid, data2);     new data[16];     num_to_str(g_exp[plr], data, sizeof(data) - 1);          fvault_set_data(g_vault_name, authid, data); }  LoadExp(plr) {     new authid[35];     get_user_authid(plr, authid, sizeof(authid) - 1);     new data2[16];     if( fvault_get_data(g_vault_lvl, authid, data2, sizeof(data2) - 1) )     {         g_lvl[plr] = str_to_num(data2);     }     else     {         g_lvl[plr] = 0;     }     new data[16];     if( fvault_get_data(g_vault_name, authid, data, sizeof(data) - 1) )     {         g_exp[plr] = str_to_num(data);     }     else     {         g_exp[plr] = 0;     } } 
and Thanks !

Last edited by MorrocoAmxx; 04-27-2014 at 22:46.
MorrocoAmxx is offline
xxxperts
Senior Member
Join Date: Oct 2013
Location: India
Old 04-28-2014 , 05:15   Re: [HELP] LevelUP System XP
Reply With Quote #2

just register a event like this :
PHP Code:
register_event("TextMsg""Event_Spec""bd""2&ec_Mod"); 
and use set_task bcoz as u said u want to show hud
PHP Code:
public Event_Spec(id)
{
    
set_task(id,......)
    return 
PLUGIN_CONTINUE;

__________________
All my work is here
xxxperts is offline
MorrocoAmxx
Member
Join Date: Apr 2014
Old 04-28-2014 , 07:17   Re: [HELP] LevelUP System XP
Reply With Quote #3

Is it possible for you to explain to me what this ?
Quote:
Originally Posted by xxxperts View Post
just register a event like this :
PHP Code:
register_event("TextMsg""Event_Spec""bd""2&ec_Mod"); 
and use set_task bcoz as u said u want to show hud
PHP Code:
public Event_Spec(id)
{
    
set_task(id,......)
    return 
PLUGIN_CONTINUE;

MorrocoAmxx is offline
xxxperts
Senior Member
Join Date: Oct 2013
Location: India
Old 04-28-2014 , 07:31   Re: [HELP] LevelUP System XP
Reply With Quote #4

Quote:
Originally Posted by MorrocoAmxx View Post
Is it possible for you to explain to me what this ?
Here You Go Bro..!
__________________
All my work is here
xxxperts is offline
MorrocoAmxx
Member
Join Date: Apr 2014
Old 04-28-2014 , 12:04   Re: [HELP] LevelUP System XP
Reply With Quote #5

Quote:
Originally Posted by xxxperts View Post
PHP Code:
#include <amxmodx>
#include <fvault>
#include <ColorChat>

new const g_vault_name[] = "EXP_MOD";
new const 
g_vault_lvl[] = "LVL_MOD";
new const 
LEVELS[25] = {
    
10//lvl 0 
    
20//lvl 1
    
30//lvl 2
    
70//lvl 3
    
90//lvl 4
    
130//lvl 5
    
170//lvl 6
    
200//lvl 7 
    
230//lvl 8
    
250//lvl 9
    
200//lvl 10
}

new 
g_exp[33],g_lvl[33];
new 
XP_Kill,XP_Knife,XP_Hs,syncObj

public plugin_init()
{
    
register_plugin("XpMod""1.0""JustGo")
    
register_event("DeathMsg""eDeath""a")
    
XP_Kill=register_cvar("XP_per_kill""5")
    
XP_Hs=register_cvar("XP_hs_bonus","6")
    
XP_Knife=register_cvar("XP_knife_bonus","7")
    
syncObj CreateHudSyncObj()
}

public 
eDeath() //function name 

    
// Create a variable to store the attacker's id
    
new attacker read_data)
    
// We create the victim variable, so that this function can check 
    // if a player was killed 
    
new iVictim read_data)
    
// If a player was killed by a HeadShot, this will be used for the cvar Xp_Hs
    
new headshot read_data)
    if(
attacker == iVictim)
    {
        return 
PLUGIN_HANDLED
    
}
    
//which weapon was used
    
new clipammoweapon get_user_weapon(attacker,clip,ammo); 
    
// used for the xp_hs cvar 
    // it checks if the victim was killed by a headshot 
    
if(headshot
    {
    
g_exp[attacker] += get_pcvar_num(XP_Hs
    }
    else if(
weapon == CSW_KNIFE
    { 
    
g_exp[attacker] += get_pcvar_num(XP_Knife)    
    }
    else
    {
        
g_exp[attacker] += get_pcvar_num(XP_Kill)
    }
    while(
g_exp[attacker] >= LEVELS[g_lvl[attacker]]) 
    {
        
g_lvl[attacker] += 
        ColorChat
(attackerRED"^3[HK] ^4Congratulations! ^3You are level ^4%i "g_lvl[attacker]) 
    }
    
SaveExp(attacker)
    return 
PLUGIN_HANDLED
}  

public 
show(id

    
set_hudmessage(02550, -1.00.906.012.0
    
ShowSyncHudMsg(id,syncObj"[ Level: %i| Exp: %i/%i]",g_lvl[id],g_exp[id],LEVELS[g_lvl[id]]) 

public 
client_putinserver(plr)
{
    if( !
is_user_hltv(plr) && !is_user_bot(plr) )
    {
        
LoadExp(plr);
    }
    
set_task(1.0"show"plr__"b")
}

public 
client_disconnect(plr)
{
    if( 
g_exp[plr] > )
    {
        
SaveExp(plr);
        
        
g_exp[plr] = 0;
    }
}

SaveExp(plr)
{
    new 
authid[35];
    
get_user_authid(plrauthidsizeof(authid) - 1);
    new 
data2[16];
    
num_to_str(g_lvl[plr], data2sizeof(data2) - 1);
    
    
fvault_set_data(g_vault_lvlauthiddata2);
    new 
data[16];
    
num_to_str(g_exp[plr], datasizeof(data) - 1);
    
    
fvault_set_data(g_vault_nameauthiddata);
}

LoadExp(plr)
{
    new 
authid[35];
    
get_user_authid(plrauthidsizeof(authid) - 1);
    new 
data2[16];
    if( 
fvault_get_data(g_vault_lvlauthiddata2sizeof(data2) - 1) )
    {
        
g_lvl[plr] = str_to_num(data2);
    }
    else
    {
        
g_lvl[plr] = 0;
    }
    new 
data[16];
    if( 
fvault_get_data(g_vault_nameauthiddatasizeof(data) - 1) )
    {
        
g_exp[plr] = str_to_num(data);
    }
    else
    {
        
g_exp[plr] = 0;
    }

Please Help Me For This Plugin ....
MorrocoAmxx is offline
ezio_auditore
Senior Member
Join Date: May 2013
Old 05-08-2014 , 03:34   Re: [HELP] LevelUP System XP
Reply With Quote #6

Quote:
Originally Posted by morrocoamxx View Post
hi ,i want to add this:
1 - when a player join team spectator it looks on a player ct or tero a hud message example:
[spectating: Name player]
[level : 1 | exp : 1/10]

in this sma :
PHP Code:
#include <amxmodx> #include <fvault> #include <colorchat>  new const g_vault_name[] = "exp_mod"; new const g_vault_lvl[] = "lvl_mod"; new const levels[25] = {     10, //lvl 0      20, //lvl 1     30, //lvl 2     70, //lvl 3     90, //lvl 4     130, //lvl 5     170, //lvl 6     200, //lvl 7      230, //lvl 8     250, //lvl 9     200, //lvl 10 }  new g_exp[33],g_lvl[33]; new xp_kill,xp_knife,xp_hs,syncobj  public plugin_init() {     register_plugin("xpmod", "1.0", "justgo")     register_event("deathmsg", "edeath", "a")     xp_kill=register_cvar("xp_per_kill", "5")     xp_hs=register_cvar("xp_hs_bonus","6")     xp_knife=register_cvar("xp_knife_bonus","7")     syncobj = createhudsyncobj() }  public edeath() //function name  {      // create a variable to store the attacker's id     new attacker = read_data( 1 )     // we create the victim variable, so that this function can check      // if a player was killed      new ivictim = read_data( 2 )     // if a player was killed by a headshot, this will be used for the cvar xp_hs     new headshot = read_data( 3 )     if(attacker == ivictim)     {         return plugin_handled     }     //which weapon was used     new clip, ammo, weapon = get_user_weapon(attacker,clip,ammo);      // used for the xp_hs cvar      // it checks if the victim was killed by a headshot      if(headshot)      {     g_exp[attacker] += get_pcvar_num(xp_hs)      }     else if(weapon == csw_knife)      {      g_exp[attacker] += get_pcvar_num(xp_knife)         }     else     {         g_exp[attacker] += get_pcvar_num(xp_kill)     }     while(g_exp[attacker] >= levels[g_lvl[attacker]])      {         g_lvl[attacker] += 1          colorchat(attacker, red, "^3[hk] ^4congratulations! ^3you are level ^4%i ", g_lvl[attacker])      }     saveexp(attacker)     return plugin_handled }    public show(id)  {      set_hudmessage(0, 255, 0, -1.0, 0.9, 0, 6.0, 12.0)      showsynchudmsg(id,syncobj, "[ level: %i| exp: %i/%i]",g_lvl[id],g_exp[id],levels[g_lvl[id]])  }  public client_putinserver(plr) {     if( !is_user_hltv(plr) && !is_user_bot(plr) )     {         loadexp(plr);     }     set_task(1.0, "show", plr, _, _, "b") }  public client_disconnect(plr) {     if( g_exp[plr] > 0 )     {         saveexp(plr);                  g_exp[plr] = 0;     } }  saveexp(plr) {     new authid[35];     get_user_authid(plr, authid, sizeof(authid) - 1);     new data2[16];     num_to_str(g_lvl[plr], data2, sizeof(data2) - 1);          fvault_set_data(g_vault_lvl, authid, data2);     new data[16];     num_to_str(g_exp[plr], data, sizeof(data) - 1);          fvault_set_data(g_vault_name, authid, data); }  loadexp(plr) {     new authid[35];     get_user_authid(plr, authid, sizeof(authid) - 1);     new data2[16];     if( fvault_get_data(g_vault_lvl, authid, data2, sizeof(data2) - 1) )     {         g_lvl[plr] = str_to_num(data2);     }     else     {         g_lvl[plr] = 0;     }     new data[16];     if( fvault_get_data(g_vault_name, authid, data, sizeof(data) - 1) )     {         g_exp[plr] = str_to_num(data);     }     else     {         g_exp[plr] = 0;     } } 
and thanks ! :d

P.S. Post your code properly
__________________

Last edited by ezio_auditore; 05-08-2014 at 03:35.
ezio_auditore is offline
Send a message via Skype™ to ezio_auditore
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 15:40.


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