Approved Levels-XP System

Gameplay Addons
karan
Mod Tester
Mod Tester
India
Posts: 122
Joined: 4 Years Ago
Location: India
Has thanked: 3 times
Been thanked: 10 times
Age: 24
Contact:

Re: Levels-XP System

#141

Post by karan » 3 Months Ago

VicKy wrote:
3 Months Ago
czirimbolo wrote:
2 Years Ago
Ok here is fixed version of level system by Jack and Raheem. Double exp is working too.

Code: Select all

#include <zombie_escape>
 
// Defines
#define MAX_LEVEL 41
#define TASK_SHOWHUD 2020
#define TASK_DOUBLE 1133
#define REPEAT_TIME 60.0
#define ID_SHOWHUD (taskid - TASK_SHOWHUD)
#define LEVELUP "levelup_ZE/ze_levelup.wav"
 
enum
{
    Host = 0,
    User,
    Pass,
    DB
}
 
new const g_iMaxLevelsXP[MAX_LEVEL] =
{
    3000, // 1
    3500, // 2
    5000, // 3
    7500, // 4
    11000, // 5
    15000, // 6
    20000, // 7
    25000, // 8
    30000, // 9
    40000, // 10
    50000, // 11
    60000, // 12
    75000, // 13
    90000, // 14
    105000, // 15
    120000, // 16
    140000, // 17
    170000, // 18
    200000, // 19
    275000, // 20
    350000, // 21
    500000, // 22
    1000000, // 23
    1750000, // 24
    3000000, // 25
    6000000, // 26
    10000000, // 27
    15000000, // 28
    20000000, // 29
    30000000, // 30
    40000000, // 31		
    62000000, // 32
    75000000, // 33
    90000000, // 34
    105000000, // 35
    125000000, // 36
    135000000, // 37
    155000000, // 38
    175000000, // 39
    200000000, // 40		
    300000000 // 41
}
 
// Constants
new const g_szLevelsVault[] = "Levels"
new const g_szRanksVault[] = "Ranks"
new const g_szLogFile[] = "Levels.log" // MySQL Errors log file
new const g_szTable[] =
" \
    ALTER TABLE `test` \
    ADD IF NOT EXISTS `Level` int(20) NOT NULL DEFAULT '0', \
    ADD IF NOT EXISTS `XP` int(20) NOT NULL DEFAULT '0'; \
"
 
// Messages
const Float:HUD_SPECT_X = -1.0
const Float:HUD_SPECT_Y = 0.70
const Float:HUD_STATS_X = 0.01
const Float:HUD_STATS_Y = 0.22
 
const HUD_STATS_ZOMBIE_R = 200
const HUD_STATS_ZOMBIE_G = 220
const HUD_STATS_ZOMBIE_B = 0
 
const HUD_STATS_HUMAN_R = 0
const HUD_STATS_HUMAN_G = 200
const HUD_STATS_HUMAN_B = 210
 
const HUD_STATS_SPEC_R = 100
const HUD_STATS_SPEC_G = 100
const HUD_STATS_SPEC_B = 100
 
// Variables
new g_iLevel[33],
    g_iXP[33],
    g_iMaxXP[33],
    Float:g_fDamage[33],
    g_MsgSync,
    g_iLevelsVaultHandle,
    g_iRanksVaultHandle,
    Handle:g_hTuple,
    Fw_LevelUP,
    ForwardReturn,
    bool:g_bIsDoubleHours
 
// Cvars
new g_pCvarZombieInfect,
    g_pCvarEscapeSuccess,
    g_pCvarEnableDamage,
    g_pCvarRequiredDamage,
    g_pCvarDamageAward,
    g_pCvarStartXP,
    g_pCvarPercentageStyle,
    g_pCvarStartFromZero,
    g_pCvarAddCommas,
    g_pCvarLevelEffects,
    g_pCvarSaveType,
    g_pCvarDBInfo[4],
    g_pCvarDoubleXP
 
public plugin_natives()
{
    register_native("ze_get_user_xp", "native_ze_get_user_xp", 1)
    register_native("ze_set_user_xp", "native_ze_set_user_xp", 1)
    register_native("ze_get_user_level", "native_ze_get_user_level", 1)
    register_native("ze_set_user_level", "native_ze_set_user_level", 1)
    register_native("ze_get_user_max_xp", "native_ze_get_user_max_xp", 1)
}
 
public plugin_precache()
{
    precache_sound(LEVELUP)
}
 
public plugin_init()
{
    register_plugin("[ZE] Level-XP System", "1.9", "Raheem/JaCk")
   
    // Hook Chains
    RegisterHookChain(RG_CBasePlayer_TakeDamage, "Fw_TakeDamage_Post", 1)
 
    Fw_LevelUP = CreateMultiForward("ze_on_levelup", ET_IGNORE, FP_CELL)
   
    // Cvars
    g_pCvarZombieInfect = register_cvar("ze_zombie_infect", "3")
    g_pCvarEscapeSuccess = register_cvar("ze_escape_success", "5")
    g_pCvarEnableDamage = register_cvar("ze_enable_dmg", "1")
    g_pCvarRequiredDamage = register_cvar("ze_required_dmg", "50.0")
    g_pCvarDamageAward = register_cvar("ze_dmg_award", "3")
    g_pCvarStartXP = register_cvar("ze_start_xp", "0")
    g_pCvarPercentageStyle = register_cvar("ze_enable_percentage_style", "0")
    g_pCvarStartFromZero = register_cvar("ze_new_level_zero_xp", "0")
    g_pCvarAddCommas = register_cvar("ze_add_commas_to_xp", "1")
    g_pCvarLevelEffects = register_cvar("ze_level_up_effects", "0")
    g_pCvarDoubleXP = register_cvar("ze_double_xp", "15-22")
 
    g_pCvarSaveType = register_cvar("ze_levels_save_type", "0")
    g_pCvarDBInfo[Host] = register_cvar("ze_levels_host", "127.0.0.1")
    g_pCvarDBInfo[User] = register_cvar("ze_levels_user", "root")
    g_pCvarDBInfo[Pass] = register_cvar("ze_levels_pass", "password")
    g_pCvarDBInfo[DB] = register_cvar("ze_levels_dbname", "levels_db")
   
    // Messages
    g_MsgSync = CreateHudSyncObj()
 
    if (get_pcvar_num(g_pCvarSaveType))
    {
        set_task(0.1, "Delay_MySQL_Init")
    }

    DoubleHours()

    if (g_bIsDoubleHours)
    {
        set_task(REPEAT_TIME, "HappyHours", TASK_DOUBLE, _, _, "b")
    }
}
 
public plugin_end()
{
    if (get_pcvar_num(g_pCvarSaveType))
    {
        if (g_hTuple != Empty_Handle)
        {
            SQL_FreeHandle(g_hTuple)
        }
    }
}
 
public Delay_MySQL_Init()
{
    MySQL_Init()
}
 
public MySQL_Init()
{
    if (!get_pcvar_num(g_pCvarSaveType))
        return
   
    new szHost[64], szUser[32], szPass[32], szDB[128]
   
    get_pcvar_string(g_pCvarDBInfo[Host], szHost, charsmax(szHost))
    get_pcvar_string(g_pCvarDBInfo[User], szUser, charsmax(szUser))
    get_pcvar_string(g_pCvarDBInfo[Pass], szPass, charsmax(szPass))
    get_pcvar_string(g_pCvarDBInfo[DB], szDB, charsmax(szDB))
   
    g_hTuple = SQL_MakeDbTuple(szHost, szUser, szPass, szDB)
   
    // Let's ensure that the g_hTuple will be valid, we will access the database to make sure
    new iErrorCode, szError[512], Handle:hSQLConnection
   
    hSQLConnection = SQL_Connect(g_hTuple, iErrorCode, szError, charsmax(szError))
   
    if (hSQLConnection != Empty_Handle)
    {
        log_amx("[MySQL][LVL] Successfully connected to host: %s (ALL IS OK).", szHost)
        SQL_FreeHandle(hSQLConnection)
    }
    else
    {
        // Disable plugin
        set_fail_state("[LVL] Failed to connect to MySQL database: %s.", szError)
    }
   
    SQL_ThreadQuery(g_hTuple, "QueryCreateTable", g_szTable)
}
 
public QueryCreateTable(iFailState, Handle:hQuery, szError[], iError, szData[], iSize, Float:flQueueTime)
{
    SQL_IsFail(iFailState, iError, szError, g_szLogFile)
}
 
public client_putinserver(id)
{
    if(is_user_hltv(id) || is_user_bot(id))
        return
   
    // Just 1 second delay
    set_task(1.0, "DelayLoad", id)
 
    // Other tasks
    set_task(1.0, "Show_Hud", id+TASK_SHOWHUD, _, _, "b")
   
    if (g_bIsDoubleHours)
    {
        set_task(REPEAT_TIME, "HappyHours", id+TASK_DOUBLE, _, _, "b")
    }
}
 
public HappyHours(taskid)
{
    DoubleHours()

    if (!g_bIsDoubleHours)
        remove_task(taskid)
   
    new szDoubleHours[32]
   
    get_pcvar_string(g_pCvarDoubleXP, szDoubleHours, charsmax(szDoubleHours))
   
    set_dhudmessage(0, 255, 0, -1.0, 0.20, 0, 0.0, 10.0)
    show_dhudmessage(0, "DOUBLE XP: %s", szDoubleHours)
}
 
public DelayLoad(id)
{
    // Load his data
    LoadData(id)
}
 
public client_disconnected(id)
{
    if(is_user_hltv(id) || is_user_bot(id))
        return
       
    remove_task(id+TASK_SHOWHUD)
    remove_task(id)
}
 
public Show_Hud(taskid)
{  
    new iPlayer = ID_SHOWHUD
   
    if (!is_user_alive(iPlayer))
    {
        iPlayer = pev(iPlayer, pev_iuser2)
       
        if (!is_user_alive(iPlayer))
            return
    }
   
    if (get_pcvar_num(g_pCvarPercentageStyle) != 0)
    {
        if(iPlayer != ID_SHOWHUD)
        {
            set_hudmessage(HUD_STATS_SPEC_R, HUD_STATS_SPEC_G, HUD_STATS_SPEC_B, HUD_SPECT_X, HUD_SPECT_Y, 0, 6.0, 1.1, 0.0, 0.0, -1)
            ShowSyncHudMsg(ID_SHOWHUD, g_MsgSync, "Level: %d | XP: %0.2f %", g_iLevel[iPlayer], (float(g_iXP[iPlayer])/float(g_iMaxXP[iPlayer])) * 100.0)
        }
        else if (ze_is_user_zombie(iPlayer))
        {
            set_hudmessage(HUD_STATS_ZOMBIE_R, HUD_STATS_ZOMBIE_G, HUD_STATS_ZOMBIE_B, HUD_STATS_X, HUD_STATS_Y, 0, 6.0, 1.1, 0.0, 0.0, -1)
            ShowSyncHudMsg(ID_SHOWHUD, g_MsgSync, "Level: %d | XP: %0.2f %", g_iLevel[ID_SHOWHUD], (float(g_iXP[ID_SHOWHUD])/float(g_iMaxXP[ID_SHOWHUD])) * 100.0)
        }
        else
        {
            set_hudmessage(HUD_STATS_HUMAN_R, HUD_STATS_HUMAN_G, HUD_STATS_HUMAN_B, HUD_STATS_X, HUD_STATS_Y, 0, 6.0, 1.1, 0.0, 0.0, -1)
            ShowSyncHudMsg(ID_SHOWHUD, g_MsgSync, "Level: %d | XP: %0.2f %", g_iLevel[ID_SHOWHUD], (float(g_iXP[ID_SHOWHUD])/float(g_iMaxXP[ID_SHOWHUD])) * 100.0)
        }
    }
    else
    {
        if(iPlayer != ID_SHOWHUD)
        {
            if (get_pcvar_num(g_pCvarAddCommas) == 1)
            {
                new szSpecXP[15], szSpecMaxXP[15]
               
                AddCommas(g_iXP[iPlayer], szSpecXP, charsmax(szSpecXP))
                AddCommas(g_iMaxXP[iPlayer], szSpecMaxXP, charsmax(szSpecMaxXP))
               
                set_hudmessage(HUD_STATS_SPEC_R, HUD_STATS_SPEC_G, HUD_STATS_SPEC_B, HUD_SPECT_X, HUD_SPECT_Y, 0, 6.0, 1.1, 0.0, 0.0, -1)
                ShowSyncHudMsg(ID_SHOWHUD, g_MsgSync, "Level: %d | XP: %s/%s", g_iLevel[iPlayer], szSpecXP, szSpecMaxXP)
            }
            else
            {
                set_hudmessage(HUD_STATS_SPEC_R, HUD_STATS_SPEC_G, HUD_STATS_SPEC_B, HUD_SPECT_X, HUD_SPECT_Y, 0, 6.0, 1.1, 0.0, 0.0, -1)
                ShowSyncHudMsg(ID_SHOWHUD, g_MsgSync, "Level: %d | XP: %d/%d", g_iLevel[iPlayer], g_iXP[iPlayer], g_iMaxXP[iPlayer])
            }  
        }
        else if (ze_is_user_zombie(iPlayer))
        {
            if (get_pcvar_num(g_pCvarAddCommas) == 1)
            {
                new szZombieXP[15], szZombieMaxXP[15]
               
                AddCommas(g_iXP[ID_SHOWHUD], szZombieXP, charsmax(szZombieXP))
                AddCommas(g_iMaxXP[ID_SHOWHUD], szZombieMaxXP, charsmax(szZombieMaxXP))
               
                set_hudmessage(HUD_STATS_ZOMBIE_R, HUD_STATS_ZOMBIE_G, HUD_STATS_ZOMBIE_B, HUD_STATS_X, HUD_STATS_Y, 0, 6.0, 1.1, 0.0, 0.0, -1)
                ShowSyncHudMsg(ID_SHOWHUD, g_MsgSync, "Level: %d | XP: %s/%s", g_iLevel[ID_SHOWHUD], szZombieXP, szZombieMaxXP)
            }
            else
            {
                set_hudmessage(HUD_STATS_ZOMBIE_R, HUD_STATS_ZOMBIE_G, HUD_STATS_ZOMBIE_B, HUD_STATS_X, HUD_STATS_Y, 0, 6.0, 1.1, 0.0, 0.0, -1)
                ShowSyncHudMsg(ID_SHOWHUD, g_MsgSync, "Level: %d | XP: %d/%d", g_iLevel[ID_SHOWHUD], g_iXP[ID_SHOWHUD], g_iMaxXP[ID_SHOWHUD])
            }
        }
        else
        {
            if (get_pcvar_num(g_pCvarAddCommas) == 1)
            {
                new szHumanXP[15], szHumanMaxXP[15]
               
                AddCommas(g_iXP[ID_SHOWHUD], szHumanXP, charsmax(szHumanXP))
                AddCommas(g_iMaxXP[ID_SHOWHUD], szHumanMaxXP, charsmax(szHumanMaxXP))
               
                set_hudmessage(HUD_STATS_HUMAN_R, HUD_STATS_HUMAN_G, HUD_STATS_HUMAN_B, HUD_STATS_X, HUD_STATS_Y, 0, 6.0, 1.1, 0.0, 0.0, -1)
                ShowSyncHudMsg(ID_SHOWHUD, g_MsgSync, "Level: %d | XP: %s/%s", g_iLevel[ID_SHOWHUD], szHumanXP, szHumanMaxXP)
            }
            else
            {
                set_hudmessage(HUD_STATS_HUMAN_R, HUD_STATS_HUMAN_G, HUD_STATS_HUMAN_B, HUD_STATS_X, HUD_STATS_Y, 0, 6.0, 1.1, 0.0, 0.0, -1)
                ShowSyncHudMsg(ID_SHOWHUD, g_MsgSync, "Level: %d | XP: %d/%d", g_iLevel[ID_SHOWHUD], g_iXP[ID_SHOWHUD], g_iMaxXP[ID_SHOWHUD])
            }
        }
    }
}
 
public ze_roundend(WinTeam)
{
    if (WinTeam == ZE_TEAM_HUMAN)
    {
        new iXP = g_bIsDoubleHours ? (get_pcvar_num(g_pCvarEscapeSuccess) * 2) : get_pcvar_num(g_pCvarEscapeSuccess)

        for(new id = 1; id <= get_member_game(m_nMaxPlayers); id++)
        {
            if (!is_user_alive(id) || ze_is_user_zombie(id))
                continue
           
            Reward(id, (g_iXP[id] + iXP))
        }
    }
   
    remove_task(TASK_SHOWHUD)
}
 
public Check_User_Level(id)
{
    if (!is_user_connected(id))
        return
 
    if (g_iLevel[id] < MAX_LEVEL)
    {
    	new szName[32]

        while (g_iXP[id] > g_iMaxXP[id])
        {
            if (get_pcvar_num(g_pCvarStartFromZero) == 1)
            {
                g_iXP[id] = 0
            }

        	g_iLevel[id]++
        	g_iMaxXP[id] = g_iMaxLevelsXP[g_iLevel[id]]
            get_user_name(id, szName, charsmax(szName))
            ze_colored_print(0, "!g%s !tNow in Level %i!y!", szName, g_iLevel[id])
            ExecuteForward(Fw_LevelUP, ForwardReturn, id)
            SaveData(id)
            PlaySound(id, LEVELUP)
           
            if (get_pcvar_num(g_pCvarLevelEffects) != 0)
            {
                // Screen Fade
                message_begin(MSG_ONE, get_user_msgid("ScreenFade"), {0,0,0}, id)
                write_short(4096*2)
                write_short(4096*5)
                write_short(0x0001)
                write_byte(random(256))
                write_byte(random(256))
                write_byte(random(256))
                write_byte(150)
                message_end()
               
                // Screen Shake
                message_begin(MSG_ONE, get_user_msgid("ScreenShake"), {0,0,0}, id)
                write_short(255<<14)
                write_short(10<<14)
                write_short(255<<14)
                message_end()
            }
        }
    }
}
 
public ze_user_infected(iVictim, iInfector)
{
    if (iInfector == 0)
        return
 
    new iXP = g_bIsDoubleHours ? (get_pcvar_num(g_pCvarZombieInfect) * 2) : get_pcvar_num(g_pCvarZombieInfect)
    Reward(iInfector, (g_iXP[iInfector] + iXP))
}
 
public Fw_TakeDamage_Post(iVictim, iInflictor, iAttacker, Float:fDamage, bitsDamageType)
{
    // Player Damage Himself
    if (iVictim == iAttacker || !is_user_alive(iVictim) || !is_user_alive(iAttacker) || ze_is_user_zombie(iAttacker) || !get_pcvar_num(g_pCvarEnableDamage))
        return HC_CONTINUE
   
    // Same Team?
    if (get_member(iAttacker, m_iTeam) == get_member(iVictim, m_iTeam))
        return HC_CONTINUE
   
    // Store Damage For every Player
    g_fDamage[iAttacker] += fDamage
   
    // Damage Calculator Equal or Higher than needed damage
    if (g_fDamage[iAttacker] >= get_pcvar_float(g_pCvarRequiredDamage))
    {
        // Player did damage that a multiplication of the cvar? Increase coins by this factor
        new iMultiplier = floatround(g_fDamage[iAttacker] / get_pcvar_float(g_pCvarRequiredDamage))
        new iXP = ((g_bIsDoubleHours ? (get_pcvar_num(g_pCvarDamageAward) * 2) : get_pcvar_num(g_pCvarDamageAward)) * iMultiplier)
        Reward(iAttacker, (g_iXP[iAttacker] + iXP))
       
        // Rest The Damage Calculator
        g_fDamage[iAttacker] = 0.0
    }
    return HC_CONTINUE
}
 
public Reward(id, XP)
{
    if ((g_iLevel[id] + 1) < MAX_LEVEL)
    {
        g_iXP[id] = XP
        Check_User_Level(id)
    }
    else
    {
    	if ((g_iXP[id] + XP) >= g_iMaxLevelsXP[MAX_LEVEL - 1])
        {
            g_iXP[id] = g_iMaxXP[id] = g_iMaxLevelsXP[MAX_LEVEL - 1]
        }
    }
    SaveData(id)
}
 
