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

nVault Helps


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Darkskypew
Member
Join Date: Sep 2010
Old 12-19-2011 , 06:40   nVault Helps
Reply With Quote #1

Why broken?

PHP Code:
public saver(id)
{
    new 
s_Key[255], s_AP[5], s_Level[5], s_Damage[255], s_DamageMax[255]
    new 
datas[255]
    
formatex(s_Keycharsmax(s_Key) , "%s"Names[id])
    
formatex(s_APcharsmax(s_AP), "%d"zp_ammopacks_get(id))
    
formatex(s_Levelcharsmax(s_Level), "%d"Level[id])
    
formatex(s_Damagecharsmax(s_Damage), "%d"g_DamageEXP[id])
    
formatex(s_DamageMaxcharsmax(s_DamageMax), "%d"MaxEXP[id])
    
    
formatex(datas255" %i %i %i %i"s_APs_Levels_Damages_DamageMax)
        
    
nvault_set(g_Vaults_Keydatas)
}

public 
load(id)
{
    new 
s_Key[255], s_APS[5], s_LevelS[5], s_DamageS[255], s_DamageMaxS[255], datas[255]
    
formatex(s_Keycharsmax(s_Key) , "%s"Names[id])
       
    
nvault_get (g_Vaults_Keydatas255)
       
    
parse (datass_APS[0], 11s_LevelS[1], 11s_DamageS[2], 11s_DamageMaxS[3], 11)
       
    
AMMO[id] = str_to_num (s_APS[0])
    
Level[id] = str_to_num (s_LevelS[1])
    
g_DamageEXP[id] = str_to_num (s_DamageS[2])
    
MaxEXP[id] = str_to_num (s_DamageMaxS[3])

Darkskypew is offline
Darkskypew
Member
Join Date: Sep 2010
Old 12-20-2011 , 10:15   Re: nVault Helps
Reply With Quote #2

did so

PHP Code:
public saverz(id)
{
    new 
s_Key[255]
    new 
datas[255]
    
formatex(s_Keycharsmax(s_Key) , "%s-Name"Names[id])
    
    
formatex(datas255"%i#%i#%i#%i"AMMO[id], Level[id], g_DamageEXP[id], MaxEXP[id])
        
    
nvault_set(g_Vaults_Keydatas)
}

public 
loadz(id)
{
    new 
s_Key[255], datas[255], s_APS[32], s_LevelS[32], s_DamageS[32], s_DamageMaxS[32]
    
formatex(s_Keycharsmax(s_Key) , "%s-Name"Names[id])
    
formatex(datas255"%i#%i#%i#%i"AMMO[id], Level[id], g_DamageEXP[id], MaxEXP[id])
    
nvault_get (g_Vaults_Keydatas255)
    
replace_all(datas 255"#"" ")
    
parse (datass_APS31s_LevelS31s_DamageS31s_DamageMaxS31)
       
    
AMMOS[id] = str_to_num (s_APS)
    
Level[id] = str_to_num (s_LevelS)
    
g_DamageEXP[id] = str_to_num (s_DamageS)
    
MaxEXP[id] = str_to_num (s_DamageMaxS)
    return 
PLUGIN_CONTINUE

Working. Half the players working, HALF NOT.

Why broken?
Darkskypew is offline
Old 12-20-2011, 10:47
drekes
This message has been deleted by drekes. Reason: Won't work
drekes
Veteran Member
Join Date: Jul 2009
Location: Vault 11
Old 12-20-2011 , 10:49   Re: nVault Helps
Reply With Quote #3

It's probably something else then these functions, i don't see anything wrong.
Post the whole code.
__________________

Quote:
Originally Posted by nikhilgupta345 View Post
You're retarded.
drekes is offline
Send a message via MSN to drekes
Darkskypew
Member
Join Date: Sep 2010
Old 12-20-2011 , 11:05   Re: nVault Helps
Reply With Quote #4

Thanx for post

PHP Code:
/*================================================================================
    
    --------------------------------
    -*- [ZP] Rewards: Ammo Packs -*-
    --------------------------------
    
    This plugin is part of Zombie Plague Mod and is distributed under the
    terms of the GNU General Public License. Check ZP_ReadMe.txt for details.
    
================================================================================*/

#include <amxmodx>
#include <hamsandwich>
#include <fakemeta>
#include <cs_ham_bots_api>
#include <zp50_gamemodes>
#define LIBRARY_NEMESIS "zp50_class_nemesis"
#include <zp50_class_nemesis>
#define LIBRARY_SURVIVOR "zp50_class_survivor"
#include <zp50_class_survivor>
#include <zp50_ammopacks>
#include <zombielite_para>
#include <dhudmessage>
#include <nvault>

#define MAXPLAYERS 32

new g_MaxPlayers
new lvlspr

new Level[33] = 0
new MaxEXP[33] = 500
new g_Vault
new AMMO[33]
new 
AMMOS[33]
new 
save[33]

new 
Float:g_DamageDealtToZombies[MAXPLAYERS+1]
new 
Float:g_DamageDealtToHumans[MAXPLAYERS+1]
new 
Float:g_DamageEXP[MAXPLAYERS+1]

new 
cvar_ammop_winnercvar_ammop_loser
new cvar_ammop_damagecvar_ammop_zombie_damaged_hpcvar_ammop_human_damaged_hp
new cvar_ammop_zombie_killedcvar_ammop_human_killed
new cvar_ammop_human_infected
new cvar_ammop_nemesis_ignorecvar_ammop_survivor_ignore

new const lvlup[] =    "zl/fun/levelup.wav"

public plugin_init()
{
    
register_plugin("[ZP] Rewards: Ammo Packs"ZP_VERSION_STRING"ZP Dev Team")
    
    
cvar_ammop_winner register_cvar("zp_ammop_winner""3")
    
cvar_ammop_loser register_cvar("zp_ammop_loser""1")
    
cvar_ammop_damage register_cvar("zp_ammop_damage""1")
    
cvar_ammop_zombie_damaged_hp register_cvar("zp_ammop_zombie_damaged_hp""500")
    
cvar_ammop_human_damaged_hp register_cvar("zp_ammop_human_damaged_hp""250")
    
cvar_ammop_zombie_killed register_cvar("zp_ammop_zombie_killed""1")
    
cvar_ammop_human_killed register_cvar("zp_ammop_human_killed""1")
    
cvar_ammop_human_infected register_cvar("zp_ammop_human_infected""1")
    
    
    
// Nemesis Class loaded?
    
if (LibraryExists(LIBRARY_NEMESISLibType_Library))
        
cvar_ammop_nemesis_ignore register_cvar("zp_ammop_nemesis_ignore""0")
    
    
// Survivor Class loaded?
    
if (LibraryExists(LIBRARY_SURVIVORLibType_Library))
        
cvar_ammop_survivor_ignore register_cvar("zp_ammop_survivor_ignore""0")
    
    
RegisterHam(Ham_TakeDamage"player""fw_TakeDamage_Post"1)
    
RegisterHamBots(Ham_TakeDamage"fw_TakeDamage_Post"1)
    
RegisterHam(Ham_Killed"player""fw_PlayerKilled_Post"1)
    
RegisterHamBots(Ham_Killed"fw_PlayerKilled_Post"1)
    
register_forward(FM_PlayerPreThink"fw_PlayerPreThink");
    
g_MaxPlayers get_maxplayers()
    
// Открываем файл и сохраняем указатель в g_Vault
    
g_Vault nvault_open("zombielite")

    
// Прекращаем работу плагина, если файл не удалось открыть
    
if (g_Vault == INVALID_HANDLE)
        
set_fail_state("Error opening nVault!")
    
nvault_prune(g_Vault0get_systime() - (15 86400)) 
}

public 
saverz(id)
{
    new 
s_Key[255]
    new 
datas[255]
    new 
Names[33]
    
get_user_name(idNames32)
    
formatex(s_Keycharsmax(s_Key) , "%s-Name"Names)
    
    
formatex(datas255"%i#%i#%i#%i"AMMO[id], Level[id], g_DamageEXP[id], MaxEXP[id])
        
    
nvault_set(g_Vaults_Keydatas)
}

public 
loadz(id)
{
    new 
Names[33]
    
get_user_name(idNames32)
    new 
s_Key[255], datas[255], s_APS[32], s_LevelS[32], s_DamageS[32], s_DamageMaxS[32]
    
formatex(s_Keycharsmax(s_Key) , "%s-Name"Names)
    
formatex(datas255"%i#%i#%i#%i"AMMO[id], Level[id], g_DamageEXP[id], MaxEXP[id])
    
nvault_get (g_Vaults_Keydatas255)
    
replace_all(datas 255"#"" ")
    
parse (datass_APS31s_LevelS31s_DamageS31s_DamageMaxS31)
       
    
AMMOS[id] = str_to_num (s_APS)
    
Level[id] = str_to_num (s_LevelS)
    
g_DamageEXP[id] = str_to_num (s_DamageS)
    
MaxEXP[id] = str_to_num (s_DamageMaxS)
    return 
PLUGIN_CONTINUE
}

public 
plugin_end()
{
    for(new 
id;id<=get_maxplayers();id++) saverz(id)
    
nvault_close(g_Vault)
}

public 
plugin_natives()
{
    
set_module_filter("module_filter")
    
set_native_filter("native_filter")
    
register_native("zl_ap_damage""native_zl_ap_damage"1)
    
register_native("zl_ap_level""native_zl_ap_level"1)
    
register_native("zl_ap_maxexp""native_zl_ap_maxexp"1)
}
public 
module_filter(const module[])
{
    if (
equal(moduleLIBRARY_NEMESIS) || equal(moduleLIBRARY_SURVIVOR))
        return 
PLUGIN_HANDLED;
    
    return 
PLUGIN_CONTINUE;
}
public 
native_filter(const name[], indextrap)
{
    if (!
trap)
        return 
PLUGIN_HANDLED;
        
    return 
PLUGIN_CONTINUE;
}

public 
zp_fw_core_infect_post(idattacker)
{
    
// Reward ammo packs to zombies infecting humans?
    
if (is_user_connected(attacker) && attacker != id && get_pcvar_num(cvar_ammop_human_infected) > 0)
        
zp_ammopacks_set(attackerzp_ammopacks_get(attacker) + get_pcvar_num(cvar_ammop_human_infected))
    
//Save_MySql(id)
}

/*
public client_connect(id)
{
    get_user_name(id, Names[id], 33)
}
*/

public client_putinserver(id)
{
    
set_task(1.0"Loads0")
    
set_task(2.0"Loads1"id+771)
    
set_task(3.0"Loads2"id+772)
}

public 
Loads0() for(new id;id<=get_maxplayers();id++) loadz(id)
public 
Loads1(id)
{
    
id-=771
    
if(Level[id] == 0MaxEXP[id] = 500
}

public 
Loads2(id)
{
    
id-=772
    save
[id] = true
    zp_ammopacks_set
(idAMMOS[id])
    
client_print(idprint_chat"AMMO: %d | Level: %d | Damage: %d | DamageMax: %d"AMMOS[id], Level[id], floatround(g_DamageEXP[id]), MaxEXP[id])
}

public 
fw_PlayerPreThink()
{
    for(new 
id;id<=get_maxplayers();id++)
    {
        if(
save[id])
        {
            
saverz(id)
            new 
ammo_packs zp_ammopacks_get(id)
            
AMMO[id] = ammo_packs
        
}
    }
}

/*
take_packs(id, amnt)
{
    //zp_ammopacks_set(id, APS)
    zp_ammopacks_set(id, zp_ammopacks_get(id) + APS[id])
    zp_ammopacks_set(id, zp_ammopacks_get(id) + amnt);
}
*/

// Ham Take Damage Post Forward
public fw_TakeDamage_Post(victiminflictorattackerFloat:damagedamage_type)
{
    
// Non-player damage or self damage
    
if (victim == attacker || !is_user_alive(attacker))
        return;
    
    
// Ignore ammo pack rewards for Nemesis?
    
if (LibraryExists(LIBRARY_NEMESISLibType_Library) && zp_class_nemesis_get(attacker) && get_pcvar_num(cvar_ammop_nemesis_ignore))
        return;
    
    
// Ignore ammo pack rewards for Survivor?
    
if (LibraryExists(LIBRARY_SURVIVORLibType_Library) && zp_class_survivor_get(attacker) && get_pcvar_num(cvar_ammop_survivor_ignore))
        return;
    
    
// Zombie attacking human...
    
if (zp_core_is_zombie(attacker) && !zp_core_is_zombie(victim))
    {
        
// Reward ammo packs to zombies for damaging humans?
        
if (get_pcvar_num(cvar_ammop_damage) > 0)
        {
            
// Store damage dealt
            
g_DamageDealtToHumans[attacker] += damage
            
            
// Give rewards according to damage dealt
            
new how_many_rewards floatround(g_DamageDealtToHumans[attacker] / get_pcvar_float(cvar_ammop_human_damaged_hp), floatround_floor)
            if (
how_many_rewards 0)
            {
                
zp_ammopacks_set(attackerzp_ammopacks_get(attacker) + (get_pcvar_num(cvar_ammop_damage) * how_many_rewards))
                
g_DamageDealtToHumans[attacker] -= get_pcvar_float(cvar_ammop_human_damaged_hp) * how_many_rewards
            
}
        }
    }
    
// Human attacking zombie...
    
else if (!zp_core_is_zombie(attacker) && zp_core_is_zombie(victim))
    {
        
// Reward ammo packs to humans for damaging zombies?
        
if (get_pcvar_num(cvar_ammop_damage) > 0)
        {
            
// Store damage dealt
            
g_DamageDealtToZombies[attacker] += damage
            
            
// Give rewards according to damage dealt
            
new how_many_rewards floatround(g_DamageDealtToZombies[attacker] / get_pcvar_float(cvar_ammop_zombie_damaged_hp), floatround_floor)
            if (
how_many_rewards 0)
            {
                
//Level[attacker]++
                
zp_ammopacks_set(attackerzp_ammopacks_get(attacker) + (get_pcvar_num(cvar_ammop_damage) * how_many_rewards))
                
g_DamageDealtToZombies[attacker] -= get_pcvar_float(cvar_ammop_zombie_damaged_hp) * how_many_rewards
            
}
            
g_DamageEXP[attacker]+=damage
            
new exp floatround(g_DamageEXP[attacker])
            new 
aname[33]
            
get_user_name(attackeranamesizeof aname 1)
            if(
exp >= MaxEXP[attacker])
            {
                
set_hudmessage(2502502500.1, -0.700.03.02.01.0, -1)
                
Level[attacker]++
                
MaxEXP[attacker] *= 2
                g_DamageEXP
[attacker] = 0.0
                levelsystem
(attacker)
                
show_hudmessage(0"%s РїРѕР»СѓС‡РёР» %d СѓСЂРѕРІРµРЅСЊ"anameLevel[attacker])
            }
            
        }
    }
}

public 
levelsystem(id)
{
    if(
<= Level[id] < 10)
    {
        
zl_parachute_false(id)
    }
    if(
10 <= Level[id] < 11)
    {
        
set_dhudmessage(2552550, -1.0, -0.700.05.01.01.0)
        
show_dhudmessage(id"Level 10^nПарашют РґРѕСЃС‚упен!"// 3
        
Linial(id)
        
emit_sound(idCHAN_VOICElvlupVOL_NORMATTN_NORM0PITCH_NORM)
        
zl_parachute_true(id)
    }
}

public 
levelsystem2(id)
{
    if(
<= Level[id] < 10)
    {
        
zl_parachute_false(id)
    }
    if(
10 <= Level[id] < 11)
    {
        
zl_parachute_true(id)
    }
}


public 
Linial(id)
{
    static 
origin[3]
    
get_user_origin(idorigin)
    
message_begin(MSG_BROADCASTSVC_TEMPENTITY)
    
write_byte(TE_BEAMCYLINDER)
    
write_coord(origin[0])
    
write_coord(origin[1])
    
write_coord(origin[2])    
    
write_coord(origin[0]+450
    
write_coord(origin[1]+450
    
write_coord(origin[2]+450)
    
write_short(lvlspr)
    
write_byte(0)
    
write_byte(255)
    
write_byte(10)
    
write_byte(60
    
write_byte(255
    
write_byte(255
    
write_byte(0
    
write_byte(0
    
write_byte(255)
    
write_byte(0)
    
message_end()
}

// Ham Player Killed Post Forward
public fw_PlayerKilled_Post(victimattackershouldgib)
{
    
// Non-player kill or self kill
    
if (victim == attacker || !is_user_connected(attacker))
        return;
    
    
// Ignore ammo pack rewards for Nemesis?
    
if (LibraryExists(LIBRARY_NEMESISLibType_Library) && zp_class_nemesis_get(attacker) && get_pcvar_num(cvar_ammop_nemesis_ignore))
        return;
    
    
// Ignore ammo pack rewards for Survivor?
    
if (LibraryExists(LIBRARY_SURVIVORLibType_Library) && zp_class_survivor_get(attacker) && get_pcvar_num(cvar_ammop_survivor_ignore))
        return;
    
    
// Reward ammo packs to attacker for the kill
    
if (zp_core_is_zombie(victim))
        
zp_ammopacks_set(attackerzp_ammopacks_get(attacker) + get_pcvar_num(cvar_ammop_zombie_killed))
    else
        
zp_ammopacks_set(attackerzp_ammopacks_get(attacker) + get_pcvar_num(cvar_ammop_human_killed))
}

public 
zp_fw_gamemodes_end()
{
    
// Determine round winner and money rewards
    
if (!zp_core_get_zombie_count())
    {
        
// Human team wins
        
new id
        
for (id 1id <= g_MaxPlayersid++)
        {
            if (!
is_user_connected(id))
                continue;
            
            if (
zp_core_is_zombie(id))
                
zp_ammopacks_set(idzp_ammopacks_get(id) + get_pcvar_num(cvar_ammop_loser))
            else
                
zp_ammopacks_set(idzp_ammopacks_get(id) + get_pcvar_num(cvar_ammop_winner))
        }
    }
    else if (!
zp_core_get_human_count())
    {
        
// Zombie team wins
        
new id
        
for (id 1id <= g_MaxPlayersid++)
        {
            if (!
is_user_connected(id))
                continue;
            
            if (
zp_core_is_zombie(id))
                
zp_ammopacks_set(idzp_ammopacks_get(id) + get_pcvar_num(cvar_ammop_winner))
            else
                
zp_ammopacks_set(idzp_ammopacks_get(id) + get_pcvar_num(cvar_ammop_loser))
        }
    }
    else
    {
        
// No one wins
        
new id
        
for (id 1id <= g_MaxPlayersid++)
        {
            if (!
is_user_connected(id))
                continue;
            
            
zp_ammopacks_set(idzp_ammopacks_get(id) + get_pcvar_num(cvar_ammop_loser))
        }
    }
    
//new id
    //for (id = 1; id <= g_MaxPlayers; id++)
        //Save_MySql(id)
}

public 
plugin_precache()
{
    
lvlspr precache_model("sprites/3dmflaora.spr")
    
precache_sound(lvlup)
}

public 
client_disconnect(id)
{
    
// Clear damage after disconnecting
    
g_DamageDealtToZombies[id] = 0.0
    g_DamageDealtToHumans
[id] = 0.0
    saverz
(id)
    
//Save_MySql(id)
}
    
public 
native_zl_ap_damage(id)
{
    return 
floatround(g_DamageEXP[id])
}

public 
native_zl_ap_level(id)
{
    return 
Level[id]
}

public 
native_zl_ap_maxexp(id)
{
    return 
MaxEXP[id]

Darkskypew is offline
drekes
Veteran Member
Join Date: Jul 2009
Location: Vault 11
Old 12-20-2011 , 11:59   Re: nVault Helps
Reply With Quote #5

replace this:
PHP Code:
public client_putinserver(id)
{
    
set_task(1.0"Loads0")
    
set_task(2.0"Loads1"id+771)
    
set_task(3.0"Loads2"id+772)
}

public 
Loads0() for(new id;id<=get_maxplayers();id++) loadz(id)
public 
Loads1(id)
{
    
id-=771
    
if(Level[id] == 0MaxEXP[id] = 500

    save
[id] = true
    zp_ammopacks_set
(idAMMOS[id])
    
client_print(idprint_chat"AMMO: %d | Level: %d | Damage: %d | DamageMax: %d"AMMOS[id], Level[id], floatround(g_DamageEXP[id]), MaxEXP[id])

with this:

PHP Code:
public client_putinserver(id)
{
    
loadz(id);

    if(
Level[id] == 0MaxEXP[id] = 500

    save
[id] = true
    zp_ammopacks_set
(idAMMOS[id])
    
client_print(idprint_chat"AMMO: %d | Level: %d | Damage: %d | DamageMax: %d"AMMOS[id], Level[id], floatround(g_DamageEXP[id]), MaxEXP[id])

And remove for(new id;id<=get_maxplayers();id++) saverz(id) in plugin_end()
__________________

Quote:
Originally Posted by nikhilgupta345 View Post
You're retarded.
drekes is offline
Send a message via MSN to drekes
Darkskypew
Member
Join Date: Sep 2010
Old 12-20-2011 , 12:25   Re: nVault Helps
Reply With Quote #6

Big thanx!
Darkskypew is offline
Darkskypew
Member
Join Date: Sep 2010
Old 12-24-2011 , 05:31   Re: nVault Helps
Reply With Quote #7

Conservation no work. Is the first player gives 6 level, and who had 10 picks up at 5 for example, that is not accurate indicators of = (
Darkskypew is offline
drekes
Veteran Member
Join Date: Jul 2009
Location: Vault 11
Old 12-24-2011 , 06:34   Re: nVault Helps
Reply With Quote #8

I don't understand what you mean.
__________________

Quote:
Originally Posted by nikhilgupta345 View Post
You're retarded.
drekes is offline
Send a message via MSN to drekes
Darkskypew
Member
Join Date: Sep 2010
Old 12-24-2011 , 08:05   Re: nVault Helps
Reply With Quote #9

Sorry.
The plugin does not work correctly. Levels are preserved, but crooked.
Levels sometimes dropped from level 10 to 3 (example)
Darkskypew is offline
drekes
Veteran Member
Join Date: Jul 2009
Location: Vault 11
Old 12-24-2011 , 08:55   Re: nVault Helps
Reply With Quote #10

When does that happen ?
__________________

Quote:
Originally Posted by nikhilgupta345 View Post
You're retarded.
drekes is offline
Send a message via MSN to drekes
Reply



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

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

Forum Jump


All times are GMT -4. The time now is 08:33.


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