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

Complete Recode of XP+Level System


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
CrAzY MaN
Senior Member
Join Date: Mar 2017
Location: India
Old 11-28-2017 , 03:28   Complete Recode of XP+Level System
Reply With Quote #1

I need help in completely recoding the plugin.
I m messed up with this -_-
Can anyone help?

PHP Code:
#include <amxmodx>
#include <fvault>
#include <cstrike>
#include <wm_play>

#define PLUGIN "XP + LEVEL + RANK SYSTEM"
#define AUTHOR "CrAzY MaN"
#define VERSION "1.1"

#define maxranks 15
#define maxlevels 50

#define xPrefix "RANK"

#define RANKS_Noobest 0
#define RANKS_Noob 1
#define RANKS_Newbiee 2
#define RANKS_Easy 3
#define RANKS_Normal 4
#define RANKS_Hard 5
#define RANKS_Expert 6
#define RANKS_SuperExpert 7
#define RANKS_Specialist 8
#define RANKS_Leader 9
#define RANKS_Mayor 10
#define RANKS_Pro 11
#define RANKS_SuperPro 12
#define RANKS_Heroic 13
#define RANKS_God 14

new const db_save[] = "level_xp_rank"

new level[33], xp[33], rank[33], cvars[3], g_status_sync

new const xp_num[maxlevels+1] = { 15701502503504505506507508509501050115012501350145015501650,
    
175018501950205021502250235024502550,26502750285029503050315032503350345035503650
375038503950405041504250435044504550465047505000 }

new const 
ranks_names[maxranks][]=
{
    
"Noobest",
    
"Noob",
    
"Newbiee",
    
"Easy",
    
"Normal",
    
"Hard",
    
"Expert",
    
"SuperExpert",
    
"Specialist",
    
"Leader",
    
"Mayor",
    
"Pro",
    
"SuperPro",
    
"Heroic",
    
"God"
}