public SaveData(id)
{
    new szAuthID[35], szName[32]
    get_user_authid(id, szAuthID, charsmax(szAuthID))
    get_user_name(id, szName, charsmax(szName))
 
    if (!get_pcvar_num(g_pCvarSaveType))
    {
        new szData[256]
        formatex(szData , charsmax(szData), "%i %i", g_iLevel[id], g_iXP[id])
       
        // Open the Vaults
        g_iLevelsVaultHandle = nvault_open(g_szLevelsVault)
        g_iRanksVaultHandle = nvault_open(g_szRanksVault)
 
        // Saves His Data
        nvault_set(g_iLevelsVaultHandle, szAuthID, szData)
        nvault_set(g_iRanksVaultHandle, szAuthID, szName)
       
        // Close Vaults
        nvault_close(g_iLevelsVaultHandle)
        nvault_close(g_iRanksVaultHandle)
    }
    else
    {
        new szQuery[128]
        formatex(szQuery, charsmax(szQuery), "UPDATE `zombie_escape` SET `Level` = '%d', `XP` = '%d' WHERE ( `SteamID` = '%s' );", g_iLevel[id], g_iXP[id], szAuthID)
        SQL_ThreadQuery(g_hTuple, "QuerySetData", szQuery)
    }
}
 
public QuerySetData(iFailState, Handle:hQuery, szError[], iError, szData[], iSize, Float:flQueueTime)
{
    SQL_IsFail(iFailState, iError, szError, g_szLogFile)
}
 
public QuerySetData2(iFailState, Handle:hQuery, szError[], iError, szData[], iSize, Float:flQueueTime)
{
    SQL_IsFail(iFailState, iError, szError, g_szLogFile)
}
 
public LoadData(id)
{
    new szAuthID[35]
   
    get_user_authid(id, szAuthID, charsmax(szAuthID))
   
    if (!get_pcvar_num(g_pCvarSaveType))
    {
        new szData[256], iTimestamp, iExists
       
        // Open the Vault
        g_iLevelsVaultHandle = nvault_open(g_szLevelsVault)
       
        iExists = nvault_lookup(g_iLevelsVaultHandle, szAuthID, szData, charsmax(szData), iTimestamp)
       
        // Close Vault
        nvault_close(g_iLevelsVaultHandle)
       
        if (!iExists)
        {
            g_iLevel[id] = 0
            g_iXP[id] = get_pcvar_num(g_pCvarStartXP)
            SaveData(id)
        }
        else
        {
            new iLevel[32], iXP[32]
            parse(szData, iLevel, 31, iXP, 31)
           
            g_iLevel[id] = str_to_num(iLevel)
            g_iXP[id] = str_to_num(iXP)
        }
 
        g_iMaxXP[id] = g_iMaxLevelsXP[g_iLevel[id]]
    }
    else
    {
        new szQuery[128], szData[5]
        formatex(szQuery, charsmax(szQuery), "SELECT * FROM `zombie_escape` WHERE ( `SteamID` = '%s' );", szAuthID)
   
        num_to_str(id, szData, charsmax(szData))
        SQL_ThreadQuery(g_hTuple, "QuerySelectData", szQuery, szData, charsmax(szData))
    }
}
 
public QuerySelectData(iFailState, Handle:hQuery, szError[], iError, szData[])
{
    if (SQL_IsFail(iFailState, iError, szError, g_szLogFile))
        return
   
    new id = str_to_num(szData)
   
    // No results for this query means this is new player
    if (!SQL_NumResults(hQuery))
    {
        g_iLevel[id] = 0
        g_iXP[id] = get_pcvar_num(g_pCvarStartXP)
    }
    else
    {
        g_iLevel[id] = SQL_ReadResult(hQuery, SQL_FieldNameToNum(hQuery, "Level"))
        g_iXP[id] = SQL_ReadResult(hQuery, SQL_FieldNameToNum(hQuery, "XP"))
    }
 
    g_iMaxXP[id] = g_iMaxLevelsXP[g_iLevel[id]]
}
 
public native_ze_get_user_xp(id)
{
    if(!is_user_connected(id))
    {
        log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player id (%d)", id)
        return false;
    }
   
    return g_iXP[id]
}
 
public native_ze_set_user_xp(id, amount)
{
    if(!is_user_connected(id))
    {
        log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player id (%d)", id)
        return false
    }
    
    DoubleHours()
    new addedXP = (amount - g_iXP[id])
    new iXP = g_bIsDoubleHours ? (addedXP * 2) : addedXP
    Reward(id, g_iXP[id] + iXP)
    return true
}
 
public native_ze_get_user_level(id)
{
    if(!is_user_connected(id))
    {
        log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player id (%d)", id)
        return false;
    }
   
    return g_iLevel[id]
}
 
public native_ze_set_user_level(id, amount)
{
    if(!is_user_connected(id))
    {
        log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player id (%d)", id)
        return false
    }
   
    if (amount > MAX_LEVEL)
    {
        log_error(AMX_ERR_NATIVE, "Level must be less than or equal to MAX_LEVEL (%d)", MAX_LEVEL)
        return false
    }
 
    g_iLevel[id] = amount
   
    if (get_pcvar_num(g_pCvarStartFromZero) == 1)
    {
        g_iXP[id] = 0
    }
    SaveData(id)
   
    return true
}
 
public native_ze_get_user_max_xp(id)
{
    if(!is_user_connected(id))
    {
        log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player id (%d)", id)
        return false
    }
   
    return g_iMaxXP[id]
}
 
stock DoubleHours()
{
    new szTime[3], szDoubleHours[32], szDoubleHours_Start[32], szDoubleHours_End[32]
    get_time("%H", szTime, charsmax(szTime))
   
    get_pcvar_string(g_pCvarDoubleXP, szDoubleHours, charsmax(szDoubleHours))
   
    for (new ch = 0; ch <= charsmax(szDoubleHours); ch++)
    {
        if (szDoubleHours[ch] == '-')
            szDoubleHours[ch] = ' '
    }
   
    parse(szDoubleHours, szDoubleHours_Start, charsmax(szDoubleHours_Start), szDoubleHours_End, charsmax(szDoubleHours_End))
   
    new iTime, iDoubleHourStart, iDoubleHourEnd
   
    iTime = str_to_num(szTime)
    iDoubleHourStart = str_to_num(szDoubleHours_Start)
    iDoubleHourEnd = str_to_num(szDoubleHours_End)
   
    if (iDoubleHourEnd > iTime >= iDoubleHourStart)
    {
        g_bIsDoubleHours = true
    }
    else
    {
        g_bIsDoubleHours = false
    }
}
@karan PLease Help I am not getiing xp while escape but i getting xp on damage i dont know why!!
try using no max xp level system nd see viewtopic.php?f=15&t=72
Image

VicKy
Mod Tester
Mod Tester
Pakistan
Posts: 82
Joined: 1 Year Ago
Has thanked: 14 times
Been thanked: 11 times
Age: 19
Contact:

#142

Post by VicKy » 3 Months Ago

karan wrote:
3 Months Ago
VicKy wrote:
3 Months Ago
czirimbolo wrote:
2 Years Ago
Ok here is fixed version of level system by Jack and Raheem. Double exp is working too.

Code: Select all

#include <zombie_escape>
 
// Defines
#define MAX_LEVEL 41
#define TASK_SHOWHUD 2020
#define TASK_DOUBLE 1133
#define REPEAT_TIME 60.0
#define ID_SHOWHUD (taskid - TASK_SHOWHUD)
#define LEVELUP "levelup_ZE/ze_levelup.wav"
 
enum
{
    Host = 0,
    User,
    Pass,
    DB
}
 
new const g_iMaxLevelsXP[MAX_LEVEL] =
{
    3000, // 1
    3500, // 2
    5000, // 3
    7500, // 4
    11000, // 5
    15000, // 6
    20000, // 7
    25000, // 8
    30000, // 9
    40000, // 10
    50000, // 11
    60000, // 12
    75000, // 13
    90000, // 14
    105000, // 15
    120000, // 16
    140000, // 17
    170000, // 18
    200000, // 19
    275000, // 20
    350000, // 21
    500000, // 22
    1000000, // 23
    1750000, // 24
    3000000, // 25
    6000000, // 26
    10000000, // 27
    15000000, // 28
    20000000, // 29
    30000000, // 30
    40000000, // 31		
    62000000, // 32
    75000000, // 33
    90000000, // 34
    105000000, // 35
    125000000, // 36
    135000000, // 37
    155000000, // 38
    175000000, // 39
    200000000, // 40		
    300000000 // 41
}
 
// Constants
new const g_szLevelsVault[] = "Levels"
new const g_szRanksVault[] = "Ranks"
new const g_szLogFile[] = "Levels.log" // MySQL Errors log file
new const g_szTable[] =
" \
    ALTER TABLE `test` \
    ADD IF NOT EXISTS `Level` int(20) NOT NULL DEFAULT '0', \
    ADD IF NOT EXISTS `XP` int(20) NOT NULL DEFAULT '0'; \
"
 
// Messages
const Float:HUD_SPECT_X = -1.0
const Float:HUD_SPECT_Y = 0.70
const Float:HUD_STATS_X = 0.01
const Float:HUD_STATS_Y = 0.22
 
const HUD_STATS_ZOMBIE_R = 200
const HUD_STATS_ZOMBIE_G = 220
const HUD_STATS_ZOMBIE_B = 0
 
const HUD_STATS_HUMAN_R = 0
const HUD_STATS_HUMAN_G = 200
const HUD_STATS_HUMAN_B = 210
 
const HUD_STATS_SPEC_R = 100
const HUD_STATS_SPEC_G = 100
const HUD_STATS_SPEC_B = 100
 
// Variables
new g_iLevel[33],
    g_iXP[33],
    g_iMaxXP[33],
    Float:g_fDamage[33],
    g_MsgSync,
    g_iLevelsVaultHandle,
    g_iRanksVaultHandle,
    Handle:g_hTuple,
    Fw_LevelUP,
    ForwardReturn,
    bool:g_bIsDoubleHours
 
// Cvars
new g_pCvarZombieInfect,
    g_pCvarEscapeSuccess,
    g_pCvarEnableDamage,
    g_pCvarRequiredDamage,
    g_pCvarDamageAward,
    g_pCvarStartXP,
    g_pCvarPercentageStyle,
    g_pCvarStartFromZero,
    g_pCvarAddCommas,
    g_pCvarLevelEffects,
    g_pCvarSaveType,
    g_pCvarDBInfo[4],
    g_pCvarDoubleXP
 
public plugin_natives()
{
    register_native("ze_get_user_xp", "native_ze_get_user_xp", 1)
    register_native("ze_set_user_xp", "native_ze_set_user_xp", 1)
    register_native("ze_get_user_level", "native_ze_get_user_level", 1)
    register_native("ze_set_user_level", "native_ze_set_user_level", 1)
    register_native("ze_get_user_max_xp", "native_ze_get_user_max_xp", 1)
}
 
public plugin_precache()
{
    precache_sound(LEVELUP)
}
 
public plugin_init()
{
    register_plugin("[ZE] Level-XP System", "1.9", "Raheem/JaCk")
   
    // Hook Chains
    RegisterHookChain(RG_CBasePlayer_TakeDamage, "Fw_TakeDamage_Post", 1)
 
    Fw_LevelUP = CreateMultiForward("ze_on_levelup", ET_IGNORE, FP_CELL)
   
    // Cvars
    g_pCvarZombieInfect = register_cvar("ze_zombie_infect", "3")
    g_pCvarEscapeSuccess = register_cvar("ze_escape_success", "5")
    g_pCvarEnableDamage = register_cvar("ze_enable_dmg", "1")
    g_pCvarRequiredDamage = register_cvar("ze_required_dmg", "50.0")
    g_pCvarDamageAward = register_cvar("ze_dmg_award", "3")
    g_pCvarStartXP = register_cvar("ze_start_xp", "0")
    g_pCvarPercentageStyle = register_cvar("ze_enable_percentage_style", "0")
    g_pCvarStartFromZero = register_cvar("ze_new_level_zero_xp", "0")
    g_pCvarAddCommas = register_cvar("ze_add_commas_to_xp", "1")
    g_pCvarLevelEffects = register_cvar("ze_level_up_effects", "0")
    g_pCvarDoubleXP = register_cvar("ze_double_xp", "15-22")
 
    g_pCvarSaveType = register_cvar("ze_levels_save_type", "0")
    g_pCvarDBInfo[Host] = register_cvar("ze_levels_host", "127.0.0.1")
    g_pCvarDBInfo[User] = register_cvar("ze_levels_user", "root")
    g_pCvarDBInfo[Pass] = register_cvar("ze_levels_pass", "password")
    g_pCvarDBInfo[DB] = register_cvar("ze_levels_dbname", "levels_db")
   
    // Messages
    g_MsgSync = CreateHudSyncObj()
 
    if (get_pcvar_num(g_pCvarSaveType))
    {
        set_task(0.1, "Delay_MySQL_Init")
    }

    DoubleHours()

    if (g_bIsDoubleHours)
    {
        set_task(REPEAT_TIME, "HappyHours", TASK_DOUBLE, _, _, "b")
    }
}
 
public plugin_end()
{
    if (get_pcvar_num(g_pCvarSaveType))
    {
        if (g_hTuple != Empty_Handle)
        {
            SQL_FreeHandle(g_hTuple)
        }
    }
}
 
public Delay_MySQL_Init()
{
    MySQL_Init()
}
 
public MySQL_Init()
{
    if (!get_pcvar_num(g_pCvarSaveType))
        return
   
    new szHost[64], szUser[32], szPass[32], szDB[128]
   
    get_pcvar_string(g_pCvarDBInfo[Host], szHost, charsmax(szHost))
    get_pcvar_string(g_pCvarDBInfo[User], szUser, charsmax(szUser))
    get_pcvar_string(g_pCvarDBInfo[Pass], szPass, charsmax(szPass))
    get_pcvar_string(g_pCvarDBInfo[DB], szDB, charsmax(szDB))
   
    g_hTuple = SQL_MakeDbTuple(szHost, szUser, szPass, szDB)
   
    // Let's ensure that the g_hTuple will be valid, we will access the database to make sure
    new iErrorCode, szError[512], Handle:hSQLConnection
   
    hSQLConnection = SQL_Connect(g_hTuple, iErrorCode, szError, charsmax(szError))
   
    if (hSQLConnection != Empty_Handle)
    {
        log_amx("[MySQL][LVL] Successfully connected to host: %s (ALL IS OK).", szHost)
        SQL_FreeHandle(hSQLConnection)
    }
    else
    {
        // Disable plugin
        set_fail_state("[LVL] Failed to connect to MySQL database: %s.", szError)
    }
   
    SQL_ThreadQuery(g_hTuple, "QueryCreateTable", g_szTable)
}
 
public QueryCreateTable(iFailState, Handle:hQuery, szError[], iError, szData[], iSize, Float:flQueueTime)
{
    SQL_IsFail(iFailState, iError, szError, g_szLogFile)
}
 
public client_putinserver(id)
{
    if(is_user_hltv(id) || is_user_bot(id))
        return
   
    // Just 1 second delay
    set_task(1.0, "DelayLoad", id)
 
    // Other tasks
    set_task(1.0, "Show_Hud", id+TASK_SHOWHUD, _, _, "b")
   
    if (g_bIsDoubleHours)
    {
        set_task(REPEAT_TIME, "HappyHours", id+TASK_DOUBLE, _, _, "b")
    }
}
 
public HappyHours(taskid)
{
    DoubleHours()

    if (!g_bIsDoubleHours)
        remove_task(taskid)
   
    new szDoubleHours[32]
   
    get_pcvar_string(g_pCvarDoubleXP, szDoubleHours, charsmax(szDoubleHours))
   
    set_dhudmessage(0, 255, 0, -1.0, 0.20, 0, 0.0, 10.0)
    show_dhudmessage(0, "DOUBLE XP: %s", szDoubleHours)
}
 
public DelayLoad(id)
{
    // Load his data
    LoadData(id)
}
 
public client_disconnected(id)
{
    if(is_user_hltv(id) || is_user_bot(id))
        return
       
    remove_task(id+TASK_SHOWHUD)
    remove_task(id)
}
 
public Show_Hud(taskid)
{  
    new iPlayer = ID_SHOWHUD
   
    if (!is_user_alive(iPlayer))
    {
        iPlayer = pev(iPlayer, pev_iuser2)
       
        if (!is_user_alive(iPlayer))
            return
    }
   
    if (get_pcvar_num(g_pCvarPercentageStyle) != 0)
    {
        if(iPlayer != ID_SHOWHUD)
        {
            set_hudmessage(HUD_STATS_SPEC_R, HUD_STATS_SPEC_G, HUD_STATS_SPEC_B, HUD_SPECT_X, HUD_SPECT_Y, 0, 6.0, 1.1, 0.0, 0.0, -1)
            ShowSyncHudMsg(ID_SHOWHUD, g_MsgSync, "Level: %d | XP: %0.2f %", g_iLevel[iPlayer], (float(g_iXP[iPlayer])/float(g_iMaxXP[iPlayer])) * 100.0)
        }
        else if (ze_is_user_zombie(iPlayer))
        {
            set_hudmessage(HUD_STATS_ZOMBIE_R, HUD_STATS_ZOMBIE_G, HUD_STATS_ZOMBIE_B, HUD_STATS_X, HUD_STATS_Y, 0, 6.0, 1.1, 0.0, 0.0, -1)
            ShowSyncHudMsg(ID_SHOWHUD, g_MsgSync, "Level: %d | XP: %0.2f %", g_iLevel[ID_SHOWHUD], (float(g_iXP[ID_SHOWHUD])/float(g_iMaxXP[ID_SHOWHUD])) * 100.0)
        }
        else
        {
            set_hudmessage(HUD_STATS_HUMAN_R, HUD_STATS_HUMAN_G, HUD_STATS_HUMAN_B, HUD_STATS_X, HUD_STATS_Y, 0, 6.0, 1.1, 0.0, 0.0, -1)
            ShowSyncHudMsg(ID_SHOWHUD, g_MsgSync, "Level: %d | XP: %0.2f %", g_iLevel[ID_SHOWHUD], (float(g_iXP[ID_SHOWHUD])/float(g_iMaxXP[ID_SHOWHUD])) * 100.0)
        }
    }
    else
    {
        if(iPlayer != ID_SHOWHUD)
        {
            if (get_pcvar_num(g_pCvarAddCommas) == 1)
            {
                new szSpecXP[15], szSpecMaxXP[15]
               
                AddCommas(g_iXP[iPlayer], szSpecXP, charsmax(szSpecXP))
                AddCommas(g_iMaxXP[iPlayer], szSpecMaxXP, charsmax(szSpecMaxXP))
               
                set_hudmessage(HUD_STATS_SPEC_R, HUD_STATS_SPEC_G, HUD_STATS_SPEC_B, HUD_SPECT_X, HUD_SPECT_Y, 0, 6.0, 1.1, 0.0, 0.0, -1)
                ShowSyncHudMsg(ID_SHOWHUD, g_MsgSync, "Level: %d | XP: %s/%s", g_iLevel[iPlayer], szSpecXP, szSpecMaxXP)
            }
            else
            {
                set_hudmessage(HUD_STATS_SPEC_R, HUD_STATS_SPEC_G, HUD_STATS_SPEC_B, HUD_SPECT_X, HUD_SPECT_Y, 0, 6.0, 1.1, 0.0, 0.0, -1)
                ShowSyncHudMsg(ID_SHOWHUD, g_MsgSync, "Level: %d | XP: %d/%d", g_iLevel[iPlayer], g_iXP[iPlayer], g_iMaxXP[iPlayer])
            }  
        }
        else if (ze_is_user_zombie(iPlayer))
        {
            if (get_pcvar_num(g_pCvarAddCommas) == 1)
            {
                new szZombieXP[15], szZombieMaxXP[15]
               
                AddCommas(g_iXP[ID_SHOWHUD], szZombieXP, charsmax(szZombieXP))
                AddCommas(g_iMaxXP[ID_SHOWHUD], szZombieMaxXP, charsmax(szZombieMaxXP))
               
                set_hudmessage(HUD_STATS_ZOMBIE_R, HUD_STATS_ZOMBIE_G, HUD_STATS_ZOMBIE_B, HUD_STATS_X, HUD_STATS_Y, 0, 6.0, 1.1, 0.0, 0.0, -1)
                ShowSyncHudMsg(ID_SHOWHUD, g_MsgSync, "Level: %d | XP: %s/%s", g_iLevel[ID_SHOWHUD], szZombieXP, szZombieMaxXP)
            }
            else
            {
                set_hudmessage(HUD_STATS_ZOMBIE_R, HUD_STATS_ZOMBIE_G, HUD_STATS_ZOMBIE_B, HUD_STATS_X, HUD_STATS_Y, 0, 6.0, 1.1, 0.0, 0.0, -1)
                ShowSyncHudMsg(ID_SHOWHUD, g_MsgSync, "Level: %d | XP: %d/%d", g_iLevel[ID_SHOWHUD], g_iXP[ID_SHOWHUD], g_iMaxXP[ID_SHOWHUD])
            }
        }
        else
        {
            if (get_pcvar_num(g_pCvarAddCommas) == 1)
            {
                new szHumanXP[15], szHumanMaxXP[15]
               
                AddCommas(g_iXP[ID_SHOWHUD], szHumanXP, charsmax(szHumanXP))
                AddCommas(g_iMaxXP[ID_SHOWHUD], szHumanMaxXP, charsmax(szHumanMaxXP))
               
                set_hudmessage(HUD_STATS_HUMAN_R, HUD_STATS_HUMAN_G, HUD_STATS_HUMAN_B, HUD_STATS_X, HUD_STATS_Y, 0, 6.0, 1.1, 0.0, 0.0, -1)
                ShowSyncHudMsg(ID_SHOWHUD, g_MsgSync, "Level: %d | XP: %s/%s", g_iLevel[ID_SHOWHUD], szHumanXP, szHumanMaxXP)
            }
            else
            {
                set_hudmessage(HUD_STATS_HUMAN_R, HUD_STATS_HUMAN_G, HUD_STATS_HUMAN_B, HUD_STATS_X, HUD_STATS_Y, 0, 6.0, 1.1, 0.0, 0.0, -1)
                ShowSyncHudMsg(ID_SHOWHUD, g_MsgSync, "Level: %d | XP: %d/%d", g_iLevel[ID_SHOWHUD], g_iXP[ID_SHOWHUD], g_iMaxXP[ID_SHOWHUD])
            }
        }
    }
}
 
