Raised This Month: $30 Target: $400
 7% 

Cvars not working


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
yagami
Member
Join Date: Jan 2021
Old 12-08-2022 , 20:07   Cvars not working
Reply With Quote #1

This plugin is a plugin made for Zombie Escape, the only problem is that I am using ZP 4.3 FIX to run Zombie Escape, so I had to adapt things

Can anybody help me to fix it, these are the following plugins

g_pCvarZombieInfect is not working
g_pCvarEscapeSuccess is not working

PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <reapi>
#include <fakemeta>
#include <hamsandwich>
#include <nvault>
#include <sqlx>
#include <amx_settings_api>
#include <cs_weap_models_api>
#include <zombieplague>

native ze_get_user_xp(id);
native ze_set_user_xp(idiXP);

// Defines
#define MAX_LEVEL 100
#define MAX_XP 500000
#define TASK_SHOWHUD 2020
#define ID_SHOWHUD (taskid - TASK_SHOWHUD)
#define LEVELUP "levelup_ZE/ze_levelup.wav"

enum
{
    
Host 0,
    
User,
    
Pass,
    
DB
}

// 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', \
    ADD IF NOT EXISTS `Max_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 = -1.0
const Float:HUD_STATS_Y 0.90

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

// Cvars
new g_pCvarZombieInfect
    
g_pCvarEscapeSuccess,
    
g_pCvarEnableDamage
    
g_pCvarRequiredDamage
    
g_pCvarDamageAward
    
g_pCvarStartXP
    
g_pCvarMaxLevelsIncrement
    
g_pCvarMaxXPFirstLevel,
    
//g_pCvarPercentageStyle, 
    
g_pCvarStartFromZero
    
//g_pCvarAddCommas, 
    
g_pCvarLevelEffects,
    
g_pCvarSaveType,
    
g_pCvarDBInfo[4]

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)
    
register_native("ze_set_user_max_xp""native_ze_set_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_IGNOREFP_CELL)
    
register_event("HLTV""r""a""1=0""2=0")
    
    
// 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""700.0")
    
g_pCvarDamageAward register_cvar("ze_dmg_award""1")
    
g_pCvarStartXP register_cvar("ze_start_xp""50")
    
g_pCvarMaxLevelsIncrement register_cvar("ze_maxlevels_increment""2.0")
    
g_pCvarMaxXPFirstLevel register_cvar("ze_max_xp_first_level""100")
    
//g_pCvarPercentageStyle = register_cvar("ze_enable_percentage_style", "1")
    
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""1")
    
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")
    }
}

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], szHostcharsmax(szHost))
    
get_pcvar_string(g_pCvarDBInfo[User], szUsercharsmax(szUser))
    
get_pcvar_string(g_pCvarDBInfo[Pass], szPasscharsmax(szPass))
    
get_pcvar_string(g_pCvarDBInfo[DB], szDBcharsmax(szDB))
    
    
g_hTuple SQL_MakeDbTuple(szHostszUserszPassszDB)
    
    
// Let's ensure that the g_hTuple will be valid, we will access the database to make sure
    
new iErrorCodeszError[512], Handle:hSQLConnection
    
    hSQLConnection 
SQL_Connect(g_hTupleiErrorCodeszErrorcharsmax(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(iFailStateHandle:hQueryszError[], iErrorszData[], iSizeFloat:flQueueTime
{
    
SQL_IsFail(iFailStateiErrorszErrorg_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")
    
set_task(0.1"Check_MaxXP"id__"b")
}

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 
Check_MaxXP(id)
{
    new 
iCurrentMaxXP g_iMaxXP[id]
    
    new 
iMaxXP get_pcvar_num(g_pCvarMaxXPFirstLevel)
    
    for (new 
1<= g_iLevel[id]; i++)
    {
        
iMaxXP floatround(float(iMaxXP) * get_pcvar_float(g_pCvarMaxLevelsIncrement))
    }
    
    if (
iCurrentMaxXP != iMaxXP)
    {
        
g_iMaxXP[id] = iMaxXP
    
}
}

public 
Show_Hud(taskid)
{    
    new 
iPlayer ID_SHOWHUD
    
    
if (!is_user_alive(iPlayer))
    {
        
iPlayer pev(iPlayerpev_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)
{
    new 
iPlayers[MAX_PLAYERS], iNum
    
switch(WinTeam)
    {
        case 
1get_players(iPlayersiNum"ace""TERRORIST")
        case 
2get_players(iPlayersiNum"ace""CT")
        default: return;
    }

    for(new 
id 0id <= iNumid++)
    {    
        
g_iXP[iPlayers[id]] += get_pcvar_num(g_pCvarEscapeSuccess
        
SaveData(iPlayers[id])
        
Check_User_Level(iPlayers[id])
        
zp_colored_print(iPlayers[id], "Voce ganhou %iXP"get_pcvar_num(g_pCvarEscapeSuccess) )
    }

}

public 
Check_User_Level(id)
{
    if(!
is_user_connected(id))
        return

    if(
g_iXP[id] >= g_iMaxXP[id])
    {
        if (
get_pcvar_num(g_pCvarStartFromZero) == 1)
        {
            
g_iXP[id] = 0
        
}
        
        new 
szName[32]
        
g_iLevel[id] ++
        
g_iMaxXP[id] = floatround(float(g_iMaxXP[id]) * get_pcvar_float(g_pCvarMaxLevelsIncrement))
        
get_user_name(idszNamecharsmax(szName))
        
zp_colored_print(0"^4%s ^1Passou para level ^4%i!"szNameg_iLevel[id])
        
ExecuteForward(Fw_LevelUPForwardReturnid)
        
        
SaveData(id)
        
        
PlaySound(idLEVELUP)
        
        if (
get_pcvar_num(g_pCvarLevelEffects) != 0)
        {
            
// Screen Fade
            
message_begin(MSG_ONEget_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_ONEget_user_msgid("ScreenShake"), {0,0,0}, id)
            
write_short(255<<14)
            
write_short(10<<14)
            
write_short(255<<14)
            
message_end()
        }
    }
}

public 
zp_user_infected(iVictimiInfector)
{
    if (
iInfector == 0)
        return


    
ze_set_user_xp(iInfectorze_get_user_xp(iInfector) + get_pcvar_num(g_pCvarZombieInfect))
    
client_print_color(iInfectorprint_team_default ,"^1Voce ganhou ^4%i ^1XP por infectar alguem!"get_pcvar_num(g_pCvarZombieInfect))
    
SaveData(iInfector)
    
Check_User_Level(iInfector)
}

public 
Fw_TakeDamage_Post(iVictimiInflictoriAttackerFloat:fDamagebitsDamageType)
{
    
// Player Damage Himself
    
if (iVictim == iAttacker || !is_user_alive(iVictim) || !is_user_alive(iAttacker) || zp_get_user_zombie(iAttacker) || !get_pcvar_num(g_pCvarEnableDamage))
        return 
HC_CONTINUE
    
    
// Same Team?
    
if (get_member(iAttackerm_iTeam) == get_member(iVictimm_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))
    {
        
// Give Player The Coins
        
g_iXP[iAttacker] += get_pcvar_num(g_pCvarDamageAward)
        
SaveData(iAttacker)
        
Check_User_Level(iAttacker)
        
        
// Rest The Damage Calculator
        
g_fDamage[iAttacker] = 0.0
    
}
    return 
HC_CONTINUE
}

public 
SaveData(id)
{
    new 
szAuthID[35], szName[32]
    
get_user_authid(idszAuthIDcharsmax(szAuthID))
    
get_user_name(idszNamecharsmax(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_iLevelsVaultHandleszAuthIDszData)
        
nvault_set(g_iRanksVaultHandleszAuthIDszName)
        
        
// Close Vaults
        
nvault_close(g_iLevelsVaultHandle)
        
nvault_close(g_iRanksVaultHandle)
    }
    else
    {
        new 
szQuery[128]
        
formatex(szQuerycharsmax(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)
    }
}

public 
QuerySetData(iFailStateHandle:hQueryszError[], iErrorszData[], iSizeFloat:flQueueTime
{
    
SQL_IsFail(iFailStateiErrorszErrorg_szLogFile)
}

public 
QuerySetData2(iFailStateHandle:hQueryszError[], iErrorszData[], iSizeFloat:flQueueTime
{
    
SQL_IsFail(iFailStateiErrorszErrorg_szLogFile)
}

public 
LoadData(id)
{
    new 
szData[256], szAuthID[35]
    
    
get_user_authid(idszAuthIDcharsmax(szAuthID))
    
    if (!
get_pcvar_num(g_pCvarSaveType))
    {
        
// Useless Variable
        
new iTimestampiExists
        
        
// Open the Vault
        
g_iLevelsVaultHandle nvault_open(g_szLevelsVault)
        
        
iExists nvault_lookup(g_iLevelsVaultHandleszAuthIDszDatacharsmax(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(szDataiLevel31iXP31iMaxLevel31)
            
            
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(szQuerycharsmax(szQuery), "SELECT * FROM `Players_Information` WHERE ( `SteamID` = '%s' );"szAuthID)
     
        
num_to_str(idszDatacharsmax(szData))
        
SQL_ThreadQuery(g_hTuple"QuerySelectData"szQueryszDatacharsmax(szData))
    }
}

public 
QuerySelectData(iFailStateHandle:hQueryszError[], iErrorszData[]) 
{
    if (
SQL_IsFail(iFailStateiErrorszErrorg_szLogFile))
        return
    
    new 
id str_to_num(szData)
    
    
// No results for this query means this is new player
    
if (!SQL_NumResults(hQuery))
    {
        new 
szSteamId[36]
        
get_user_authid(idszSteamIdcharsmax(szSteamId))

        
g_iLevel[id] = 0
        g_iXP
[id] = 0
        g_iMaxXP
[id] = get_pcvar_num(g_pCvarMaxXPFirstLevel)
        return
    }

    
g_iLevel[id] = SQL_ReadResult(hQuerySQL_FieldNameToNum(hQuery"Level"))
    
g_iXP[id] = SQL_ReadResult(hQuerySQL_FieldNameToNum(hQuery"XP"))
    
g_iMaxXP[id] = SQL_ReadResult(hQuerySQL_FieldNameToNum(hQuery"Max_XP"))
}

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(idamount)
{
    if(!
is_user_connected(id))
    {
        
log_error(AMX_ERR_NATIVE"[ZE] Invalid Player id (%d)"id)
        return 
false;
    }
    
    
g_iXP[id] = amount
    
    Check_User_Level
(id)
    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(idamount)
{
    if(!
is_user_connected(id))
    {
        
log_error(AMX_ERR_NATIVE"[ZE] Invalid Player id (%d)"id)
        return 
false;
    }
    
    
g_iLevel[id] = amount
    
    
if (get_pcvar_num(g_pCvarStartFromZero) == 1)
    {
        
g_iXP[id] = 0
    
}
    
    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]
}

public 
native_ze_set_user_max_xp(idamount)
{
    if(!
is_user_connected(id))
    {
        
log_error(AMX_ERR_NATIVE"[ZE] Invalid Player id (%d)"id)
        return 
false;
    }
    
    
g_iMaxXP[id] = amount
    
return true;
}


zp_colored_print(target, const message[], any:...)
{
    static 
buffer[512], msg_SayText 0
    
if( !msg_SayText msg_SayText get_user_msgid("SayText"
    
    
// Send to everyone
    
if (!target)
    {
        static 
playermaxplayersargscount
        maxplayers 
get_member_game(m_nMaxPlayers)
        
argscount numargs()
        
        for (
player 1player <= maxplayersplayer++)
        {
            
// Not connected
            
if (!is_user_connected(player))
                continue;
            
            
// Remember changed arguments
            
static arg_indexchanged_args[20], changedcount // [20] = max LANG_PLAYER occurencies    
            
changedcount 0
            
            
// Replace LANG_PLAYER with player id
            
for (arg_index 2arg_index argscountarg_index++)
            {
                if (
getarg(arg_index) == LANG_PLAYER && arg_index argscount)
                {
                    
// Check if next param string is a registered language translation
                    
static lang_key[64], arg_subindex
                    arg_subindex 
0
                    
while ((lang_key[arg_subindex] = getarg(arg_index 1arg_subindex++))) { /* keep looping */ }
                    if (
GetLangTransKey(lang_key) != TransKey_Bad)
                    {
                        
setarg(arg_index0player)
                        
changed_args[changedcount++] = arg_index
                        arg_index
++ // skip next argument since we know it's a translation key
                    
}
                }
            }
            
            
// Format message for player (+add ZE prefix)
            
vformat(buffercharsmax(buffer), message3)
            
format(buffercharsmax(buffer), "%s%s""[Star]"buffer)
            
            
replace_all(buffercharsmax(buffer), "!g""^x04"); // Green Color  
            
replace_all(buffercharsmax(buffer), "!y""^x01"); // Yellow Color  
            
replace_all(buffercharsmax(buffer), "!t""^x03"); // Team Color 
            
            // Send it
            
message_begin(MSG_ONE_UNRELIABLEmsg_SayText_player)
            
write_byte(player)
            
write_string(buffer)
            
message_end()
            
            
// Replace back player id's with LANG_PLAYER
            
for (arg_index 0arg_index changedcountarg_index++)
                
setarg(changed_args[arg_index], 0LANG_PLAYER)
        }
    }
    
// Send to specific target
    
else
    {
        
// Format message for player (+add ZE prefix)
        
vformat(buffercharsmax(buffer), message3)
        
format(buffercharsmax(buffer), "%s%s""[Star]"buffer)
        
        
replace_all(buffercharsmax(buffer), "!g""^x04"); // Green Color  
        
replace_all(buffercharsmax(buffer), "!y""^x01"); // Yellow Color  
        
replace_all(buffercharsmax(buffer), "!t""^x03"); // Team Color 
            
        // Send it
        
message_begin(MSG_ONEmsg_SayText_target)
        
write_byte(target)
        
write_string(buffer)
        
message_end()
    }
}

stock GetPlayersNum(CsTeams:iTeam) {
    new 
iNum
    
for( new 1<= get_maxplayers(); i++ ) {
        if(
is_user_connected(i) && is_user_alive(i) && cs_get_user_team(i) == iTeam)
            
iNum++
    }
    return 
iNum
}
// Stop Sound 
yagami is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 23:31.


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