public 
plugin_init()
{
register_plugin(PLUGINVERSIONAUTHOR)

// system of xp+lvl+rank
cvars[0] = register_cvar("rank_level_bonus""10000"// Amount of money when passing level.
cvars[1] = register_cvar("rank_save_type""2"// 1 - IP || 2 - Nick || 3 - SteamID


register_event("StatusValue""showStatus""be""1=2""2!0")
register_event("StatusValue""hideStatus""be""1=1""2=0")
register_event("DeathMsg""xDeathMsg""a""1>0"// Used for xps and etc...

g_status_sync CreateHudSyncObj()
}

/*----------------------------------------------------------------------------------------------------------------
-HUD OF THE GAME
----------------------------------------------------------------------------------------------------------------*/
public hud_status(id)
{
    if(!
is_user_alive(id) ||  !is_user_connected(id) )
    return;
    if(
level[id] >= maxlevels)
    {
        static 
rgbrandom_num(0255), random_num(0255), random_num(0255);
        
set_hudmessage(rgb0.550.8001.01.10.00.0, -1)
        
show_hudmessage(id,"» Level: %d/%d^n» Rank: %s^n» XP: %d/%d"level[id], maxlevelsranks_names[rank[id]], xp[id], xp[id])
    }
    else
    {
        
set_hudmessage(2552552550.550.8001.01.10.00.0, -1)
        
show_hudmessage(id,"» Level: %d/%d^n» Rank: %s^n» XP: %d/%d"level[id], maxlevelsranks_names[rank[id]], xp[id], xp_num[level[id]])
    }
}

/*----------------------------------------------------------------------------------------------------------------
-EVENT TO ADD XP
----------------------------------------------------------------------------------------------------------------*/
public xDeathMsg()
{    
    new 
id read_data(1)
    new 
hs read_data(3)
    
    
xp[id]++
    
    if(
hs)
        
xp[id] += 3
    
    check_level
(id1)
    
save_data(id)
}

/*----------------------------------------------------------------------------------------------------------------
-CHECK LEVEL OF ADD ++
----------------------------------------------------------------------------------------------------------------*/
public check_level(idsound)
{
    if(!
is_user_connected(id)) return PLUGIN_HANDLED;
    
    new 
name[32]; get_user_name(idname31)
    
    if(
level[id] < maxlevels
    {        
        while(
xp[id] >= xp_num[level[id]])
        {
            
level[id]++
            
            if(
sound)
            {
                if(
level[id] == maxlevels)
                {
                    
client_print_color(id"!g[%s] !yYour have reached the maximum level. Level maximum: !t%s!y."xPrefixlevel[id])
                    
client_print_color(0"!g%s !yreached the maximum level. Level maximum: !t%s!y."namelevel[id])
                    
                    
client_cmd(0"spk ambience/wolfhowl02.wav")
                    
                    return 
PLUGIN_HANDLED
                
}
                
                
client_print_color(0"!g%s !yhas won !t%d !ymoney for raising a level."nameget_pcvar_num(cvars[0]))
                
cs_set_user_money(idcs_get_user_money(id) + get_pcvar_num(cvars[0]))
                
                
client_cmd(0"spk ambience/lv_fruit1.wav")
                
                
set_ranks(id)
            }
        }
    } 
    
    
// Bug Preventions... (Back to top)
    
if(level[id] == maxlevels && xp[id] > xp_num[level[id]-1])
    {
        
xp[id] = xp_num[level[id]-1]
        
save_data(id)
    }
    
    if(
level[id] >= maxlevels
    {    
        
level[id] = maxlevels
        xp
[id] = xp_num[level[id]-1]
        
save_data(id)
    }
    
    return 
PLUGIN_HANDLED
}

/*----------------------------------------------------------------------------------------------------------------
-SET THE RANK POSITION
----------------------------------------------------------------------------------------------------------------*/
public set_ranks(id)
{
    if(
level[id] <= 2rank[id] = RANKS_Noobest
    
if(level[id] >= 2rank[id] = RANKS_Noob
    
if(level[id] >= 5rank[id] = RANKS_Newbiee
    
if(level[id] >= 8rank[id] = RANKS_Easy
    
if(level[id] >= 11rank[id] = RANKS_Normal
    
if(level[id] >= 14rank[id] = RANKS_Hard
    
if(level[id] >= 17rank[id] = RANKS_Expert
    
if(level[id] >= 20rank[id] = RANKS_SuperExpert
    
if(level[id] >= 23rank[id] = RANKS_Specialist
    
if(level[id] >= 26rank[id] = RANKS_Leader
    
if(level[id] >= 29rank[id] = RANKS_Mayor
    
if(level[id] >= 32rank[id] = RANKS_Pro
    
if(level[id] >= 33rank[id] = RANKS_SuperPro
    
if(level[id] >= 36rank[id] = RANKS_Heroic
    
if(level[id] >= 43rank[id] = RANKS_God
}

/*----------------------------------------------------------------------------------------------------------------
-SAVE LEVEL, XP AND RANK
----------------------------------------------------------------------------------------------------------------*/
public save_data(id)
{
    if(!
is_user_connected(id)) return PLUGIN_HANDLED;
    
    new 
auth[40], data[50]
    
    switch(
get_pcvar_num(cvars[1]))
    {
        case 
1get_user_ip(idauthcharsmax(auth), 1)
            case 
2get_user_name(idauthcharsmax(auth))
            case 
3get_user_authid(idauthcharsmax(auth))
        }
    
    
formatex(datacharsmax(data), "%d %d"level[id], xp[id])
    
    
fvault_pset_data(db_saveauthdata)
    
    return 
PLUGIN_HANDLED;
}

/*----------------------------------------------------------------------------------------------------------------
-LOAD DATA
----------------------------------------------------------------------------------------------------------------*/
public client_putinserver(id)
{
    new 
auth[40], data[50], x1[10], x2[10]
    
    switch(
get_pcvar_num(cvars[1]))
    {
        case 
1get_user_ip(idauthcharsmax(auth), 1)
            case 
2get_user_name(idauthcharsmax(auth))
            case 
3get_user_authid(idauthcharsmax(auth))
        }
    
    
fvault_get_data(db_saveauthdatacharsmax(data))
    
parse(datax1charsmax(x1), x2charsmax(x2))
    
    
level[id] = str_to_num(x1)
    
xp[id] = str_to_num(x2)
    
    
set_task(2.0"set_ranks"id)
    
check_level(id0)
    
    
set_task(1.1"hud_status"id__"b")
}

/*----------------------------------------------------------------------------------------------------------------
-SHOW XP BY LOOKING AT THE PERSON
----------------------------------------------------------------------------------------------------------------*/

public showStatus(id)
{
    if(!
is_user_bot(id) && is_user_connected(id)) 
    {
        new 
name[32], pid read_data(2)
        
        
get_user_name(pidname31)
        new 
color1 0color2 0
        
        
new xxx get_user_team(id)
        new 
xxx2 get_user_team(pid)
        
        new 
team1 xxx == 1team2 xxx2 == 1
        
        
if (team2 == 1)
            
color1 255
        
else
            
color2 255
        
        
if (team1 == team2)    // friend
        
{
            
set_hudmessage(color150color2, -1.00.6010.013.00.010.01, -1)
            
ShowSyncHudMsg(idg_status_sync"Name: %s^nRank: %s^nLevel: %d^nXP: %d/%d"nameranks_names[rank[pid]], level[pid], xp[pid], xp_num[level[pid]])
        }
    }
}

public 
hideStatus(id)
{
    
ClearSyncHud(idg_status_sync)

Attached Files
File Type: inc wm_play.inc (3.2 KB, 50 views)
__________________

Last edited by CrAzY MaN; 11-28-2017 at 03:42.
CrAzY MaN is offline
KiLLeR.
Senior Member
Join Date: Jul 2014
Location: Bulgaria
Old 11-28-2017 , 15:22   Re: Complete Recode of XP+Level System
Reply With Quote #2

You want someone to recode the whole plugin for you?! If yes, then I guess it's not right place. Also why you need that?
KiLLeR. is offline
CrazY.
Veteran Member
Join Date: May 2015
Location: SP, Brazil
Old 11-28-2017 , 17:52   Re: Complete Recode of XP+Level System
Reply With Quote #3

What's the problem with the plugin?
CrazY. is offline
Relaxing
AlliedModders Donor
Join Date: Jun 2016
Location: White Plains
Old 11-28-2017 , 20:24   Re: Complete Recode of XP+Level System
Reply With Quote #4

There's a problem. That's why you created this thread. Also I recommend you to remove this plugin, since you're posting for help, which it's main reason is that your code isn't complicated, but you're calling yourself lazy when it comes to fix (more flexible code) it. Since the script file is using only the amxmodx library, it isn't that hard to deal with it. (currently thinking about those register event and logevent event types, it's hard to remember all of them.)
__________________
Relaxing is offline
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 11-29-2017 , 05:36   Re: Complete Recode of XP+Level System
Reply With Quote #5

If you can't support your plugin, then simply delete it. If someone else makes it for you - it's not yours anymore. Your plugin is not different from all the others like this one, it's even worse.
__________________
OciXCrom is offline
Send a message via Skype™ to OciXCrom
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 23:17.


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