public ze_roundend(WinTeam)
{
    if (WinTeam == ZE_TEAM_HUMAN)
    {
        new iXP = g_bIsDoubleHours ? (get_pcvar_num(g_pCvarEscapeSuccess) * 2) : get_pcvar_num(g_pCvarEscapeSuccess)

        for(new id = 1; id <= get_member_game(m_nMaxPlayers); id++)
        {
            if (!is_user_alive(id) || ze_is_user_zombie(id))
                continue
           
            Reward(id, (g_iXP[id] + iXP))
        }
    }
   
    remove_task(TASK_SHOWHUD)
}
 
public Check_User_Level(id)
{
    if (!is_user_connected(id))
        return
 
    if (g_iLevel[id] < MAX_LEVEL)
    {
    	new szName[32]

        while (g_iXP[id] > g_iMaxXP[id])
        {
            if (get_pcvar_num(g_pCvarStartFromZero) == 1)
            {
                g_iXP[id] = 0
            }

        	g_iLevel[id]++
        	g_iMaxXP[id] = g_iMaxLevelsXP[g_iLevel[id]]
            get_user_name(id, szName, charsmax(szName))
            ze_colored_print(0, "!g%s !tNow in Level %i!y!", szName, g_iLevel[id])
            ExecuteForward(Fw_LevelUP, ForwardReturn, id)
            SaveData(id)
            PlaySound(id, LEVELUP)
           
            if (get_pcvar_num(g_pCvarLevelEffects) != 0)
            {
                // Screen Fade
                message_begin(MSG_ONE, get_user_msgid("ScreenFade"), {0,0,0}, id)
                write_short(4096*2)
                write_short(4096*5)
                write_short(0x0001)
                write_byte(random(256))
                write_byte(random(256))
                write_byte(random(256))
                write_byte(150)
                message_end()
               
                // Screen Shake
                message_begin(MSG_ONE, get_user_msgid("ScreenShake"), {0,0,0}, id)
                write_short(255<<14)
                write_short(10<<14)
                write_short(255<<14)
                message_end()
            }
        }
    }
}
 
public ze_user_infected(iVictim, iInfector)
{
    if (iInfector == 0)
        return
 
    new iXP = g_bIsDoubleHours ? (get_pcvar_num(g_pCvarZombieInfect) * 2) : get_pcvar_num(g_pCvarZombieInfect)
    Reward(iInfector, (g_iXP[iInfector] + iXP))
}
 
public Fw_TakeDamage_Post(iVictim, iInflictor, iAttacker, Float:fDamage, bitsDamageType)
{
    // Player Damage Himself
    if (iVictim == iAttacker || !is_user_alive(iVictim) || !is_user_alive(iAttacker) || ze_is_user_zombie(iAttacker) || !get_pcvar_num(g_pCvarEnableDamage))
        return HC_CONTINUE
   
    // Same Team?
    if (get_member(iAttacker, m_iTeam) == get_member(iVictim, m_iTeam))
        return HC_CONTINUE
   
    // Store Damage For every Player
    g_fDamage[iAttacker] += fDamage
   
    // Damage Calculator Equal or Higher than needed damage
    if (g_fDamage[iAttacker] >= get_pcvar_float(g_pCvarRequiredDamage))
    {
        // Player did damage that a multiplication of the cvar? Increase coins by this factor
        new iMultiplier = floatround(g_fDamage[iAttacker] / get_pcvar_float(g_pCvarRequiredDamage))
        new iXP = ((g_bIsDoubleHours ? (get_pcvar_num(g_pCvarDamageAward) * 2) : get_pcvar_num(g_pCvarDamageAward)) * iMultiplier)
        Reward(iAttacker, (g_iXP[iAttacker] + iXP))
       
        // Rest The Damage Calculator
        g_fDamage[iAttacker] = 0.0
    }
    return HC_CONTINUE
}
 
public Reward(id, XP)
{
    if ((g_iLevel[id] + 1) < MAX_LEVEL)
    {
        g_iXP[id] = XP
        Check_User_Level(id)
    }
    else
    {
    	if ((g_iXP[id] + XP) >= g_iMaxLevelsXP[MAX_LEVEL - 1])
        {
            g_iXP[id] = g_iMaxXP[id] = g_iMaxLevelsXP[MAX_LEVEL - 1]
        }
    }
    SaveData(id)
}
 
public SaveData(id)
{
    new szAuthID[35], szName[32]
    get_user_authid(id, szAuthID, charsmax(szAuthID))
    get_user_name(id, szName, charsmax(szName))
 
    if (!get_pcvar_num(g_pCvarSaveType))
    {
        new szData[256]
        formatex(szData , charsmax(szData), "%i %i", g_iLevel[id], g_iXP[id])
       
        // Open the Vaults
        g_iLevelsVaultHandle = nvault_open(g_szLevelsVault)
        g_iRanksVaultHandle = nvault_open(g_szRanksVault)
 
        // Saves His Data
        nvault_set(g_iLevelsVaultHandle, szAuthID, szData)
        nvault_set(g_iRanksVaultHandle, szAuthID, szName)
       
        // Close Vaults
        nvault_close(g_iLevelsVaultHandle)
        nvault_close(g_iRanksVaultHandle)
    }
    else
    {
        new szQuery[128]
        formatex(szQuery, charsmax(szQuery), "UPDATE `zombie_escape` SET `Level` = '%d', `XP` = '%d' WHERE ( `SteamID` = '%s' );", g_iLevel[id], g_iXP[id], szAuthID)
        SQL_ThreadQuery(g_hTuple, "QuerySetData", szQuery)
    }
}
 
public QuerySetData(iFailState, Handle:hQuery, szError[], iError, szData[], iSize, Float:flQueueTime)
{
    SQL_IsFail(iFailState, iError, szError, g_szLogFile)
}
 
public QuerySetData2(iFailState, Handle:hQuery, szError[], iError, szData[], iSize, Float:flQueueTime)
{
    SQL_IsFail(iFailState, iError, szError, g_szLogFile)
}
 
public LoadData(id)
{
    new szAuthID[35]
   
    get_user_authid(id, szAuthID, charsmax(szAuthID))
   
    if (!get_pcvar_num(g_pCvarSaveType))
    {
        new szData[256], iTimestamp, iExists
       
        // Open the Vault
        g_iLevelsVaultHandle = nvault_open(g_szLevelsVault)
       
        iExists = nvault_lookup(g_iLevelsVaultHandle, szAuthID, szData, charsmax(szData), iTimestamp)
       
        // Close Vault
        nvault_close(g_iLevelsVaultHandle)
       
        if (!iExists)
        {
            g_iLevel[id] = 0
            g_iXP[id] = get_pcvar_num(g_pCvarStartXP)
            SaveData(id)
        }
        else
        {
            new iLevel[32], iXP[32]
            parse(szData, iLevel, 31, iXP, 31)
           
            g_iLevel[id] = str_to_num(iLevel)
            g_iXP[id] = str_to_num(iXP)
        }
 
        g_iMaxXP[id] = g_iMaxLevelsXP[g_iLevel[id]]
    }
    else
    {
        new szQuery[128], szData[5]
        formatex(szQuery, charsmax(szQuery), "SELECT * FROM `zombie_escape` WHERE ( `SteamID` = '%s' );", szAuthID)
   
        num_to_str(id, szData, charsmax(szData))
        SQL_ThreadQuery(g_hTuple, "QuerySelectData", szQuery, szData, charsmax(szData))
    }
}
 
public QuerySelectData(iFailState, Handle:hQuery, szError[], iError, szData[])
{
    if (SQL_IsFail(iFailState, iError, szError, g_szLogFile))
        return
   
    new id = str_to_num(szData)
   
    // No results for this query means this is new player
    if (!SQL_NumResults(hQuery))
    {
        g_iLevel[id] = 0
        g_iXP[id] = get_pcvar_num(g_pCvarStartXP)
    }
    else
    {
        g_iLevel[id] = SQL_ReadResult(hQuery, SQL_FieldNameToNum(hQuery, "Level"))
        g_iXP[id] = SQL_ReadResult(hQuery, SQL_FieldNameToNum(hQuery, "XP"))
    }
 
    g_iMaxXP[id] = g_iMaxLevelsXP[g_iLevel[id]]
}
 
public native_ze_get_user_xp(id)
{
    if(!is_user_connected(id))
    {
        log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player id (%d)", id)
        return false;
    }
   
    return g_iXP[id]
}
 
public native_ze_set_user_xp(id, amount)
{
    if(!is_user_connected(id))
    {
        log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player id (%d)", id)
        return false
    }
    
    DoubleHours()
    new addedXP = (amount - g_iXP[id])
    new iXP = g_bIsDoubleHours ? (addedXP * 2) : addedXP
    Reward(id, g_iXP[id] + iXP)
    return true
}
 
public native_ze_get_user_level(id)
{
    if(!is_user_connected(id))
    {
        log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player id (%d)", id)
        return false;
    }
   
    return g_iLevel[id]
}
 
public native_ze_set_user_level(id, amount)
{
    if(!is_user_connected(id))
    {
        log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player id (%d)", id)
        return false
    }
   
    if (amount > MAX_LEVEL)
    {
        log_error(AMX_ERR_NATIVE, "Level must be less than or equal to MAX_LEVEL (%d)", MAX_LEVEL)
        return false
    }
 
    g_iLevel[id] = amount
   
    if (get_pcvar_num(g_pCvarStartFromZero) == 1)
    {
        g_iXP[id] = 0
    }
    SaveData(id)
   
    return true
}
 
public native_ze_get_user_max_xp(id)
{
    if(!is_user_connected(id))
    {
        log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player id (%d)", id)
        return false
    }
   
    return g_iMaxXP[id]
}
 
stock DoubleHours()
{
    new szTime[3], szDoubleHours[32], szDoubleHours_Start[32], szDoubleHours_End[32]
    get_time("%H", szTime, charsmax(szTime))
   
    get_pcvar_string(g_pCvarDoubleXP, szDoubleHours, charsmax(szDoubleHours))
   
    for (new ch = 0; ch <= charsmax(szDoubleHours); ch++)
    {
        if (szDoubleHours[ch] == '-')
            szDoubleHours[ch] = ' '
    }
   
    parse(szDoubleHours, szDoubleHours_Start, charsmax(szDoubleHours_Start), szDoubleHours_End, charsmax(szDoubleHours_End))
   
    new iTime, iDoubleHourStart, iDoubleHourEnd
   
    iTime = str_to_num(szTime)
    iDoubleHourStart = str_to_num(szDoubleHours_Start)
    iDoubleHourEnd = str_to_num(szDoubleHours_End)
   
    if (iDoubleHourEnd > iTime >= iDoubleHourStart)
    {
        g_bIsDoubleHours = true
    }
    else
    {
        g_bIsDoubleHours = false
    }
}
@karan PLease Help I am not getiing xp while escape but i getting xp on damage i dont know why!!
try using no max xp level system nd see viewtopic.php?f=15&t=72
I Used The Default One Maxx-Xp And No-Maxxp But Both Are Not Working ( no getting xp at escape ) i dont know why

code is :-
  1. #include <zombie_escape>
  2.  
  3. // Defines
  4. #define MAX_LEVEL 60
  5. #define MAX_XP 528029013
  6. #define TASK_SHOWHUD 2020
  7. #define ID_SHOWHUD (taskid - TASK_SHOWHUD)
  8. #define LEVELUP "levelup_ZE/ze_levelup.wav"
  9.  
  10. enum
  11. {
  12.     Host = 0,
  13.     User,
  14.     Pass,
  15.     DB
  16. }
  17.  
  18. // Constants
  19. new const g_szLevelsVault[] = "FuriX_LL"
  20. new const g_szRanksVault[] = "FuriX-RR"
  21. new const g_szLogFile[] = "Levels.log" // MySQL Errors log file
  22. new const g_szTable[] =
  23. " \
  24.     ALTER TABLE `test` \
  25.     ADD IF NOT EXISTS `Level` int(20) NOT NULL DEFAULT '0', \
  26.     ADD IF NOT EXISTS `XP` int(20) NOT NULL DEFAULT '0', \
  27.     ADD IF NOT EXISTS `Max_XP` int(20) NOT NULL DEFAULT '0'; \
  28. "
  29.  
  30. // Messages
  31. const Float:HUD_SPECT_X = -1.0
  32. const Float:HUD_SPECT_Y = 0.70
  33. const Float:HUD_STATS_X = -1.0
  34. const Float:HUD_STATS_Y = 0.90
  35.  
  36. const HUD_STATS_ZOMBIE_R = 200
  37. const HUD_STATS_ZOMBIE_G = 220
  38. const HUD_STATS_ZOMBIE_B = 0
  39.  
  40. const HUD_STATS_HUMAN_R = 0
  41. const HUD_STATS_HUMAN_G = 200
  42. const HUD_STATS_HUMAN_B = 210
  43.  
  44. const HUD_STATS_SPEC_R = 100
  45. const HUD_STATS_SPEC_G = 100
  46. const HUD_STATS_SPEC_B = 100
  47.  
  48. // Variables
  49. new g_iLevel[33],
  50.     g_iXP[33],
  51.     g_iMaxXP[33],
  52.     Float:g_fDamage[33],
  53.     g_MsgSync,
  54.     g_iLevelsVaultHandle,
  55.     g_iRanksVaultHandle,
  56.     Handle:g_hTuple,
  57.     Fw_LevelUP,
  58.     ForwardReturn
  59.  
  60. // Cvars
  61. new g_pCvarZombieInfect,
  62.     g_pCvarEscapeSuccess,
  63.     g_pCvarEnableDamage,
  64.     g_pCvarRequiredDamage,
  65.     g_pCvarDamageAward,
  66.     g_pCvarStartXP,
  67.     g_pCvarMaxLevelsIncrement,
  68.     g_pCvarMaxXPFirstLevel,
  69.     g_pCvarPercentageStyle,
  70.     g_pCvarStartFromZero,
  71.     g_pCvarAddCommas,
  72.     g_pCvarLevelEffects,
  73.     g_pCvarSaveType,
  74.     g_pCvarDBInfo[4]
  75.  
  76. public plugin_natives()
  77. {
  78.     register_native("ze_get_user_xp", "native_ze_get_user_xp", 1)
  79.     register_native("ze_set_user_xp", "native_ze_set_user_xp", 1)
  80.     register_native("ze_get_user_level", "native_ze_get_user_level", 1)
  81.     register_native("ze_set_user_level", "native_ze_set_user_level", 1)
  82.     register_native("ze_get_user_max_xp", "native_ze_get_user_max_xp", 1)
  83.     register_native("ze_set_user_max_xp", "native_ze_set_user_max_xp", 1)
  84. }
  85.  
  86. public plugin_precache()
  87. {
  88.     precache_sound(LEVELUP)
  89. }
  90.  
  91. public plugin_init()
  92. {
  93.     register_plugin("[ZE] Level-XP System", "1.9", "Raheem/JaCk")
  94.    
  95.     // Hook Chains
  96.     RegisterHookChain(RG_CBasePlayer_TakeDamage, "Fw_TakeDamage_Post", 1)
  97.  
  98.     Fw_LevelUP = CreateMultiForward("ze_on_levelup", ET_IGNORE, FP_CELL)
  99.    
  100.     // Cvars
  101.     g_pCvarZombieInfect = register_cvar("ze_zombie_infect", "0")
  102.     g_pCvarEscapeSuccess = register_cvar("ze_escape_success", "100")
  103.     g_pCvarEnableDamage = register_cvar("ze_enable_dmg", "1")
  104.     g_pCvarRequiredDamage = register_cvar("ze_required_dmg", "1000.0")
  105.     g_pCvarDamageAward = register_cvar("ze_dmg_award", "3")
  106.     g_pCvarStartXP = register_cvar("ze_start_xp", "50")
  107.     g_pCvarMaxLevelsIncrement = register_cvar("ze_maxlevels_increment", "1.3")
  108.     g_pCvarMaxXPFirstLevel = register_cvar("ze_max_xp_first_level", "100")
  109.     g_pCvarPercentageStyle = register_cvar("ze_enable_percentage_style", "0")
  110.     g_pCvarStartFromZero = register_cvar("ze_new_level_zero_xp", "0")
  111.     g_pCvarAddCommas = register_cvar("ze_add_commas_to_xp", "1")
  112.     g_pCvarLevelEffects = register_cvar("ze_level_up_effects", "1")
  113.     g_pCvarSaveType = register_cvar("ze_levels_save_type", "0")
  114.     g_pCvarDBInfo[Host] = register_cvar("ze_levels_host", "127.0.0.1")
  115.     g_pCvarDBInfo[User] = register_cvar("ze_levels_user", "root")
  116.     g_pCvarDBInfo[Pass] = register_cvar("ze_levels_pass", "password")
  117.     g_pCvarDBInfo[DB] = register_cvar("ze_levels_dbname", "levels_db")
  118.    
  119.     // Messages
  120.     g_MsgSync = CreateHudSyncObj()
  121.  
  122.     if (get_pcvar_num(g_pCvarSaveType))
  123.     {
  124.         set_task(0.1, "Delay_MySQL_Init")
  125.     }
  126. }
  127.  
  128. public plugin_end()
  129. {
  130.     if (get_pcvar_num(g_pCvarSaveType))
  131.     {
  132.         if (g_hTuple != Empty_Handle)
  133.         {
  134.             SQL_FreeHandle(g_hTuple)
  135.         }
  136.     }
  137. }
  138.  
  139. public Delay_MySQL_Init()
  140. {
  141.     MySQL_Init()
  142. }
  143.  
  144. public MySQL_Init()
  145. {
  146.     if (!get_pcvar_num(g_pCvarSaveType))
  147.         return
  148.    
  149.     new szHost[64], szUser[32], szPass[32], szDB[128]
  150.    
  151.     get_pcvar_string(g_pCvarDBInfo[Host], szHost, charsmax(szHost))
  152.     get_pcvar_string(g_pCvarDBInfo[User], szUser, charsmax(szUser))
  153.     get_pcvar_string(g_pCvarDBInfo[Pass], szPass, charsmax(szPass))
  154.     get_pcvar_string(g_pCvarDBInfo[DB], szDB, charsmax(szDB))
  155.    
  156.     g_hTuple = SQL_MakeDbTuple(szHost, szUser, szPass, szDB)
  157.    
  158.     // Let's ensure that the g_hTuple will be valid, we will access the database to make sure
  159.     new iErrorCode, szError[512], Handle:hSQLConnection
  160.    
  161.     hSQLConnection = SQL_Connect(g_hTuple, iErrorCode, szError, charsmax(szError))
  162.    
  163.     if (hSQLConnection != Empty_Handle)
  164.     {
  165.         log_amx("[MySQL][LVL] Successfully connected to host: %s (ALL IS OK).", szHost)
  166.         SQL_FreeHandle(hSQLConnection)
  167.     }
  168.     else
  169.     {
  170.         // Disable plugin
  171.         set_fail_state("[LVL] Failed to connect to MySQL database: %s.", szError)
  172.     }
  173.    
  174.     SQL_ThreadQuery(g_hTuple, "QueryCreateTable", g_szTable)
  175. }
  176.  
  177. public QueryCreateTable(iFailState, Handle:hQuery, szError[], iError, szData[], iSize, Float:flQueueTime)
  178. {
  179.     SQL_IsFail(iFailState, iError, szError, g_szLogFile)
  180. }
  181.  
  182. public client_putinserver(id)
  183. {
  184.     if(is_user_hltv(id) || is_user_bot(id))
  185.         return
  186.    
  187.     // Just 1 second delay
  188.     set_task(1.0, "DelayLoad", id)
  189.  
  190.     // Other tasks
  191.     set_task(1.0, "Show_Hud", id+TASK_SHOWHUD, _, _, "b")
  192.     set_task(0.1, "Check_MaxXP", id, _, _, "b")
  193. }
  194.  
  195. public DelayLoad(id)
  196. {
  197.     // Load his data
  198.     LoadData(id)
  199. }
  200.  
  201. public client_disconnected(id)
  202. {
  203.     if(is_user_hltv(id) || is_user_bot(id))
  204.         return
  205.        
  206.     remove_task(id+TASK_SHOWHUD)
  207.     remove_task(id)
  208. }
  209.  
  210. public Check_MaxXP(id)
  211. {
  212.     new iCurrentMaxXP = g_iMaxXP[id]
  213.    
  214.     new iMaxXP = get_pcvar_num(g_pCvarMaxXPFirstLevel)
  215.    
  216.     for (new i = 1; i <= g_iLevel[id]; i++)
  217.     {
  218.         iMaxXP = floatround(float(iMaxXP) * get_pcvar_float(g_pCvarMaxLevelsIncrement))
  219.     }
  220.    
  221.     if (iCurrentMaxXP != iMaxXP)
  222.     {
  223.         g_iMaxXP[id] = iMaxXP
  224.     }
  225. }
  226.  
  227. public Show_Hud(taskid)
  228. {  
  229.     new iPlayer = ID_SHOWHUD
  230.    
  231.     if (!is_user_alive(iPlayer))
  232.     {
  233.         iPlayer = pev(iPlayer, pev_iuser2)
  234.        
  235.         if (!is_user_alive(iPlayer))
  236.             return
  237.     }
  238.    
  239.     if (get_pcvar_num(g_pCvarPercentageStyle) != 0)
  240.     {
  241.         if(iPlayer != ID_SHOWHUD)
  242.         {
  243.             set_hudmessage(HUD_STATS_SPEC_R, HUD_STATS_SPEC_G, HUD_STATS_SPEC_B, HUD_SPECT_X, HUD_SPECT_Y, 0, 6.0, 1.1, 0.0, 0.0, -1)
  244.             ShowSyncHudMsg(ID_SHOWHUD, g_MsgSync, "Level: %d | XP: %0.2f %", g_iLevel[iPlayer], (float(g_iXP[iPlayer])/float(g_iMaxXP[iPlayer])) * 100.0)
  245.         }
  246.         else if (ze_is_user_zombie(iPlayer))
  247.         {
  248.             set_hudmessage(HUD_STATS_ZOMBIE_R, HUD_STATS_ZOMBIE_G, HUD_STATS_ZOMBIE_B, HUD_STATS_X, HUD_STATS_Y, 0, 6.0, 1.1, 0.0, 0.0, -1)
  249.             ShowSyncHudMsg(ID_SHOWHUD, g_MsgSync, "Level: %d | XP: %0.2f %", g_iLevel[ID_SHOWHUD], (float(g_iXP[ID_SHOWHUD])/float(g_iMaxXP[ID_SHOWHUD])) * 100.0)
  250.         }
  251.         else
  252.         {
  253.             set_hudmessage(HUD_STATS_HUMAN_R, HUD_STATS_HUMAN_G, HUD_STATS_HUMAN_B, HUD_STATS_X, HUD_STATS_Y, 0, 6.0, 1.1, 0.0, 0.0, -1)
  254.             ShowSyncHudMsg(ID_SHOWHUD, g_MsgSync, "Level: %d | XP: %0.2f %", g_iLevel[ID_SHOWHUD], (float(g_iXP[ID_SHOWHUD])/float(g_iMaxXP[ID_SHOWHUD])) * 100.0)
  255.         }
  256.     }
  257.     else
  258.     {
  259.         if(iPlayer != ID_SHOWHUD)
  260.         {
  261.             if (get_pcvar_num(g_pCvarAddCommas) == 1)
  262.             {
  263.                 new szSpecXP[15], szSpecMaxXP[15]
  264.                
  265.                 AddCommas(g_iXP[iPlayer], szSpecXP, charsmax(szSpecXP))
  266.                 AddCommas(g_iMaxXP[iPlayer], szSpecMaxXP, charsmax(szSpecMaxXP))
  267.                
  268.                 set_hudmessage(HUD_STATS_SPEC_R, HUD_STATS_SPEC_G, HUD_STATS_SPEC_B, HUD_SPECT_X, HUD_SPECT_Y, 0, 6.0, 1.1, 0.0, 0.0, -1)
  269.                 ShowSyncHudMsg(ID_SHOWHUD, g_MsgSync, "Level: %d | XP: %s/%s", g_iLevel[iPlayer], szSpecXP, szSpecMaxXP)
  270.             }
  271.             else
  272.             {
  273.                 set_hudmessage(HUD_STATS_SPEC_R, HUD_STATS_SPEC_G, HUD_STATS_SPEC_B, HUD_SPECT_X, HUD_SPECT_Y, 0, 6.0, 1.1, 0.0, 0.0, -1)
  274.                 ShowSyncHudMsg(ID_SHOWHUD, g_MsgSync, "Level: %d | XP: %d/%d", g_iLevel[iPlayer], g_iXP[iPlayer], g_iMaxXP[iPlayer])
  275.             }  
  276.         }
  277.         else if (ze_is_user_zombie(iPlayer))
  278.         {
  279.             if (get_pcvar_num(g_pCvarAddCommas) == 1)
  280.             {
  281.                 new szZombieXP[15], szZombieMaxXP[15]
  282.                
  283.                 AddCommas(g_iXP[ID_SHOWHUD], szZombieXP, charsmax(szZombieXP))
  284.                 AddCommas(g_iMaxXP[ID_SHOWHUD], szZombieMaxXP, charsmax(szZombieMaxXP))
  285.                
  286.                 set_hudmessage(HUD_STATS_ZOMBIE_R, HUD_STATS_ZOMBIE_G, HUD_STATS_ZOMBIE_B, HUD_STATS_X, HUD_STATS_Y, 0, 6.0, 1.1, 0.0, 0.0, -1)
  287.                 ShowSyncHudMsg(ID_SHOWHUD, g_MsgSync, "Level: %d | XP: %s/%s", g_iLevel[ID_SHOWHUD], szZombieXP, szZombieMaxXP)
  288.             }
  289.             else
  290.             {
  291.                 set_hudmessage(HUD_STATS_ZOMBIE_R, HUD_STATS_ZOMBIE_G, HUD_STATS_ZOMBIE_B, HUD_STATS_X, HUD_STATS_Y, 0, 6.0, 1.1, 0.0, 0.0, -1)
  292.                 ShowSyncHudMsg(ID_SHOWHUD, g_MsgSync, "Level: %d | XP: %d/%d", g_iLevel[ID_SHOWHUD], g_iXP[ID_SHOWHUD], g_iMaxXP[ID_SHOWHUD])
  293.             }
  294.         }
  295.         else
  296.         {
  297.             if (get_pcvar_num(g_pCvarAddCommas) == 1)
  298.             {
  299.                 new szHumanXP[15], szHumanMaxXP[15]
  300.                
  301.                 AddCommas(g_iXP[ID_SHOWHUD], szHumanXP, charsmax(szHumanXP))
  302.                 AddCommas(g_iMaxXP[ID_SHOWHUD], szHumanMaxXP, charsmax(szHumanMaxXP))
  303.                
  304.                 set_hudmessage(HUD_STATS_HUMAN_R, HUD_STATS_HUMAN_G, HUD_STATS_HUMAN_B, HUD_STATS_X, HUD_STATS_Y, 0, 6.0, 1.1, 0.0, 0.0, -1)
  305.                 ShowSyncHudMsg(ID_SHOWHUD, g_MsgSync, "Level: %d | XP: %s/%s", g_iLevel[ID_SHOWHUD], szHumanXP, szHumanMaxXP)
  306.             }
  307.             else
  308.             {
  309.                 set_hudmessage(HUD_STATS_HUMAN_R, HUD_STATS_HUMAN_G, HUD_STATS_HUMAN_B, HUD_STATS_X, HUD_STATS_Y, 0, 6.0, 1.1, 0.0, 0.0, -1)
  310.                 ShowSyncHudMsg(ID_SHOWHUD, g_MsgSync, "Level: %d | XP: %d/%d", g_iLevel[ID_SHOWHUD], g_iXP[ID_SHOWHUD], g_iMaxXP[ID_SHOWHUD])
  311.             }
  312.         }
  313.     }
  314. }
  315.  
  316. public ze_roundend(WinTeam)
  317. {
  318.     if (WinTeam == ZE_TEAM_HUMAN)
  319.     {
  320.         for(new id = 1; id <= get_member_game(m_nMaxPlayers); id++)
  321.         {
  322.             if (!is_user_alive(id) || get_member(id, m_iTeam) == TEAM_TERRORIST)
  323.                 continue
  324.            
  325.             g_iXP[id] += get_pcvar_num(g_pCvarEscapeSuccess)
  326.             SaveData(id)
  327.             Check_User_Level(id)
  328.         }
  329.     }
  330.    
  331.     remove_task(TASK_SHOWHUD)
  332. }
  333.  
  334. public Check_User_Level(id)
  335. {
  336.     if(!is_user_connected(id))
  337.         return
  338.  
  339.     if(g_iXP[id] >= g_iMaxXP[id])
  340.     {
  341.         if (get_pcvar_num(g_pCvarStartFromZero) == 1)
  342.         {
  343.             g_iXP[id] = 0
  344.         }
  345.        
  346.         new szName[32]
  347.         g_iLevel[id] ++
  348.        
  349.         g_iMaxXP[id] = floatround(float(g_iMaxXP[id]) * get_pcvar_float(g_pCvarMaxLevelsIncrement))
  350.         get_user_name(id, szName, charsmax(szName))
  351.         ze_colored_print(0, "!g%s !tNow in Level %i!y!", szName, g_iLevel[id])
  352.         ExecuteForward(Fw_LevelUP, ForwardReturn, id)
  353.        
  354.         SaveData(id)
  355.        
  356.         PlaySound(id, LEVELUP)
  357.        
  358.         if (get_pcvar_num(g_pCvarLevelEffects) != 0)
  359.         {
  360.             // Screen Fade
  361.             message_begin(MSG_ONE, get_user_msgid("ScreenFade"), {0,0,0}, id)
  362.             write_short(4096*2)
  363.             write_short(4096*5)
  364.             write_short(0x0001)
  365.             write_byte(random(256))
  366.             write_byte(random(256))
  367.             write_byte(random(256))
  368.             write_byte(150)
  369.             message_end()
  370.            
  371.             // Screen Shake
  372.             message_begin(MSG_ONE, get_user_msgid("ScreenShake"), {0,0,0}, id)
  373.             write_short(255<<14)
  374.             write_short(10<<14)
  375.             write_short(255<<14)
  376.             message_end()
  377.         }
  378.     }
  379. }
  380.  
  381. public ze_user_infected(iVictim, iInfector)
  382. {
  383.     if (iInfector == 0)
  384.         return
  385.    
  386.     g_iXP[iInfector] += get_pcvar_num(g_pCvarZombieInfect)
  387.     SaveData(iInfector)
  388.     Check_User_Level(iInfector)
  389. }
  390.  
  391. public Fw_TakeDamage_Post(iVictim, iInflictor, iAttacker, Float:fDamage, bitsDamageType)
  392. {
  393.     // Player Damage Himself
  394.     if (iVictim == iAttacker || !is_user_alive(iVictim) || !is_user_alive(iAttacker) || ze_is_user_zombie(iAttacker) || !get_pcvar_num(g_pCvarEnableDamage))
  395.         return HC_CONTINUE
  396.    
  397.     // Same Team?
  398.     if (get_member(iAttacker, m_iTeam) == get_member(iVictim, m_iTeam))
  399.         return HC_CONTINUE
  400.    
  401.     // Store Damage For every Player
  402.     g_fDamage[iAttacker] += fDamage
  403.    
  404.     // Damage Calculator Equal or Higher than needed damage
  405.     if (g_fDamage[iAttacker] >= get_pcvar_float(g_pCvarRequiredDamage))
  406.     {
  407.         // Give Player The Coins
  408.         g_iXP[iAttacker] += get_pcvar_num(g_pCvarDamageAward)
  409.         SaveData(iAttacker)
  410.         Check_User_Level(iAttacker)
  411.        
  412.         // Rest The Damage Calculator
  413.         g_fDamage[iAttacker] = 0.0
  414.     }
  415.     return HC_CONTINUE
  416. }
  417.  
  418. public SaveData(id)
  419. {
  420.     new szAuthID[35], szName[32]
  421.     get_user_authid(id, szAuthID, charsmax(szAuthID))
  422.     get_user_name(id, szName, charsmax(szName))
  423.    
  424.     // Set Him to max if he Higher than Max Value
  425.     if (g_iLevel[id] > MAX_LEVEL)
  426.     {
  427.         g_iLevel[id] = MAX_LEVEL
  428.     }
  429.    
  430.     if (g_iXP[id] > MAX_XP)
  431.     {
  432.         g_iXP[id] = MAX_XP
  433.     }
  434.  
  435.     if (!get_pcvar_num(g_pCvarSaveType))
  436.     {
  437.         new szData[256]
  438.         formatex(szData , charsmax(szData), "%i %i %i", g_iLevel[id], g_iXP[id], g_iMaxXP[id])
  439.        
  440.         // Open the Vaults
  441.         g_iLevelsVaultHandle = nvault_open(g_szLevelsVault)
  442.         g_iRanksVaultHandle = nvault_open(g_szRanksVault)
  443.  
  444.         // Saves His Data
  445.         nvault_set(g_iLevelsVaultHandle, szAuthID, szData)
  446.         nvault_set(g_iRanksVaultHandle, szAuthID, szName)
  447.        
  448.         // Close Vaults
  449.         nvault_close(g_iLevelsVaultHandle)
  450.         nvault_close(g_iRanksVaultHandle)
  451.     }
  452.     else
  453.     {
  454.         new szQuery[128]
  455.         formatex(szQuery, charsmax(szQuery), "UPDATE `zombie_escape` SET `Level` = '%d', `XP` = '%d', `Max_XP` = '%d' WHERE ( `SteamID` = '%s' );", g_iLevel[id], g_iXP[id], g_iMaxXP[id], szAuthID)
  456.         SQL_ThreadQuery(g_hTuple, "QuerySetData", szQuery)
  457.     }
  458. }
  459.  
  460. public QuerySetData(iFailState, Handle:hQuery, szError[], iError, szData[], iSize, Float:flQueueTime)
  461. {
  462.     SQL_IsFail(iFailState, iError, szError, g_szLogFile)
  463. }
  464.  
  465. public QuerySetData2(iFailState, Handle:hQuery, szError[], iError, szData[], iSize, Float:flQueueTime)
  466. {
  467.     SQL_IsFail(iFailState, iError, szError, g_szLogFile)
  468. }
  469.  
  470. public LoadData(id)
  471. {
  472.     new szData[256], szAuthID[35]
  473.    
  474.     get_user_authid(id, szAuthID, charsmax(szAuthID))
  475.    
  476.     if (!get_pcvar_num(g_pCvarSaveType))
  477.     {
  478.         // Useless Variable
  479.         new iTimestamp, iExists
  480.        
  481.         // Open the Vault
  482.         g_iLevelsVaultHandle = nvault_open(g_szLevelsVault)
  483.        
  484.         iExists = nvault_lookup(g_iLevelsVaultHandle, szAuthID, szData, charsmax(szData), iTimestamp)
  485.        
  486.         // Close Vault
  487.         nvault_close(g_iLevelsVaultHandle)
  488.        
  489.         if (!iExists)
  490.         {
  491.             g_iLevel[id] = 0
  492.             g_iXP[id] = get_pcvar_num(g_pCvarStartXP)
  493.             g_iMaxXP[id] = get_pcvar_num(g_pCvarMaxXPFirstLevel)
  494.             SaveData(id)
  495.         }
  496.         else
  497.         {
  498.             new iLevel[32], iXP[32], iMaxLevel[32]
  499.             parse(szData, iLevel, 31, iXP, 31, iMaxLevel, 31)
  500.            
  501.             g_iLevel[id] = str_to_num(iLevel)
  502.             g_iXP[id] = str_to_num(iXP)
  503.             g_iMaxXP[id] = str_to_num(iMaxLevel)
  504.         }
  505.     }
  506.     else
  507.     {
  508.         new szQuery[128], szData[5]
  509.         formatex(szQuery, charsmax(szQuery), "SELECT * FROM `Players_Information` WHERE ( `SteamID` = '%s' );", szAuthID)
  510.      
  511.         num_to_str(id, szData, charsmax(szData))
  512.         SQL_ThreadQuery(g_hTuple, "QuerySelectData", szQuery, szData, charsmax(szData))
  513.     }
  514. }
  515.  
  516. public QuerySelectData(iFailState, Handle:hQuery, szError[], iError, szData[])
  517. {
  518.     if (SQL_IsFail(iFailState, iError, szError, g_szLogFile))
  519.         return
  520.    
  521.     new id = str_to_num(szData)
  522.    
  523.     // No results for this query means this is new player
  524.     if (!SQL_NumResults(hQuery))
  525.     {
  526.         new szSteamId[36], szQuery[128]
  527.         get_user_authid(id, szSteamId, charsmax(szSteamId))
  528.  
  529.         g_iLevel[id] = 0
  530.         g_iXP[id] = 0
  531.         g_iMaxXP[id] = get_pcvar_num(g_pCvarMaxXPFirstLevel)
  532.         return
  533.     }
  534.  
  535.     g_iLevel[id] = SQL_ReadResult(hQuery, SQL_FieldNameToNum(hQuery, "Level"))
  536.     g_iXP[id] = SQL_ReadResult(hQuery, SQL_FieldNameToNum(hQuery, "XP"))
  537.     g_iMaxXP[id] = SQL_ReadResult(hQuery, SQL_FieldNameToNum(hQuery, "Max_XP"))
  538. }
  539.  
  540. public native_ze_get_user_xp(id)
  541. {
  542.     if(!is_user_connected(id))
  543.     {
  544.         log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player id (%d)", id)
  545.         return false;
  546.     }
  547.    
  548.     return g_iXP[id]
  549. }
  550.  
  551. public native_ze_set_user_xp(id, amount)
  552. {
  553.     if(!is_user_connected(id))
  554.     {
  555.         log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player id (%d)", id)
  556.         return false;
  557.     }
  558.    
  559.     g_iXP[id] = amount
  560.    
  561.     Check_User_Level(id)
  562.     return true;
  563. }
  564.  
  565. public native_ze_get_user_level(id)
  566. {
  567.     if(!is_user_connected(id))
  568.     {
  569.         log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player id (%d)", id)
  570.         return false;
  571.     }
  572.    
  573.     return g_iLevel[id]
  574. }
  575.  
  576. public native_ze_set_user_level(id, amount)
  577. {
  578.     if(!is_user_connected(id))
  579.     {
  580.         log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player id (%d)", id)
  581.         return false;
  582.     }
  583.    
  584.     g_iLevel[id] = amount
  585.    
  586.     if (get_pcvar_num(g_pCvarStartFromZero) == 1)
  587.     {
  588.         g_iXP[id] = 0
  589.     }
  590.    
  591.     return true;
  592. }
  593.  
  594. public native_ze_get_user_max_xp(id)
  595. {
  596.     if(!is_user_connected(id))
  597.     {
  598.         log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player id (%d)", id)
  599.         return false;
  600.     }
  601.    
  602.     return g_iMaxXP[id]
  603. }
  604.  
  605. public native_ze_set_user_max_xp(id, amount)
  606. {
  607.     if(!is_user_connected(id))
  608.     {
  609.         log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player id (%d)", id)
  610.         return false;
  611.     }
  612.    
  613.     g_iMaxXP[id] = amount
  614.     return true;
  615. }
Image
Image

karan
Mod Tester
Mod Tester
India
Posts: 122
Joined: 4 Years Ago
Location: India
Has thanked: 3 times
Been thanked: 10 times
Age: 24
Contact:

#143

Post by karan » 3 Months Ago

VicKy wrote:
3 Months Ago
karan wrote:
3 Months Ago
VicKy wrote:
3 Months Ago


@karan PLease Help I am not getiing xp while escape but i getting xp on damage i dont know why!!
try using no max xp level system nd see viewtopic.php?f=15&t=72
I Used The Default One Maxx-Xp And No-Maxxp But Both Are Not Working ( no getting xp at escape ) i dont know why

code is :-
  1. #include <zombie_escape>
  2.  
  3. // Defines
  4. #define MAX_LEVEL 60
  5. #define MAX_XP 528029013
  6. #define TASK_SHOWHUD 2020
  7. #define ID_SHOWHUD (taskid - TASK_SHOWHUD)
  8. #define LEVELUP "levelup_ZE/ze_levelup.wav"
  9.  
  10. enum
  11. {
  12.     Host = 0,
  13.     User,
  14.     Pass,
  15.     DB
  16. }
  17.  
  18. // Constants
  19. new const g_szLevelsVault[] = "FuriX_LL"
  20. new const g_szRanksVault[] = "FuriX-RR"
  21. new const g_szLogFile[] = "Levels.log" // MySQL Errors log file
  22. new const g_szTable[] =
  23. " \
  24.     ALTER TABLE `test` \
  25.     ADD IF NOT EXISTS `Level` int(20) NOT NULL DEFAULT '0', \
  26.     ADD IF NOT EXISTS `XP` int(20) NOT NULL DEFAULT '0', \
  27.     ADD IF NOT EXISTS `Max_XP` int(20) NOT NULL DEFAULT '0'; \
  28. "
  29.  
  30. // Messages
  31. const Float:HUD_SPECT_X = -1.0
  32. const Float:HUD_SPECT_Y = 0.70
  33. const Float:HUD_STATS_X = -1.0
  34. const Float:HUD_STATS_Y = 0.90
  35.  
  36. const HUD_STATS_ZOMBIE_R = 200
  37. const HUD_STATS_ZOMBIE_G = 220
  38. const HUD_STATS_ZOMBIE_B = 0
  39.  
  40. const HUD_STATS_HUMAN_R = 0
  41. const HUD_STATS_HUMAN_G = 200
  42. const HUD_STATS_HUMAN_B = 210
  43.  
  44. const HUD_STATS_SPEC_R = 100
  45. const HUD_STATS_SPEC_G = 100
  46. const HUD_STATS_SPEC_B = 100
  47.  
  48. // Variables
  49. new g_iLevel[33],
  50.     g_iXP[33],
  51.     g_iMaxXP[33],
  52.     Float:g_fDamage[33],
  53.     g_MsgSync,
  54.     g_iLevelsVaultHandle,
  55.     g_iRanksVaultHandle,
  56.     Handle:g_hTuple,
  57.     Fw_LevelUP,
  58.     ForwardReturn
  59.  
  60. // Cvars
  61. new g_pCvarZombieInfect,
  62.     g_pCvarEscapeSuccess,
  63.     g_pCvarEnableDamage,
  64.     g_pCvarRequiredDamage,
  65.     g_pCvarDamageAward,
  66.     g_pCvarStartXP,
  67.     g_pCvarMaxLevelsIncrement,
  68.     g_pCvarMaxXPFirstLevel,
  69.     g_pCvarPercentageStyle,
  70.     g_pCvarStartFromZero,
  71.     g_pCvarAddCommas,
  72.     g_pCvarLevelEffects,
  73.     g_pCvarSaveType,
  74.     g_pCvarDBInfo[4]
  75.  
  76. public plugin_natives()
  77. {
  78.     register_native("ze_get_user_xp", "native_ze_get_user_xp", 1)
  79.     register_native("ze_set_user_xp", "native_ze_set_user_xp", 1)
  80.     register_native("ze_get_user_level", "native_ze_get_user_level", 1)
  81.     register_native("ze_set_user_level", "native_ze_set_user_level", 1)
  82.     register_native("ze_get_user_max_xp", "native_ze_get_user_max_xp", 1)
  83.     register_native("ze_set_user_max_xp", "native_ze_set_user_max_xp", 1)
  84. }
  85.  
  86. public plugin_precache()
  87. {
  88.     precache_sound(LEVELUP)
  89. }
  90.  
  91. public plugin_init()
  92. {
  93.     register_plugin("[ZE] Level-XP System", "1.9", "Raheem/JaCk")
  94.    
  95.     // Hook Chains
  96.     RegisterHookChain(RG_CBasePlayer_TakeDamage, "Fw_TakeDamage_Post", 1)
  97.  
  98.     Fw_LevelUP = CreateMultiForward("ze_on_levelup", ET_IGNORE, FP_CELL)
  99.    
  100.     // Cvars
  101.     g_pCvarZombieInfect = register_cvar("ze_zombie_infect", "0")
  102.     g_pCvarEscapeSuccess = register_cvar("ze_escape_success", "100")
  103.     g_pCvarEnableDamage = register_cvar("ze_enable_dmg", "1")
  104.     g_pCvarRequiredDamage = register_cvar("ze_required_dmg", "1000.0")
  105.     g_pCvarDamageAward = register_cvar("ze_dmg_award", "3")
  106.     g_pCvarStartXP = register_cvar("ze_start_xp", "50")
  107.     g_pCvarMaxLevelsIncrement = register_cvar("ze_maxlevels_increment", "1.3")
  108.     g_pCvarMaxXPFirstLevel = register_cvar("ze_max_xp_first_level", "100")
  109.     g_pCvarPercentageStyle = register_cvar("ze_enable_percentage_style", "0")
  110.     g_pCvarStartFromZero = register_cvar("ze_new_level_zero_xp", "0")
  111.     g_pCvarAddCommas = register_cvar("ze_add_commas_to_xp", "1")
  112.     g_pCvarLevelEffects = register_cvar("ze_level_up_effects", "1")
  113.     g_pCvarSaveType = register_cvar("ze_levels_save_type", "0")
  114.     g_pCvarDBInfo[Host] = register_cvar("ze_levels_host", "127.0.0.1")
  115.     g_pCvarDBInfo[User] = register_cvar("ze_levels_user", "root")
  116.     g_pCvarDBInfo[Pass] = register_cvar("ze_levels_pass", "password")
  117.     g_pCvarDBInfo[DB] = register_cvar("ze_levels_dbname", "levels_db")
  118.    
  119.     // Messages
  120.     g_MsgSync = CreateHudSyncObj()
  121.  
  122.     if (get_pcvar_num(g_pCvarSaveType))
  123.     {
  124.         set_task(0.1, "Delay_MySQL_Init")
  125.     }
  126. }
  127.  
  128. public plugin_end()
  129. {
  130.     if (get_pcvar_num(g_pCvarSaveType))
  131.     {
  132.         if (g_hTuple != Empty_Handle)
  133.         {
  134.             SQL_FreeHandle(g_hTuple)
  135.         }
  136.     }
  137. }
  138.  
  139. public Delay_MySQL_Init()
  140. {
  141.     MySQL_Init()
  142. }
  143.  
  144. public MySQL_Init()
  145. {
  146.     if (!get_pcvar_num(g_pCvarSaveType))
  147.         return
  148.    
  149.     new szHost[64], szUser[32], szPass[32], szDB[128]
  150.    
  151.     get_pcvar_string(g_pCvarDBInfo[Host], szHost, charsmax(szHost))
  152.     get_pcvar_string(g_pCvarDBInfo[User], szUser, charsmax(szUser))
  153.     get_pcvar_string(g_pCvarDBInfo[Pass], szPass, charsmax(szPass))
  154.     get_pcvar_string(g_pCvarDBInfo[DB], szDB, charsmax(szDB))
  155.    
  156.     g_hTuple = SQL_MakeDbTuple(szHost, szUser, szPass, szDB)
  157.    
  158.     // Let's ensure that the g_hTuple will be valid, we will access the database to make sure
  159.     new iErrorCode, szError[512], Handle:hSQLConnection
  160.    
  161.     hSQLConnection = SQL_Connect(g_hTuple, iErrorCode, szError, charsmax(szError))
  162.    
  163.     if (hSQLConnection != Empty_Handle)
  164.     {
  165.         log_amx("[MySQL][LVL] Successfully connected to host: %s (ALL IS OK).", szHost)
  166.         SQL_FreeHandle(hSQLConnection)
  167.     }
  168.     else
  169.     {
  170.         // Disable plugin
  171.         set_fail_state("[LVL] Failed to connect to MySQL database: %s.", szError)
  172.     }
  173.    
  174.     SQL_ThreadQuery(g_hTuple, "QueryCreateTable", g_szTable)
  175. }
  176.  
  177. public QueryCreateTable(iFailState, Handle:hQuery, szError[], iError, szData[], iSize, Float:flQueueTime)
  178. {
  179.     SQL_IsFail(iFailState, iError, szError, g_szLogFile)
  180. }
  181.  
  182. public client_putinserver(id)
  183. {
  184.     if(is_user_hltv(id) || is_user_bot(id))
  185.         return
  186.    
  187.     // Just 1 second delay
  188.     set_task(1.0, "DelayLoad", id)
  189.  
  190.     // Other tasks
  191.     set_task(1.0, "Show_Hud", id+TASK_SHOWHUD, _, _, "b")
  192.     set_task(0.1, "Check_MaxXP", id, _, _, "b")
  193. }
  194.  
  195. public DelayLoad(id)
  196. {
  197.     // Load his data
  198.     LoadData(id)
  199. }
  200.  
  201. public client_disconnected(id)
  202. {
  203.     if(is_user_hltv(id) || is_user_bot(id))
  204.         return
  205.        
  206.     remove_task(id+TASK_SHOWHUD)
  207.     remove_task(id)
  208. }
  209.  
  210. public Check_MaxXP(id)
  211. {
  212.     new iCurrentMaxXP = g_iMaxXP[id]
  213.    
  214.     new iMaxXP = get_pcvar_num(g_pCvarMaxXPFirstLevel)
  215.    
  216.     for (new i = 1; i <= g_iLevel[id]; i++)
  217.     {
  218.         iMaxXP = floatround(float(iMaxXP) * get_pcvar_float(g_pCvarMaxLevelsIncrement))
  219.     }
  220.    
  221.     if (iCurrentMaxXP != iMaxXP)
  222.     {
  223.         g_iMaxXP[id] = iMaxXP
  224.     }
  225. }
  226.  
  227. public Show_Hud(taskid)
  228. {  
  229.     new iPlayer = ID_SHOWHUD
  230.    
  231.     if (!is_user_alive(iPlayer))
  232.     {
  233.         iPlayer = pev(iPlayer, pev_iuser2)
  234.        
  235.         if (!is_user_alive(iPlayer))
  236.             return
  237.     }
  238.    
  239.     if (get_pcvar_num(g_pCvarPercentageStyle) != 0)
  240.     {
  241.         if(iPlayer != ID_SHOWHUD)
  242.         {
  243.             set_hudmessage(HUD_STATS_SPEC_R, HUD_STATS_SPEC_G, HUD_STATS_SPEC_B, HUD_SPECT_X, HUD_SPECT_Y, 0, 6.0, 1.1, 0.0, 0.0, -1)
  244.             ShowSyncHudMsg(ID_SHOWHUD, g_MsgSync, "Level: %d | XP: %0.2f %", g_iLevel[iPlayer], (float(g_iXP[iPlayer])/float(g_iMaxXP[iPlayer])) * 100.0)
  245.         }
  246.         else if (ze_is_user_zombie(iPlayer))
  247.         {
  248.             set_hudmessage(HUD_STATS_ZOMBIE_R, HUD_STATS_ZOMBIE_G, HUD_STATS_ZOMBIE_B, HUD_STATS_X, HUD_STATS_Y, 0, 6.0, 1.1, 0.0, 0.0, -1)
  249.             ShowSyncHudMsg(ID_SHOWHUD, g_MsgSync, "Level: %d | XP: %0.2f %", g_iLevel[ID_SHOWHUD], (float(g_iXP[ID_SHOWHUD])/float(g_iMaxXP[ID_SHOWHUD])) * 100.0)
  250.         }
  251.         else
  252.         {
  253.             set_hudmessage(HUD_STATS_HUMAN_R, HUD_STATS_HUMAN_G, HUD_STATS_HUMAN_B, HUD_STATS_X, HUD_STATS_Y, 0, 6.0, 1.1, 0.0, 0.0, -1)
  254.             ShowSyncHudMsg(ID_SHOWHUD, g_MsgSync, "Level: %d | XP: %0.2f %", g_iLevel[ID_SHOWHUD], (float(g_iXP[ID_SHOWHUD])/float(g_iMaxXP[ID_SHOWHUD])) * 100.0)
  255.         }
  256.     }
  257.     else
  258.     {
  259.         if(iPlayer != ID_SHOWHUD)
  260.         {
  261.             if (get_pcvar_num(g_pCvarAddCommas) == 1)
  262.             {
  263.                 new szSpecXP[15], szSpecMaxXP[15]
  264.                
  265.                 AddCommas(g_iXP[iPlayer], szSpecXP, charsmax(szSpecXP))
  266.                 AddCommas(g_iMaxXP[iPlayer], szSpecMaxXP, charsmax(szSpecMaxXP))
  267.                
  268.                 set_hudmessage(HUD_STATS_SPEC_R, HUD_STATS_SPEC_G, HUD_STATS_SPEC_B, HUD_SPECT_X, HUD_SPECT_Y, 0, 6.0, 1.1, 0.0, 0.0, -1)
  269.                 ShowSyncHudMsg(ID_SHOWHUD, g_MsgSync, "Level: %d | XP: %s/%s", g_iLevel[iPlayer], szSpecXP, szSpecMaxXP)
  270.             }
  271.             else
  272.             {
  273.                 set_hudmessage(HUD_STATS_SPEC_R, HUD_STATS_SPEC_G, HUD_STATS_SPEC_B, HUD_SPECT_X, HUD_SPECT_Y, 0, 6.0, 1.1, 0.0, 0.0, -1)
  274.                 ShowSyncHudMsg(ID_SHOWHUD, g_MsgSync, "Level: %d | XP: %d/%d", g_iLevel[iPlayer], g_iXP[iPlayer], g_iMaxXP[iPlayer])
  275.             }  
  276.         }
  277.         else if (ze_is_user_zombie(iPlayer))
  278.         {
  279.             if (get_pcvar_num(g_pCvarAddCommas) == 1)
  280.             {
  281.                 new szZombieXP[15], szZombieMaxXP[15]
  282.                
  283.                 AddCommas(g_iXP[ID_SHOWHUD], szZombieXP, charsmax(szZombieXP))
  284.                 AddCommas(g_iMaxXP[ID_SHOWHUD], szZombieMaxXP, charsmax(szZombieMaxXP))
  285.                
  286.                 set_hudmessage(HUD_STATS_ZOMBIE_R, HUD_STATS_ZOMBIE_G, HUD_STATS_ZOMBIE_B, HUD_STATS_X, HUD_STATS_Y, 0, 6.0, 1.1, 0.0, 0.0, -1)
  287.                 ShowSyncHudMsg(ID_SHOWHUD, g_MsgSync, "Level: %d | XP: %s/%s", g_iLevel[ID_SHOWHUD], szZombieXP, szZombieMaxXP)
  288.             }
  289.             else
  290.             {
  291.                 set_hudmessage(HUD_STATS_ZOMBIE_R, HUD_STATS_ZOMBIE_G, HUD_STATS_ZOMBIE_B, HUD_STATS_X, HUD_STATS_Y, 0, 6.0, 1.1, 0.0, 0.0, -1)
  292.                 ShowSyncHudMsg(ID_SHOWHUD, g_MsgSync, "Level: %d | XP: %d/%d", g_iLevel[ID_SHOWHUD], g_iXP[ID_SHOWHUD], g_iMaxXP[ID_SHOWHUD])
  293.             }
  294.         }
  295.         else
  296.         {
  297.             if (get_pcvar_num(g_pCvarAddCommas) == 1)
  298.             {
  299.                 new szHumanXP[15], szHumanMaxXP[15]
  300.                
  301.                 AddCommas(g_iXP[ID_SHOWHUD], szHumanXP, charsmax(szHumanXP))
  302.                 AddCommas(g_iMaxXP[ID_SHOWHUD], szHumanMaxXP, charsmax(szHumanMaxXP))
  303.                
  304.                 set_hudmessage(HUD_STATS_HUMAN_R, HUD_STATS_HUMAN_G, HUD_STATS_HUMAN_B, HUD_STATS_X, HUD_STATS_Y, 0, 6.0, 1.1, 0.0, 0.0, -1)
  305.                 ShowSyncHudMsg(ID_SHOWHUD, g_MsgSync, "Level: %d | XP: %s/%s", g_iLevel[ID_SHOWHUD], szHumanXP, szHumanMaxXP)
  306.             }
  307.             else
  308.             {
  309.                 set_hudmessage(HUD_STATS_HUMAN_R, HUD_STATS_HUMAN_G, HUD_STATS_HUMAN_B, HUD_STATS_X, HUD_STATS_Y, 0, 6.0, 1.1, 0.0, 0.0, -1)
  310.                 ShowSyncHudMsg(ID_SHOWHUD, g_MsgSync, "Level: %d | XP: %d/%d", g_iLevel[ID_SHOWHUD], g_iXP[ID_SHOWHUD], g_iMaxXP[ID_SHOWHUD])
  311.             }
  312.         }
  313.     }
  314. }
  315.  
  316. public ze_roundend(WinTeam)
  317. {
  318.     if (WinTeam == ZE_TEAM_HUMAN)
  319.     {
  320.         for(new id = 1; id <= get_member_game(m_nMaxPlayers); id++)
  321.         {
  322.             if (!is_user_alive(id) || get_member(id, m_iTeam) == TEAM_TERRORIST)
  323.                 continue
  324.            
  325.             g_iXP[id] += get_pcvar_num(g_pCvarEscapeSuccess)
  326.             SaveData(id)
  327.             Check_User_Level(id)
  328.         }
  329.     }
  330.    
  331.     remove_task(TASK_SHOWHUD)
  332. }
  333.  
  334. public Check_User_Level(id)
  335. {
  336.     if(!is_user_connected(id))
  337.         return
  338.  
  339.     if(g_iXP[id] >= g_iMaxXP[id])
  340.     {
  341.         if (get_pcvar_num(g_pCvarStartFromZero) == 1)
  342.         {
  343.             g_iXP[id] = 0
  344.         }
  345.        
  346.         new szName[32]
  347.         g_iLevel[id] ++
  348.        
  349.         g_iMaxXP[id] = floatround(float(g_iMaxXP[id]) * get_pcvar_float(g_pCvarMaxLevelsIncrement))
  350.         get_user_name(id, szName, charsmax(szName))
  351.         ze_colored_print(0, "!g%s !tNow in Level %i!y!", szName, g_iLevel[id])
  352.         ExecuteForward(Fw_LevelUP, ForwardReturn, id)
  353.        
  354.         SaveData(id)
  355.        
  356.         PlaySound(id, LEVELUP)
  357.        
  358.         if (get_pcvar_num(g_pCvarLevelEffects) != 0)
  359.         {
  360.             // Screen Fade
  361.             message_begin(MSG_ONE, get_user_msgid("ScreenFade"), {0,0,0}, id)
  362.             write_short(4096*2)
  363.             write_short(4096*5)
  364.             write_short(0x0001)
  365.             write_byte(random(256))
  366.             write_byte(random(256))
  367.             write_byte(random(256))
  368.             write_byte(150)
  369.             message_end()
  370.            
  371.             // Screen Shake
  372.             message_begin(MSG_ONE, get_user_msgid("ScreenShake"), {0,0,0}, id)
  373.             write_short(255<<14)
  374.             write_short(10<<14)
  375.             write_short(255<<14)
  376.             message_end()
  377.         }
  378.     }
  379. }
  380.  
  381. public ze_user_infected(iVictim, iInfector)
  382. {
  383.     if (iInfector == 0)
  384.         return
  385.    
  386.     g_iXP[iInfector] += get_pcvar_num(g_pCvarZombieInfect)
  387.     SaveData(iInfector)
  388.     Check_User_Level(iInfector)
  389. }
  390.  
  391. public Fw_TakeDamage_Post(iVictim, iInflictor, iAttacker, Float:fDamage, bitsDamageType)
  392. {
  393.     // Player Damage Himself
  394.     if (iVictim == iAttacker || !is_user_alive(iVictim) || !is_user_alive(iAttacker) || ze_is_user_zombie(iAttacker) || !get_pcvar_num(g_pCvarEnableDamage))
  395.         return HC_CONTINUE
  396.    
  397.     // Same Team?
  398.     if (get_member(iAttacker, m_iTeam) == get_member(iVictim, m_iTeam))
  399.         return HC_CONTINUE
  400.    
  401.     // Store Damage For every Player
  402.     g_fDamage[iAttacker] += fDamage
  403.    
  404.     // Damage Calculator Equal or Higher than needed damage
  405.     if (g_fDamage[iAttacker] >= get_pcvar_float(g_pCvarRequiredDamage))
  406.     {
  407.         // Give Player The Coins
  408.         g_iXP[iAttacker] += get_pcvar_num(g_pCvarDamageAward)
  409.         SaveData(iAttacker)
  410.         Check_User_Level(iAttacker)
  411.        
  412.         // Rest The Damage Calculator
  413.         g_fDamage[iAttacker] = 0.0
  414.     }
  415.     return HC_CONTINUE
  416. }
  417.  
  418. public SaveData(id)
  419. {
  420.     new szAuthID[35], szName[32]
  421.     get_user_authid(id, szAuthID, charsmax(szAuthID))
  422.     get_user_name(id, szName, charsmax(szName))
  423.    
  424.     // Set Him to max if he Higher than Max Value
  425.     if (g_iLevel[id] > MAX_LEVEL)
  426.     {
  427.         g_iLevel[id] = MAX_LEVEL
  428.     }
  429.    
  430.     if (g_iXP[id] > MAX_XP)
  431.     {
  432.         g_iXP[id] = MAX_XP
  433.     }
  434.  
  435.     if (!get_pcvar_num(g_pCvarSaveType))
  436.     {
  437.         new szData[256]
  438.         formatex(szData , charsmax(szData), "%i %i %i", g_iLevel[id], g_iXP[id], g_iMaxXP[id])
  439.        
  440.         // Open the Vaults
  441.         g_iLevelsVaultHandle = nvault_open(g_szLevelsVault)
  442.         g_iRanksVaultHandle = nvault_open(g_szRanksVault)
  443.  
  444.         // Saves His Data
  445.         nvault_set(g_iLevelsVaultHandle, szAuthID, szData)
  446.         nvault_set(g_iRanksVaultHandle, szAuthID, szName)
  447.        
  448.         // Close Vaults
  449.         nvault_close(g_iLevelsVaultHandle)
  450.         nvault_close(g_iRanksVaultHandle)
  451.     }
  452.     else
  453.     {
  454.         new szQuery[128]
  455.         formatex(szQuery, charsmax(szQuery), "UPDATE `zombie_escape` SET `Level` = '%d', `XP` = '%d', `Max_XP` = '%d' WHERE ( `SteamID` = '%s' );", g_iLevel[id], g_iXP[id], g_iMaxXP[id], szAuthID)
  456.         SQL_ThreadQuery(g_hTuple, "QuerySetData", szQuery)
  457.     }
  458. }
  459.  
  460. public QuerySetData(iFailState, Handle:hQuery, szError[], iError, szData[], iSize, Float:flQueueTime)
  461. {
  462.     SQL_IsFail(iFailState, iError, szError, g_szLogFile)
  463. }
  464.  
  465. public QuerySetData2(iFailState, Handle:hQuery, szError[], iError, szData[], iSize, Float:flQueueTime)
  466. {
  467.     SQL_IsFail(iFailState, iError, szError, g_szLogFile)
  468. }
  469.  
  470. public LoadData(id)
  471. {
  472.     new szData[256], szAuthID[35]
  473.    
  474.     get_user_authid(id, szAuthID, charsmax(szAuthID))
  475.    
  476.     if (!get_pcvar_num(g_pCvarSaveType))
  477.     {
  478.         // Useless Variable
  479.         new iTimestamp, iExists
  480.        
  481.         // Open the Vault
  482.         g_iLevelsVaultHandle = nvault_open(g_szLevelsVault)
  483.        
  484.         iExists = nvault_lookup(g_iLevelsVaultHandle, szAuthID, szData, charsmax(szData), iTimestamp)
  485.        
  486.         // Close Vault
  487.         nvault_close(g_iLevelsVaultHandle)
  488.        
  489.         if (!iExists)
  490.         {
  491.             g_iLevel[id] = 0
  492.             g_iXP[id] = get_pcvar_num(g_pCvarStartXP)
  493.             g_iMaxXP[id] = get_pcvar_num(g_pCvarMaxXPFirstLevel)
  494.             SaveData(id)
  495.         }
  496.         else
  497.         {
  498.             new iLevel[32], iXP[32], iMaxLevel[32]
  499.             parse(szData, iLevel, 31, iXP, 31, iMaxLevel, 31)
  500.            
  501.             g_iLevel[id] = str_to_num(iLevel)
  502.             g_iXP[id] = str_to_num(iXP)
  503.             g_iMaxXP[id] = str_to_num(iMaxLevel)
  504.         }
  505.     }
  506.     else
  507.     {
  508.         new szQuery[128], szData[5]
  509.         formatex(szQuery, charsmax(szQuery), "SELECT * FROM `Players_Information` WHERE ( `SteamID` = '%s' );", szAuthID)
  510.      
  511.         num_to_str(id, szData, charsmax(szData))
  512.         SQL_ThreadQuery(g_hTuple, "QuerySelectData", szQuery, szData, charsmax(szData))
  513.     }
  514. }
  515.  
  516. public QuerySelectData(iFailState, Handle:hQuery, szError[], iError, szData[])
  517. {
  518.     if (SQL_IsFail(iFailState, iError, szError, g_szLogFile))
  519.         return
  520.    
  521.     new id = str_to_num(szData)
  522.    
  523.     // No results for this query means this is new player
  524.     if (!SQL_NumResults(hQuery))
  525.     {
  526.         new szSteamId[36], szQuery[128]
  527.         get_user_authid(id, szSteamId, charsmax(szSteamId))
  528.  
  529.         g_iLevel[id] = 0
  530.         g_iXP[id] = 0
  531.         g_iMaxXP[id] = get_pcvar_num(g_pCvarMaxXPFirstLevel)
  532.         return
  533.     }
  534.  
  535.     g_iLevel[id] = SQL_ReadResult(hQuery, SQL_FieldNameToNum(hQuery, "Level"))
  536.     g_iXP[id] = SQL_ReadResult(hQuery, SQL_FieldNameToNum(hQuery, "XP"))
  537.     g_iMaxXP[id] = SQL_ReadResult(hQuery, SQL_FieldNameToNum(hQuery, "Max_XP"))
  538. }
  539.  
  540. public native_ze_get_user_xp(id)
  541. {
  542.     if(!is_user_connected(id))
  543.     {
  544.         log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player id (%d)", id)
  545.         return false;
  546.     }
  547.    
  548.     return g_iXP[id]
  549. }
  550.  
  551. public native_ze_set_user_xp(id, amount)
  552. {
  553.     if(!is_user_connected(id))
  554.     {
  555.         log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player id (%d)", id)
  556.         return false;
  557.     }
  558.    
  559.     g_iXP[id] = amount
  560.    
  561.     Check_User_Level(id)
  562.     return true;
  563. }
  564.  
  565. public native_ze_get_user_level(id)
  566. {
  567.     if(!is_user_connected(id))
  568.     {
  569.         log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player id (%d)", id)
  570.         return false;
  571.     }
  572.    
  573.     return g_iLevel[id]
  574. }
  575.  
  576. public native_ze_set_user_level(id, amount)
  577. {
  578.     if(!is_user_connected(id))
  579.     {
  580.         log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player id (%d)", id)
  581.         return false;
  582.     }
  583.    
  584.     g_iLevel[id] = amount
  585.    
  586.     if (get_pcvar_num(g_pCvarStartFromZero) == 1)
  587.     {
  588.         g_iXP[id] = 0
  589.     }
  590.    
  591.     return true;
  592. }
  593.  
  594. public native_ze_get_user_max_xp(id)
  595. {
  596.     if(!is_user_connected(id))
  597.     {
  598.         log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player id (%d)", id)
  599.         return false;
  600.     }
  601.    
  602.     return g_iMaxXP[id]
  603. }
  604.  
  605. public native_ze_set_user_max_xp(id, amount)
  606. {
  607.     if(!is_user_connected(id))
  608.     {
  609.         log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player id (%d)", id)
  610.         return false;
  611.     }
  612.    
  613.     g_iMaxXP[id] = amount
  614.     return true;
  615. }
post ur ze.cfg file
Image

VicKy
Mod Tester
Mod Tester
Pakistan
Posts: 82
Joined: 1 Year Ago
Has thanked: 14 times
Been thanked: 11 times
Age: 19
Contact:

#144

Post by VicKy » 3 Months Ago

karan wrote:
3 Months Ago
VicKy wrote:
3 Months Ago
karan wrote:
3 Months Ago

try using no max xp level system nd see viewtopic.php?f=15&t=72
I Used The Default One Maxx-Xp And No-Maxxp But Both Are Not Working ( no getting xp at escape ) i dont know why

code is :-
  1. #include <zombie_escape>
  2.  
  3. // Defines
  4. #define MAX_LEVEL 60
  5. #define MAX_XP 528029013
  6. #define TASK_SHOWHUD 2020
  7. #define ID_SHOWHUD (taskid - TASK_SHOWHUD)
  8. #define LEVELUP "levelup_ZE/ze_levelup.wav"
  9.  
  10. enum
  11. {
  12.     Host = 0,
  13.     User,
  14.     Pass,
  15.     DB
  16. }
  17.  
  18. // Constants
  19. new const g_szLevelsVault[] = "FuriX_LL"
  20. new const g_szRanksVault[] = "FuriX-RR"
  21. new const g_szLogFile[] = "Levels.log" // MySQL Errors log file
  22. new const g_szTable[] =
  23. " \
  24.     ALTER TABLE `test` \
  25.     ADD IF NOT EXISTS `Level` int(20) NOT NULL DEFAULT '0', \
  26.     ADD IF NOT EXISTS `XP` int(20) NOT NULL DEFAULT '0', \
  27.     ADD IF NOT EXISTS `Max_XP` int(20) NOT NULL DEFAULT '0'; \
  28. "
  29.  
  30. // Messages
  31. const Float:HUD_SPECT_X = -1.0
  32. const Float:HUD_SPECT_Y = 0.70
  33. const Float:HUD_STATS_X = -1.0
  34. const Float:HUD_STATS_Y = 0.90
  35.  
  36. const HUD_STATS_ZOMBIE_R = 200
  37. const HUD_STATS_ZOMBIE_G = 220
  38. const HUD_STATS_ZOMBIE_B = 0
  39.  
  40. const HUD_STATS_HUMAN_R = 0
  41. const HUD_STATS_HUMAN_G = 200
  42. const HUD_STATS_HUMAN_B = 210
  43.  
  44. const HUD_STATS_SPEC_R = 100
  45. const HUD_STATS_SPEC_G = 100
  46. const HUD_STATS_SPEC_B = 100
  47.  
  48. // Variables
  49. new g_iLevel[33],
  50.     g_iXP[33],
  51.     g_iMaxXP[33],
  52.     Float:g_fDamage[33],
  53.     g_MsgSync,
  54.     g_iLevelsVaultHandle,
  55.     g_iRanksVaultHandle,
  56.     Handle:g_hTuple,
  57.     Fw_LevelUP,
  58.     ForwardReturn
  59.  
  60. // Cvars
  61. new g_pCvarZombieInfect,
  62.     g_pCvarEscapeSuccess,
  63.     g_pCvarEnableDamage,
  64.     g_pCvarRequiredDamage,
  65.     g_pCvarDamageAward,
  66.     g_pCvarStartXP,
  67.     g_pCvarMaxLevelsIncrement,
  68.     g_pCvarMaxXPFirstLevel,
  69.     g_pCvarPercentageStyle,
  70.     g_pCvarStartFromZero,
  71.     g_pCvarAddCommas,
  72.     g_pCvarLevelEffects,
  73.     g_pCvarSaveType,
  74.     g_pCvarDBInfo[4]
  75.  
  76. public plugin_natives()
  77. {
  78.     register_native("ze_get_user_xp", "native_ze_get_user_xp", 1)
  79.     register_native("ze_set_user_xp", "native_ze_set_user_xp", 1)
  80.     register_native("ze_get_user_level", "native_ze_get_user_level", 1)
  81.     register_native("ze_set_user_level", "native_ze_set_user_level", 1)
  82.     register_native("ze_get_user_max_xp", "native_ze_get_user_max_xp", 1)
  83.     register_native("ze_set_user_max_xp", "native_ze_set_user_max_xp", 1)
  84. }
  85.  
  86. public plugin_precache()
  87. {
  88.     precache_sound(LEVELUP)
  89. }
  90.  
  91. public plugin_init()
  92. {
  93.     register_plugin("[ZE] Level-XP System", "1.9", "Raheem/JaCk")
  94.    
  95.     // Hook Chains
  96.     RegisterHookChain(RG_CBasePlayer_TakeDamage, "Fw_TakeDamage_Post", 1)
  97.  
  98.     Fw_LevelUP = CreateMultiForward("ze_on_levelup", ET_IGNORE, FP_CELL)
  99.    
  100.     // Cvars
  101.     g_pCvarZombieInfect = register_cvar("ze_zombie_infect", "0")
  102.     g_pCvarEscapeSuccess = register_cvar("ze_escape_success", "100")
  103.     g_pCvarEnableDamage = register_cvar("ze_enable_dmg", "1")
  104.     g_pCvarRequiredDamage = register_cvar("ze_required_dmg", "1000.0")
  105.     g_pCvarDamageAward = register_cvar("ze_dmg_award", "3")
  106.     g_pCvarStartXP = register_cvar("ze_start_xp", "50")
  107.     g_pCvarMaxLevelsIncrement = register_cvar("ze_maxlevels_increment", "1.3")
  108.     g_pCvarMaxXPFirstLevel = register_cvar("ze_max_xp_first_level", "100")
  109.     g_pCvarPercentageStyle = register_cvar("ze_enable_percentage_style", "0")
  110.     g_pCvarStartFromZero = register_cvar("ze_new_level_zero_xp", "0")
  111.     g_pCvarAddCommas = register_cvar("ze_add_commas_to_xp", "1")
  112.     g_pCvarLevelEffects = register_cvar("ze_level_up_effects", "1")
  113.     g_pCvarSaveType = register_cvar("ze_levels_save_type", "0")
  114.     g_pCvarDBInfo[Host] = register_cvar("ze_levels_host", "127.0.0.1")
  115.     g_pCvarDBInfo[User] = register_cvar("ze_levels_user", "root")
  116.     g_pCvarDBInfo[Pass] = register_cvar("ze_levels_pass", "password")
  117.     g_pCvarDBInfo[DB] = register_cvar("ze_levels_dbname", "levels_db")
  118.    
  119.     // Messages
  120.     g_MsgSync = CreateHudSyncObj()
  121.  
  122.     if (get_pcvar_num(g_pCvarSaveType))
  123.     {
  124.         set_task(0.1, "Delay_MySQL_Init")
  125.     }
  126. }
  127.  
  128. public plugin_end()
  129. {
  130.     if (get_pcvar_num(g_pCvarSaveType))
  131.     {
  132.         if (g_hTuple != Empty_Handle)
  133.         {
  134.             SQL_FreeHandle(g_hTuple)
  135.         }
  136.     }
  137. }
  138.  
  139. public Delay_MySQL_Init()
  140. {
  141.     MySQL_Init()
  142. }
  143.  
  144. public MySQL_Init()
  145. {
  146.     if (!get_pcvar_num(g_pCvarSaveType))
  147.         return
  148.    
  149.     new szHost[64], szUser[32], szPass[32], szDB[128]
  150.    
  151.     get_pcvar_string(g_pCvarDBInfo[Host], szHost, charsmax(szHost))
  152.     get_pcvar_string(g_pCvarDBInfo[User], szUser, charsmax(szUser))
  153.     get_pcvar_string(g_pCvarDBInfo[Pass], szPass, charsmax(szPass))
  154.     get_pcvar_string(g_pCvarDBInfo[DB], szDB, charsmax(szDB))
  155.    
  156.     g_hTuple = SQL_MakeDbTuple(szHost, szUser, szPass, szDB)
  157.    
  158.     // Let's ensure that the g_hTuple will be valid, we will access the database to make sure
  159.     new iErrorCode, szError[512], Handle:hSQLConnection
  160.    
  161.     hSQLConnection = SQL_Connect(g_hTuple, iErrorCode, szError, charsmax(szError))
  162.    
  163.     if (hSQLConnection != Empty_Handle)
  164.     {
  165.         log_amx("[MySQL][LVL] Successfully connected to host: %s (ALL IS OK).", szHost)
  166.         SQL_FreeHandle(hSQLConnection)
  167.     }
  168.     else
  169.     {
  170.         // Disable plugin
  171.         set_fail_state("[LVL] Failed to connect to MySQL database: %s.", szError)
  172.     }
  173.    
  174.     SQL_ThreadQuery(g_hTuple, "QueryCreateTable", g_szTable)
  175. }
  176.  
  177. public QueryCreateTable(iFailState, Handle:hQuery, szError[], iError, szData[], iSize, Float:flQueueTime)
  178. {
  179.     SQL_IsFail(iFailState, iError, szError, g_szLogFile)
  180. }
  181.  
  182. public client_putinserver(id)
  183. {
  184.     if(is_user_hltv(id) || is_user_bot(id))
  185.         return
  186.    
  187.     // Just 1 second delay
  188.     set_task(1.0, "DelayLoad", id)
  189.  
  190.     // Other tasks
  191.     set_task(1.0, "Show_Hud", id+TASK_SHOWHUD, _, _, "b")
  192.     set_task(0.1, "Check_MaxXP", id, _, _, "b")
  193. }
  194.  
  195. public DelayLoad(id)
  196. {
  197.     // Load his data
  198.     LoadData(id)
  199. }
  200.  
  201. public client_disconnected(id)
  202. {
  203.     if(is_user_hltv(id) || is_user_bot(id))
  204.         return
  205.        
  206.     remove_task(id+TASK_SHOWHUD)
  207.     remove_task(id)
  208. }
  209.  
  210. public Check_MaxXP(id)
  211. {
  212.     new iCurrentMaxXP = g_iMaxXP[id]
  213.    
  214.     new iMaxXP = get_pcvar_num(g_pCvarMaxXPFirstLevel)
  215.    
  216.     for (new i = 1; i <= g_iLevel[id]; i++)
  217.     {
  218.         iMaxXP = floatround(float(iMaxXP) * get_pcvar_float(g_pCvarMaxLevelsIncrement))
  219.     }
  220.    
  221.     if (iCurrentMaxXP != iMaxXP)
  222.     {
  223.         g_iMaxXP[id] = iMaxXP
  224.     }
  225. }
  226.  
  227. public Show_Hud(taskid)
  228. {  
  229.     new iPlayer = ID_SHOWHUD
  230.    
  231.     if (!is_user_alive(iPlayer))
  232.     {
  233.         iPlayer = pev(iPlayer, pev_iuser2)
  234.        
  235.         if (!is_user_alive(iPlayer))
  236.             return
  237.     }
  238.    
  239.     if (get_pcvar_num(g_pCvarPercentageStyle) != 0)
  240.     {
  241.         if(iPlayer != ID_SHOWHUD)
  242.         {
  243.             set_hudmessage(HUD_STATS_SPEC_R, HUD_STATS_SPEC_G, HUD_STATS_SPEC_B, HUD_SPECT_X, HUD_SPECT_Y, 0, 6.0, 1.1, 0.0, 0.0, -1)
  244.             ShowSyncHudMsg(ID_SHOWHUD, g_MsgSync, "Level: %d | XP: %0.2f %", g_iLevel[iPlayer], (float(g_iXP[iPlayer])/float(g_iMaxXP[iPlayer])) * 100.0)
  245.         }
  246.         else if (ze_is_user_zombie(iPlayer))
  247.         {
  248.             set_hudmessage(HUD_STATS_ZOMBIE_R, HUD_STATS_ZOMBIE_G, HUD_STATS_ZOMBIE_B, HUD_STATS_X, HUD_STATS_Y, 0, 6.0, 1.1, 0.0, 0.0, -1)
  249.             ShowSyncHudMsg(ID_SHOWHUD, g_MsgSync, "Level: %d | XP: %0.2f %", g_iLevel[ID_SHOWHUD], (float(g_iXP[ID_SHOWHUD])/float(g_iMaxXP[ID_SHOWHUD])) * 100.0)
  250.         }
  251.         else
  252.         {
  253.             set_hudmessage(HUD_STATS_HUMAN_R, HUD_STATS_HUMAN_G, HUD_STATS_HUMAN_B, HUD_STATS_X, HUD_STATS_Y, 0, 6.0, 1.1, 0.0, 0.0, -1)
  254.             ShowSyncHudMsg(ID_SHOWHUD, g_MsgSync, "Level: %d | XP: %0.2f %", g_iLevel[ID_SHOWHUD], (float(g_iXP[ID_SHOWHUD])/float(g_iMaxXP[ID_SHOWHUD])) * 100.0)
  255.         }
  256.     }
  257.     else
  258.     {
  259.         if(iPlayer != ID_SHOWHUD)
  260.         {
  261.             if (get_pcvar_num(g_pCvarAddCommas) == 1)
  262.             {
  263.                 new szSpecXP[15], szSpecMaxXP[15]
  264.                
  265.                 AddCommas(g_iXP[iPlayer], szSpecXP, charsmax(szSpecXP))
  266.                 AddCommas(g_iMaxXP[iPlayer], szSpecMaxXP, charsmax(szSpecMaxXP))
  267.                
  268.                 set_hudmessage(HUD_STATS_SPEC_R, HUD_STATS_SPEC_G, HUD_STATS_SPEC_B, HUD_SPECT_X, HUD_SPECT_Y, 0, 6.0, 1.1, 0.0, 0.0, -1)
  269.                 ShowSyncHudMsg(ID_SHOWHUD, g_MsgSync, "Level: %d | XP: %s/%s", g_iLevel[iPlayer], szSpecXP, szSpecMaxXP)
  270.             }
  271.             else
  272.             {
  273.                 set_hudmessage(HUD_STATS_SPEC_R, HUD_STATS_SPEC_G, HUD_STATS_SPEC_B, HUD_SPECT_X, HUD_SPECT_Y, 0, 6.0, 1.1, 0.0, 0.0, -1)
  274.                 ShowSyncHudMsg(ID_SHOWHUD, g_MsgSync, "Level: %d | XP: %d/%d", g_iLevel[iPlayer], g_iXP[iPlayer], g_iMaxXP[iPlayer])
  275.             }  
  276.         }
  277.         else if (ze_is_user_zombie(iPlayer))
  278.         {
  279.             if (get_pcvar_num(g_pCvarAddCommas) == 1)
  280.             {
  281.                 new szZombieXP[15], szZombieMaxXP[15]
  282.                
  283.                 AddCommas(g_iXP[ID_SHOWHUD], szZombieXP, charsmax(szZombieXP))
  284.                 AddCommas(g_iMaxXP[ID_SHOWHUD], szZombieMaxXP, charsmax(szZombieMaxXP))
  285.                
  286.                 set_hudmessage(HUD_STATS_ZOMBIE_R, HUD_STATS_ZOMBIE_G, HUD_STATS_ZOMBIE_B, HUD_STATS_X, HUD_STATS_Y, 0, 6.0, 1.1, 0.0, 0.0, -1)
  287.                 ShowSyncHudMsg(ID_SHOWHUD, g_MsgSync, "Level: %d | XP: %s/%s", g_iLevel[ID_SHOWHUD], szZombieXP, szZombieMaxXP)
  288.             }
  289.             else
  290.             {
  291.                 set_hudmessage(HUD_STATS_ZOMBIE_R, HUD_STATS_ZOMBIE_G, HUD_STATS_ZOMBIE_B, HUD_STATS_X, HUD_STATS_Y, 0, 6.0, 1.1, 0.0, 0.0, -1)
  292.                 ShowSyncHudMsg(ID_SHOWHUD, g_MsgSync, "Level: %d | XP: %d/%d", g_iLevel[ID_SHOWHUD], g_iXP[ID_SHOWHUD], g_iMaxXP[ID_SHOWHUD])
  293.             }
  294.         }
  295.         else
  296.         {
  297.             if (get_pcvar_num(g_pCvarAddCommas) == 1)
  298.             {
  299.                 new szHumanXP[15], szHumanMaxXP[15]
  300.                
  301.                 AddCommas(g_iXP[ID_SHOWHUD], szHumanXP, charsmax(szHumanXP))
  302.                 AddCommas(g_iMaxXP[ID_SHOWHUD], szHumanMaxXP, charsmax(szHumanMaxXP))
  303.                
  304.                 set_hudmessage(HUD_STATS_HUMAN_R, HUD_STATS_HUMAN_G, HUD_STATS_HUMAN_B, HUD_STATS_X, HUD_STATS_Y, 0, 6.0, 1.1, 0.0, 0.0, -1)
  305.                 ShowSyncHudMsg(ID_SHOWHUD, g_MsgSync, "Level: %d | XP: %s/%s", g_iLevel[ID_SHOWHUD], szHumanXP, szHumanMaxXP)
  306.             }
  307.             else
  308.             {
  309.                 set_hudmessage(HUD_STATS_HUMAN_R, HUD_STATS_HUMAN_G, HUD_STATS_HUMAN_B, HUD_STATS_X, HUD_STATS_Y, 0, 6.0, 1.1, 0.0, 0.0, -1)
  310.                 ShowSyncHudMsg(ID_SHOWHUD, g_MsgSync, "Level: %d | XP: %d/%d", g_iLevel[ID_SHOWHUD], g_iXP[ID_SHOWHUD], g_iMaxXP[ID_SHOWHUD])
  311.             }
  312.         }
  313.     }
  314. }
  315.  
  316. public ze_roundend(WinTeam)
  317. {
  318.     if (WinTeam == ZE_TEAM_HUMAN)
  319.     {
  320.         for(new id = 1; id <= get_member_game(m_nMaxPlayers); id++)
  321.         {
  322.             if (!is_user_alive(id) || get_member(id, m_iTeam) == TEAM_TERRORIST)
  323.                 continue
  324.            
  325.             g_iXP[id] += get_pcvar_num(g_pCvarEscapeSuccess)
  326.             SaveData(id)
  327.             Check_User_Level(id)
  328.         }
  329.     }
  330.    
  331.     remove_task(TASK_SHOWHUD)
  332. }
  333.  
  334. public Check_User_Level(id)
  335. {
  336.     if(!is_user_connected(id))
  337.         return
  338.  
  339.     if(g_iXP[id] >= g_iMaxXP[id])
  340.     {
  341.         if (get_pcvar_num(g_pCvarStartFromZero) == 1)
  342.         {
  343.             g_iXP[id] = 0
  344.         }
  345.        
  346.         new szName[32]
  347.         g_iLevel[id] ++
  348.        
  349.         g_iMaxXP[id] = floatround(float(g_iMaxXP[id]) * get_pcvar_float(g_pCvarMaxLevelsIncrement))
  350.         get_user_name(id, szName, charsmax(szName))
  351.         ze_colored_print(0, "!g%s !tNow in Level %i!y!", szName, g_iLevel[id])
  352.         ExecuteForward(Fw_LevelUP, ForwardReturn, id)
  353.        
  354.         SaveData(id)
  355.        
  356.         PlaySound(id, LEVELUP)
  357.        
  358.         if (get_pcvar_num(g_pCvarLevelEffects) != 0)
  359.         {
  360.             // Screen Fade
  361.             message_begin(MSG_ONE, get_user_msgid("ScreenFade"), {0,0,0}, id)
  362.             write_short(4096*2)
  363.             write_short(4096*5)
  364.             write_short(0x0001)
  365.             write_byte(random(256))
  366.             write_byte(random(256))
  367.             write_byte(random(256))
  368.             write_byte(150)
  369.             message_end()
  370.            
  371.             // Screen Shake
  372.             message_begin(MSG_ONE, get_user_msgid("ScreenShake"), {0,0,0}, id)
  373.             write_short(255<<14)
  374.             write_short(10<<14)
  375.             write_short(255<<14)
  376.             message_end()
  377.         }
  378.     }
  379. }
  380.  
  381. public ze_user_infected(iVictim, iInfector)
  382. {
  383.     if (iInfector == 0)
  384.         return
  385.    
  386.     g_iXP[iInfector] += get_pcvar_num(g_pCvarZombieInfect)
  387.     SaveData(iInfector)
  388.     Check_User_Level(iInfector)
  389. }
  390.  
  391. public Fw_TakeDamage_Post(iVictim, iInflictor, iAttacker, Float:fDamage, bitsDamageType)
  392. {
  393.     // Player Damage Himself
  394.     if (iVictim == iAttacker || !is_user_alive(iVictim) || !is_user_alive(iAttacker) || ze_is_user_zombie(iAttacker) || !get_pcvar_num(g_pCvarEnableDamage))
  395.         return HC_CONTINUE
  396.    
  397.     // Same Team?
  398.     if (get_member(iAttacker, m_iTeam) == get_member(iVictim, m_iTeam))
  399.         return HC_CONTINUE
  400.    
  401.     // Store Damage For every Player
  402.     g_fDamage[iAttacker] += fDamage
  403.    
  404.     // Damage Calculator Equal or Higher than needed damage
  405.     if (g_fDamage[iAttacker] >= get_pcvar_float(g_pCvarRequiredDamage))
  406.     {
  407.         // Give Player The Coins
  408.         g_iXP[iAttacker] += get_pcvar_num(g_pCvarDamageAward)
  409.         SaveData(iAttacker)
  410.         Check_User_Level(iAttacker)
  411.        
  412.         // Rest The Damage Calculator
  413.         g_fDamage[iAttacker] = 0.0
  414.     }
  415.     return HC_CONTINUE
  416. }
  417.  
  418. public SaveData(id)
  419. {
  420.     new szAuthID[35], szName[32]
  421.     get_user_authid(id, szAuthID, charsmax(szAuthID))
  422.     get_user_name(id, szName, charsmax(szName))
  423.    
  424.     // Set Him to max if he Higher than Max Value
  425.     if (g_iLevel[id] > MAX_LEVEL)
  426.     {
  427.         g_iLevel[id] = MAX_LEVEL
  428.     }
  429.    
  430.     if (g_iXP[id] > MAX_XP)
  431.     {
  432.         g_iXP[id] = MAX_XP
  433.     }
  434.  
  435.     if (!get_pcvar_num(g_pCvarSaveType))
  436.     {
  437.         new szData[256]
  438.         formatex(szData , charsmax(szData), "%i %i %i", g_iLevel[id], g_iXP[id], g_iMaxXP[id])
  439.        
  440.         // Open the Vaults
  441.         g_iLevelsVaultHandle = nvault_open(g_szLevelsVault)
  442.         g_iRanksVaultHandle = nvault_open(g_szRanksVault)
  443.  
  444.         // Saves His Data
  445.         nvault_set(g_iLevelsVaultHandle, szAuthID, szData)
  446.         nvault_set(g_iRanksVaultHandle, szAuthID, szName)
  447.        
  448.         // Close Vaults
  449.         nvault_close(g_iLevelsVaultHandle)
  450.         nvault_close(g_iRanksVaultHandle)
  451.     }
  452.     else
  453.     {
  454.         new szQuery[128]
  455.         formatex(szQuery, charsmax(szQuery), "UPDATE `zombie_escape` SET `Level` = '%d', `XP` = '%d', `Max_XP` = '%d' WHERE ( `SteamID` = '%s' );", g_iLevel[id], g_iXP[id], g_iMaxXP[id], szAuthID)
  456.         SQL_ThreadQuery(g_hTuple, "QuerySetData", szQuery)
  457.     }
  458. }
  459.  
  460. public QuerySetData(iFailState, Handle:hQuery, szError[], iError, szData[], iSize, Float:flQueueTime)
  461. {
  462.     SQL_IsFail(iFailState, iError, szError, g_szLogFile)
  463. }
  464.  
  465. public QuerySetData2(iFailState, Handle:hQuery, szError[], iError, szData[], iSize, Float:flQueueTime)
  466. {
  467.     SQL_IsFail(iFailState, iError, szError, g_szLogFile)
  468. }
  469.  
  470. public LoadData(id)
  471. {
  472.     new szData[256], szAuthID[35]
  473.    
  474.     get_user_authid(id, szAuthID, charsmax(szAuthID))
  475.    
  476.     if (!get_pcvar_num(g_pCvarSaveType))
  477.     {
  478.         // Useless Variable
  479.         new iTimestamp, iExists
  480.        
  481.         // Open the Vault
  482.         g_iLevelsVaultHandle = nvault_open(g_szLevelsVault)
  483.        
  484.         iExists = nvault_lookup(g_iLevelsVaultHandle, szAuthID, szData, charsmax(szData), iTimestamp)
  485.        
  486.         // Close Vault
  487.         nvault_close(g_iLevelsVaultHandle)
  488.        
  489.         if (!iExists)
  490.         {
  491.             g_iLevel[id] = 0
  492.             g_iXP[id] = get_pcvar_num(g_pCvarStartXP)
  493.             g_iMaxXP[id] = get_pcvar_num(g_pCvarMaxXPFirstLevel)
  494.             SaveData(id)
  495.         }
  496.         else
  497.         {
  498.             new iLevel[32], iXP[32], iMaxLevel[32]
  499.             parse(szData, iLevel, 31, iXP, 31, iMaxLevel, 31)
  500.            
  501.             g_iLevel[id] = str_to_num(iLevel)
  502.             g_iXP[id] = str_to_num(iXP)
  503.             g_iMaxXP[id] = str_to_num(iMaxLevel)
  504.         }
  505.     }
  506.     else
  507.     {
  508.         new szQuery[128], szData[5]
  509.         formatex(szQuery, charsmax(szQuery), "SELECT * FROM `Players_Information` WHERE ( `SteamID` = '%s' );", szAuthID)
  510.      
  511.         num_to_str(id, szData, charsmax(szData))
  512.         SQL_ThreadQuery(g_hTuple, "QuerySelectData", szQuery, szData, charsmax(szData))
  513.     }
  514. }
  515.  
  516. public QuerySelectData(iFailState, Handle:hQuery, szError[], iError, szData[])
  517. {
  518.     if (SQL_IsFail(iFailState, iError, szError, g_szLogFile))
  519.         return
  520.    
  521.     new id = str_to_num(szData)
  522.    
  523.     // No results for this query means this is new player
  524.     if (!SQL_NumResults(hQuery))
  525.     {
  526.         new szSteamId[36], szQuery[128]
  527.         get_user_authid(id, szSteamId, charsmax(szSteamId))
  528.  
  529.         g_iLevel[id] = 0
  530.         g_iXP[id] = 0
  531.         g_iMaxXP[id] = get_pcvar_num(g_pCvarMaxXPFirstLevel)
  532.         return
  533.     }
  534.  
  535.     g_iLevel[id] = SQL_ReadResult(hQuery, SQL_FieldNameToNum(hQuery, "Level"))
  536.     g_iXP[id] = SQL_ReadResult(hQuery, SQL_FieldNameToNum(hQuery, "XP"))
  537.     g_iMaxXP[id] = SQL_ReadResult(hQuery, SQL_FieldNameToNum(hQuery, "Max_XP"))
  538. }
  539.  
  540. public native_ze_get_user_xp(id)
  541. {
  542.     if(!is_user_connected(id))
  543.     {
  544.         log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player id (%d)", id)
  545.         return false;
  546.     }
  547.    
  548.     return g_iXP[id]
  549. }
  550.  
  551. public native_ze_set_user_xp(id, amount)
  552. {
  553.     if(!is_user_connected(id))
  554.     {
  555.         log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player id (%d)", id)
  556.         return false;
  557.     }
  558.    
  559.     g_iXP[id] = amount
  560.    
  561.     Check_User_Level(id)
  562.     return true;
  563. }
  564.  
  565. public native_ze_get_user_level(id)
  566. {
  567.     if(!is_user_connected(id))
  568.     {
  569.         log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player id (%d)", id)
  570.         return false;
  571.     }
  572.    
  573.     return g_iLevel[id]
  574. }
  575.  
  576. public native_ze_set_user_level(id, amount)
  577. {
  578.     if(!is_user_connected(id))
  579.     {
  580.         log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player id (%d)", id)
  581.         return false;
  582.     }
  583.    
  584.     g_iLevel[id] = amount
  585.    
  586.     if (get_pcvar_num(g_pCvarStartFromZero) == 1)
  587.     {
  588.         g_iXP[id] = 0
  589.     }
  590.    
  591.     return true;
  592. }
  593.  
  594. public native_ze_get_user_max_xp(id)
  595. {
  596.     if(!is_user_connected(id))
  597.     {
  598.         log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player id (%d)", id)
  599.         return false;
  600.     }
  601.    
  602.     return g_iMaxXP[id]
  603. }
  604.  
  605. public native_ze_set_user_max_xp(id, amount)
  606. {
  607.     if(!is_user_connected(id))
  608.     {
  609.         log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player id (%d)", id)
  610.         return false;
  611.     }
  612.    
  613.     g_iMaxXP[id] = amount
  614.     return true;
  615. }
post ur ze.cfg file
my zombie_escpe.cfg is
  1. // Zombie Escape Configuration File
  2. // You can edit anything here and it will effcet your server when you Restart it
  3.  
  4. // Humans
  5. ze_human_speed_factor 20.0      // Human Speed Factor, Will be added to his weapon speed.
  6. ze_human_gravity 800            // Human Gravity
  7. ze_human_health 300         // Human HP
  8.  
  9. // Zombies
  10. ze_zombie_speed 300.0               // Zombie Speed
  11. ze_zombie_gravity 640               // Zombie Gravity
  12. ze_first_zombies_health 40000       // First Zombies Health
  13. ze_zombie_health 20000              // Zombie Health
  14. ze_zombie_knockback 300.0           // Zombie Knockback
  15. ze_zombie_nightvision 1             // Allow Night Vision for Zombie (0 = Disabled || 1 = Enabled)
  16. ze_zombie_auto_nightvision 1        // Automatic Enable Night Vision On Infection (0 = Disabled || 1 = Enabled)
  17. ze_zombie_nightvision_density 70    // Night Vision Density
  18. ze_zombie_nvision_red 253           // Night Vision Red Color
  19. ze_zombie_nvision_green 110         // Night Vision Green Color
  20. ze_zombie_nvision_blue 110          // Night Vision Blue Color
  21.  
  22. // General
  23. ze_lighting_style d        // Map Light Style Range from a to z(a = Very Dark || z = Normal Light)
  24. ze_release_time 15         // Time to freeze zombie(s)
  25. ze_freeze_time 20          // Time to freeze all players
  26. ze_round_time 9.0          // Round Time
  27. ze_block_kill 1            // Block Kill Command
  28. ze_required_players 1      // Required players to start the game
  29. ze_human_infected_frags 1  // Frags that Zombie Will earn when infecting Human
  30. ze_infection_deaths 1      // Deaths that will be added to Infected Human when he Infected
  31. ze_escape_success_frags 3  // Frags that will Alive humans Earn if they escaped
  32. ze_block_money_hud 1       // Block HUD money message
  33. ze_block_radar_ap_hp 0     // Block Radar, Armor and Health HUD messages
  34. ze_round_end_delay 5       // Delay the round end by this time in seconds.
  35.  
  36. // Messages
  37. ze_enable_infect_notice 1       // Infect Hud Message (0 = Disabled || 1 = Enabled)
  38. ze_infect_notice_red 255        // Infection Message Red Color
  39. ze_infect_notice_green 0        // Infection Message Green Color
  40. ze_infect_notice_blue 0         // Infection Message Blue Color
  41. ze_score_message_type 1         // Type of the Score Message (0 = Disabled || 1 = dhud || 2 = hud)
  42. ze_score_message_red 200        // Score Message Red Color
  43. ze_score_message_green 100      // Score Message Green Color
  44. ze_score_message_blue 0         // Score Message Blue Color
  45. ze_speed_rank_mode 2            // Rank Message (0 = Disabled || 1 = Leader Mode || 2 = Rank Mode)
  46. ze_speed_rank_red 0             // Rank Message Color Red (For Both Leader & Normal one)
  47. ze_speed_rank_green 230         // Rank Message Color Green (For Both Leader & Normal one)
  48. ze_speed_rank_blue 255          // Rank Message Color Blue (For Both Leader & Normal one)
  49. ze_leader_glow 0                // Glow For Leader Mode (0 = Disabled || 1 = Enabled)
  50. ze_leader_random_color 1        // If you enable this the glow color will be randomly if disabled it will take RGB colors you set
  51. ze_leader_glow_red 255          // Glow Red Color
  52. ze_leader_glow_green 0          // Glow Green Color
  53. ze_leader_glow_blue 0           // Glow Blue Color
  54. ze_hud_info_mode 1              // Player Hud Information like HP, Class, Escape Coins (0 = Disabled || 1 = Hud || 2 = Dhud)
  55. ze_hud_info_commas 1            // Enable Commas To HP (0 = Disabled || 1 = Enabled)
  56. ze_hud_info_zombie_red 255      // Zombie Information Red Color
  57. ze_hud_info_zombie_green 60     // Zombie Information Green Color
  58. ze_hud_info_zombie_blue 60      // Zombie Information Blue Color
  59. ze_hud_info_human_red 60        // Human Information Red Color
  60. ze_hud_info_human_green 60      // Human Information Green Color
  61. ze_hud_info_human_blue 255      // Human Information Blue Color
  62. ze_hud_info_spec_red 100        // Spectators Information Red Color
  63. ze_hud_info_spec_green 100      // Spectators Information Green Color
  64. ze_hud_info_spec_blue 100       // Spectators Information Blue Color
  65. ze_earn_chat_notice 1           // Earn Chat Notice Like: +30 Escape Coins (0 = Disabled || 1 = Enabled)
  66.  
  67. // Escape Coins system
  68. ze_coins_save_type 0       // Where to save? (0 = nVault | 1 = MySQL)
  69. ze_escape_success_coins 100 // Coins Alive humans earn on Escape Success
  70. ze_human_infected_coins 15  // Coins Zombie Earn when infect humans
  71. ze_damage_coins 3          // Coins human take when he make X damage to zombies
  72. ze_damage_required 1000     // X Damage required so player earn ze_damage_coins
  73. ze_start_coins 500          // Coins that will given to new players
  74. ze_max_coins 50000        // Max coins can player hold in his account
  75.  
  76. // Escape Coins MySQL Information (Needed only if you used MySQL)
  77. ze_ec_host "localhost"          // Database ip
  78. ze_ec_user "username"           // Database account username
  79. ze_ec_pass "password"           // Database account password
  80. ze_ec_dbname "database name"    // Database name
  81.  
  82. // Weapons
  83. ze_buy_time 60             // Time after it the player will not be able to use Weapon Menu
  84. ze_give_HE_nade 1          // Give HE Grenade Automatically
  85. ze_give_SM_nade 1          // Give Smoke Grenade Automatically
  86. ze_give_FB_nade 1          // Give Flashbang Grenade Automatically
  87.  
  88. // Madness
  89. ze_madness_time 5.0        // Madness Time for Zombies
  90. ze_madness_color_red 255   // Madness Aura Red Color
  91. ze_madness_color_green 0   // Madness Aura Green Color
  92. ze_madness_color_blue 0    // Madness Aura Blue Color
  93.  
  94. // Fire Nade
  95. ze_fire_duration 6         // Fire Nade burning time
  96. ze_fire_damage 10          // Fire Nade Damage every second
  97. ze_fire_hud_icon 1         // Fire Icon appear when player is being burn (0 = Disabled || 1 = Enabled)
  98. ze_fire_explosion 0        // Keep the normal Explosion (0 = Disabled || 1 = Enabled)
  99. ze_fire_slowdown 0.1       // Slowdown when player being burn
  100. ze_fire_radius 240.0       // Fire Nade explosion radius
  101. ze_fire_hit_type 0         // 0 = Fire can pass through walls | 1 = Fire nade must see zombie to fire him (can't pass walls)
  102.  
  103. // Frost Nade
  104. ze_frost_duration 4        // Frost Nade Freeze Duaration
  105. ze_frost_hud_icon 1        // Frost Nade Icon while frozen (0 = Disabled || 1 = Enabled)
  106. ze_freeze_damage 0         // Allow zombie take damage while frozen? (0 = No Damage || 1 = Take Damage)
  107. ze_freeze_radius 240.0     // Frost Nade explosion Radius
  108. ze_freeze_hit_type 0       // 0 = Frost can pass through walls | 1 = Frost nade must see zombie to fire him (can't pass walls)
  109.  
  110. // Server
  111. mp_autoteambalance 0      // Stop Automatic Balancing (game.cfg)
  112. mp_roundover 0            // Must be 0 (game.cfg)
  113. mp_round_infinite 0       // Must be 0 (game.cfg)
  114. mp_roundrespawn_time 30   // Time that player can respawn as zombie if zombie chosen (game.cfg)
  115. sv_maxspeed 400           // Set this more than zombie speed (server.cfg)
  116. mp_roundtime 9.0          // Set this same as ze_round_time cvar (server.cfg)
  117. mp_freezetime 20          // Set this same as ze_freeze_time cvar (server.cfg)
  118.  
  119. // Extra-Plugins Cvars
  120. ze_shield_time 10               // Force Shield nade time in seconds
  121. ze_break_hint_type 2            // Break hint type 2 = Center Chat | 1 = HUD
  122. ze_tank_gun_team 1              // Tank gun: 0 = Disabled for all | 1 = Disabled for zombies | 2 = Disabled for humans
  123. parachute_fallspeed 75          // Parachute fall speed? Max 100
  124. nademodes_motion_enabled 0      // Disable Motion Mod (Not Needed in ZombieEscape).
  125. nademodes_satchel_enabled 0     // Disable Stachel Mod (Not Needed in ZombieEscape).
  126. nademodes_proximity_limit 10    // You can set as you want.
  127. nademodes_trip_limit 10         // You can set as you want.
  128. ze_freezing_m4a1_damage 500     // Damage required then zombie get freeze?
  129. ze_multiplier_m4a1_damage 2     // Multiple the Frost M4A1 Damage by? [Integer Factor, 1 or 2 and so on]
  130. stunrifle_barfill_time 5        // The time in seconds that needed for every bar to be filled. There are 6 bars.
  131. stunrifle_radius 500            // The electricity beam will effect players in this radius while you reloading.
  132. stunrifle_electricity_dmg 10    //  The 1 bar electricity damage is 10, If it's 2 bars the damage is 20 if 3 bars damage is 30 and so on.
Image
Image

VicKy
Mod Tester
Mod Tester
Pakistan
Posts: 82
Joined: 1 Year Ago
Has thanked: 14 times
Been thanked: 11 times
Age: 19
Contact:

#145

Post by VicKy » 2 Months Ago

Please Fix The Mysql On Both
Maxx-Xp
No-Maxxp
These users thanked the author VicKy for the post:
Z0uha1r_LK (2 Months Ago)
Image
Image

soumyadip77
Member
Member
India
Posts: 13
Joined: 3 Years Ago
Has thanked: 0
Been thanked: 2 times
Contact:

#146

Post by soumyadip77 » 1 Month Ago

I was looking to the nomaxx code where i found something confusing can anyone tell me why it is here and why

Code: Select all

new const g_szTable[] =
" \
	ALTER TABLE `test` \
	ADD IF NOT EXISTS `Level` int(20) NOT NULL DEFAULT '0', \
	ADD IF NOT EXISTS `XP` int(20) NOT NULL DEFAULT '0', \
	ADD IF NOT EXISTS `Max_XP` int(20) NOT NULL DEFAULT '0'; \
"
here it is creating table right using this code

Code: Select all

public MySQL_Init()
{
	if (!get_pcvar_num(g_pCvarSaveType))
		return

	new szHost[64], szUser[32], szPass[32], szDB[128]

	get_pcvar_string(g_pCvarDBInfo[Host], szHost, charsmax(szHost))
	get_pcvar_string(g_pCvarDBInfo[User], szUser, charsmax(szUser))
	get_pcvar_string(g_pCvarDBInfo[Pass], szPass, charsmax(szPass))
	get_pcvar_string(g_pCvarDBInfo[DB], szDB, charsmax(szDB))

	g_hTuple = SQL_MakeDbTuple(szHost, szUser, szPass, szDB)

	// Let's ensure that the g_hTuple will be valid, we will access the database to make sure
	new iErrorCode, szError[512], Handle:hSQLConnection

	hSQLConnection = SQL_Connect(g_hTuple, iErrorCode, szError, charsmax(szError))

	if (hSQLConnection != Empty_Handle)
	{
		log_amx("[MySQL][LVL] Successfully connected to host: %s (ALL IS OK).", szHost)
		SQL_FreeHandle(hSQLConnection)
	}
	else
	{
		// Disable plugin
		set_fail_state("[LVL] Failed to connect to MySQL database: %s.", szError)
	}

	SQL_ThreadQuery(g_hTuple, "QueryCreateTable", g_szTable)
}

public QueryCreateTable(iFailState, Handle:hQuery, szError[], iError, szData[], iSize, Float:flQueueTime)
{
	SQL_IsFail(iFailState, iError, szError, g_szLogFile)
}
but while saving there is no link to this DB. it is updating on the ze coin system DB.

Code: Select all

public SaveData(id)
{
	new szAuthID[35], szName[32]
	get_user_authid(id, szAuthID, charsmax(szAuthID))
	get_user_name(id, szName, charsmax(szName))

	// Set Him to max if he Higher than Max Value
	if (g_iLevel[id] > MAX_LEVEL)
	{
		g_iLevel[id] = MAX_LEVEL
	}

	if (g_iXP[id] > MAX_XP)
	{
		g_iXP[id] = MAX_XP
	}

	if (!get_pcvar_num(g_pCvarSaveType))
	{
		new szData[256]
		formatex(szData , charsmax(szData), "%i %i %i", g_iLevel[id], g_iXP[id], g_iMaxXP[id])

		// Open the Vaults
		g_iLevelsVaultHandle = nvault_open(g_szLevelsVault)
		g_iRanksVaultHandle = nvault_open(g_szRanksVault)

		// Saves His Data
		nvault_set(g_iLevelsVaultHandle, szAuthID, szData)
		nvault_set(g_iRanksVaultHandle, szAuthID, szName)

		// Close Vaults
		nvault_close(g_iLevelsVaultHandle)
		nvault_close(g_iRanksVaultHandle)
	}
	else
	{
		new szQuery[128]
		formatex(szQuery, charsmax(szQuery), "UPDATE `zombie_escape` SET `Level` = '%d', `XP` = '%d', `Max_XP` = '%d' WHERE ( `SteamID` = '%s' );", g_iLevel[id], g_iXP[id], g_iMaxXP[id], szAuthID)
		SQL_ThreadQuery(g_hTuple, "QuerySetData", szQuery)
	}
}
also while loading Level it is using same ze coin system DB

Code: Select all

public LoadData(id)
{
	new szData[256], szAuthID[35]

	get_user_authid(id, szAuthID, charsmax(szAuthID))

	if (!get_pcvar_num(g_pCvarSaveType))
	{
		// Useless Variable
		new iTimestamp, iExists

		// Open the Vault
		g_iLevelsVaultHandle = nvault_open(g_szLevelsVault)

		iExists = nvault_lookup(g_iLevelsVaultHandle, szAuthID, szData, charsmax(szData), iTimestamp)

		// Close Vault
		nvault_close(g_iLevelsVaultHandle)

		if (!iExists)
		{
			g_iLevel[id] = 0
			g_iXP[id] = get_pcvar_num(g_pCvarStartXP)
			g_iMaxXP[id] = get_pcvar_num(g_pCvarMaxXPFirstLevel)
			SaveData(id)
		}
		else
		{
			new iLevel[32], iXP[32], iMaxLevel[32]
			parse(szData, iLevel, 31, iXP, 31, iMaxLevel, 31)

			g_iLevel[id] = str_to_num(iLevel)
			g_iXP[id] = str_to_num(iXP)
			g_iMaxXP[id] = str_to_num(iMaxLevel)
		}
	}
	else
	{
		new szQuery[128], szData[5]
		formatex(szQuery, charsmax(szQuery), "SELECT * FROM `Players_Information` WHERE ( `SteamID` = '%s' );", szAuthID)

		num_to_str(id, szData, charsmax(szData))
		SQL_ThreadQuery(g_hTuple, "QuerySelectData", szQuery, szData, charsmax(szData))
	}
}
btw i am talking about SQL not nvault

User avatar
Z0uha1r_LK
Moderator
Moderator
Morocco
Posts: 342
Joined: 2 Years Ago
Location: Morocco
Has thanked: 92 times
Been thanked: 39 times
Age: 19
Contact:

#147

Post by Z0uha1r_LK » 1 Month Ago

soumyadip77 wrote:
1 Month Ago
I was looking to the nomaxx code where i found something confusing can anyone tell me why it is here and why

Code: Select all

new const g_szTable[] =
" \
	ALTER TABLE `test` \
	ADD IF NOT EXISTS `Level` int(20) NOT NULL DEFAULT '0', \
	ADD IF NOT EXISTS `XP` int(20) NOT NULL DEFAULT '0', \
	ADD IF NOT EXISTS `Max_XP` int(20) NOT NULL DEFAULT '0'; \
"
here it is creating table right using this code

Code: Select all

public MySQL_Init()
{
	if (!get_pcvar_num(g_pCvarSaveType))
		return

	new szHost[64], szUser[32], szPass[32], szDB[128]

	get_pcvar_string(g_pCvarDBInfo[Host], szHost, charsmax(szHost))
	get_pcvar_string(g_pCvarDBInfo[User], szUser, charsmax(szUser))
	get_pcvar_string(g_pCvarDBInfo[Pass], szPass, charsmax(szPass))
	get_pcvar_string(g_pCvarDBInfo[DB], szDB, charsmax(szDB))

	g_hTuple = SQL_MakeDbTuple(szHost, szUser, szPass, szDB)

	// Let's ensure that the g_hTuple will be valid, we will access the database to make sure
	new iErrorCode, szError[512], Handle:hSQLConnection

	hSQLConnection = SQL_Connect(g_hTuple, iErrorCode, szError, charsmax(szError))

	if (hSQLConnection != Empty_Handle)
	{
		log_amx("[MySQL][LVL] Successfully connected to host: %s (ALL IS OK).", szHost)
		SQL_FreeHandle(hSQLConnection)
	}
	else
	{
		// Disable plugin
		set_fail_state("[LVL] Failed to connect to MySQL database: %s.", szError)
	}

	SQL_ThreadQuery(g_hTuple, "QueryCreateTable", g_szTable)
}

public QueryCreateTable(iFailState, Handle:hQuery, szError[], iError, szData[], iSize, Float:flQueueTime)
{
	SQL_IsFail(iFailState, iError, szError, g_szLogFile)
}
but while saving there is no link to this DB. it is updating on the ze coin system DB.

Code: Select all

public SaveData(id)
{
	new szAuthID[35], szName[32]
	get_user_authid(id, szAuthID, charsmax(szAuthID))
	get_user_name(id, szName, charsmax(szName))

	// Set Him to max if he Higher than Max Value
	if (g_iLevel[id] > MAX_LEVEL)
	{
		g_iLevel[id] = MAX_LEVEL
	}

	if (g_iXP[id] > MAX_XP)
	{
		g_iXP[id] = MAX_XP
	}

	if (!get_pcvar_num(g_pCvarSaveType))
	{
		new szData[256]
		formatex(szData , charsmax(szData), "%i %i %i", g_iLevel[id], g_iXP[id], g_iMaxXP[id])

		// Open the Vaults
		g_iLevelsVaultHandle = nvault_open(g_szLevelsVault)
		g_iRanksVaultHandle = nvault_open(g_szRanksVault)

		// Saves His Data
		nvault_set(g_iLevelsVaultHandle, szAuthID, szData)
		nvault_set(g_iRanksVaultHandle, szAuthID, szName)

		// Close Vaults
		nvault_close(g_iLevelsVaultHandle)
		nvault_close(g_iRanksVaultHandle)
	}
	else
	{
		new szQuery[128]
		formatex(szQuery, charsmax(szQuery), "UPDATE `zombie_escape` SET `Level` = '%d', `XP` = '%d', `Max_XP` = '%d' WHERE ( `SteamID` = '%s' );", g_iLevel[id], g_iXP[id], g_iMaxXP[id], szAuthID)
		SQL_ThreadQuery(g_hTuple, "QuerySetData", szQuery)
	}
}
also while loading Level it is using same ze coin system DB

Code: Select all

public LoadData(id)
{
	new szData[256], szAuthID[35]

	get_user_authid(id, szAuthID, charsmax(szAuthID))

	if (!get_pcvar_num(g_pCvarSaveType))
	{
		// Useless Variable
		new iTimestamp, iExists

		// Open the Vault
		g_iLevelsVaultHandle = nvault_open(g_szLevelsVault)

		iExists = nvault_lookup(g_iLevelsVaultHandle, szAuthID, szData, charsmax(szData), iTimestamp)

		// Close Vault
		nvault_close(g_iLevelsVaultHandle)

		if (!iExists)
		{
			g_iLevel[id] = 0
			g_iXP[id] = get_pcvar_num(g_pCvarStartXP)
			g_iMaxXP[id] = get_pcvar_num(g_pCvarMaxXPFirstLevel)
			SaveData(id)
		}
		else
		{
			new iLevel[32], iXP[32], iMaxLevel[32]
			parse(szData, iLevel, 31, iXP, 31, iMaxLevel, 31)

			g_iLevel[id] = str_to_num(iLevel)
			g_iXP[id] = str_to_num(iXP)
			g_iMaxXP[id] = str_to_num(iMaxLevel)
		}
	}
	else
	{
		new szQuery[128], szData[5]
		formatex(szQuery, charsmax(szQuery), "SELECT * FROM `Players_Information` WHERE ( `SteamID` = '%s' );", szAuthID)

		num_to_str(id, szData, charsmax(szData))
		SQL_ThreadQuery(g_hTuple, "QuerySelectData", szQuery, szData, charsmax(szData))
	}
}
btw i am talking about SQL not nvault
plugin is support MySQL!, You can save level in MySQL DB

soumyadip77
Member
Member
India
Posts: 13
Joined: 3 Years Ago
Has thanked: 0
Been thanked: 2 times
Contact:

#148

Post by soumyadip77 » 1 Month Ago

but code looks not good
These users thanked the author soumyadip77 for the post:
Z0uha1r_LK (1 Month Ago)

atilla_be
Member
Member
Belgium
Posts: 5
Joined: 1 Week Ago
Has thanked: 0
Been thanked: 1 time
Contact:

#149

Post by atilla_be » 1 Week Ago

Code: Select all

AMX Mod X Compiler 1.10.0.5445
Copyright (c) 1997-2006 ITB CompuPhase
Copyright (c) 2004-2013 AMX Mod X Team

ze_level_system.sma(25) : error 018: initialization data exceeds declared size
ze_level_system.sma(512) : warning 204: symbol is assigned a value that is never used: "szQuery"

1 Error.
Could not locate output file ze_level_system.amx (compile failed).
console

Code: Select all

L 11/17/2021 - 12:33:22: [AMXX] Plugin "ze_items_level.amxx" failed to load: Plugin uses an unknown function (name "ze_get_user_level") - check your modules.ini.

User avatar
Z0uha1r_LK
Moderator
Moderator
Morocco
Posts: 342
Joined: 2 Years Ago
Location: Morocco
Has thanked: 92 times
Been thanked: 39 times
Age: 19
Contact:

#150

Post by Z0uha1r_LK » 1 Week Ago

atilla_be wrote:
1 Week Ago

Code: Select all

AMX Mod X Compiler 1.10.0.5445
Copyright (c) 1997-2006 ITB CompuPhase
Copyright (c) 2004-2013 AMX Mod X Team

ze_level_system.sma(25) : error 018: initialization data exceeds declared size
ze_level_system.sma(512) : warning 204: symbol is assigned a value that is never used: "szQuery"

1 Error.
Could not locate output file ze_level_system.amx (compile failed).
console

Code: Select all

L 11/17/2021 - 12:33:22: [AMXX] Plugin "ze_items_level.amxx" failed to load: Plugin uses an unknown function (name "ze_get_user_level") - check your modules.ini.
sent me .sma

Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests