Raised This Month: $ Target: $400
 0% 

Solved Save/Get multiple different values in the same variable per player


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
sursista
Senior Member
Join Date: Jul 2010
Location: Spain
Old 02-17-2022 , 14:58   Re: Save/Get multiple different values in the same variable per player
Reply With Quote #1

Quote:
Originally Posted by OciXCrom View Post
I don't see a problem there.

Other than that, show the full code so we can see how you're using it.
This is a small example of what I'm trying to do, again it works, but only 70% of the time, the other 30% I either don't get assists or the name of the assist belongs to a different player (which did not get assistance)

PHP Code:
public fw_TakeDamage(victiminflictorattackerFloat:damagedamage_type)
{
    if (
victim == attacker || !is_user_alive(attacker) || !is_user_alive(victim))
        return
        
    if(!
g_hp_victim[victim])
        
g_hp_victim[victim] = get_user_health(victim) / 3
    
    
if(zp_core_is_zombie(attacker
    && !
zp_class_survivor_get(victim))
    {    
        
g_fDamage_Human[victim][attacker] += damage;
        if(
g_fDamage_Human[victim][attacker] >= g_hp_victim[victim] && !g_victim_done[victim][attacker])
        {
            
g_count_victim_human[attacker]++;
            
g_victim_done[victim][attacker] = true;
            
            new 
name[32]
            
get_user_name(victimnamecharsmax(name))
            
            
client_print(idprint_chat"You got a assist of %s"name)
        }
    }
    
    if(!
zp_core_is_zombie(attacker)
    && !
zp_core_is_first_zombie(victim)
    && !
zp_class_nemesis_get(victim))
    {
        
g_fDamage_Zombie[victim][attacker] += damage;
        if(
g_fDamage_Zombie[victim][attacker] >= g_hp_victim[victim] && !g_victim_done[victim][attacker])
        {
            
g_count_victim_zombie[attacker]++;
            
g_victim_done[victim][attacker] = true;
            
            new 
name[32]
            
get_user_name(victimnamecharsmax(name))
            
            
client_print(idprint_chat"You got a assist of %s"name)
        }
    }
}

public 
fw_Killed(victimattackershouldgib)
{
    if (
victim == attacker || !is_user_connected(attacker))
        return
        
    if(
zp_core_is_zombie(attacker
    && 
g_count_victim_human[attacker]
    && !
zp_class_survivor_get(victim))
    {    
        if(
g_count_victim_human[attacker])
            
g_count_victim_human[attacker]--;
        
        
g_fDamage_Human[victim][attacker] = 0.0;
        
g_he_attacker[attacker] = true;
    }
    
    if(!
zp_core_is_zombie(attacker)
    && 
g_count_victim_zombie[attacker]
    && !
zp_core_is_first_zombie(victim)
    && !
zp_class_nemesis_get(victim))
    {    
        if(
g_count_victim_zombie[attacker])
            
g_count_victim_zombie[attacker]--;
        
        
g_fDamage_Zombie[victim][attacker] = 0.0;
        
g_he_attacker[attacker] = true;
    }
    
    for(new 
id 1id <= 32id++)
    {
        if(
is_user_alive(id)
        && 
zp_core_is_zombie(id)
        && !
g_he_attacker[id]
        && 
g_count_victim_human[id]
        && 
g_victim_done[victim][id]
        && !
zp_class_survivor_get(victim))
        {    
            new 
name[32]
            
get_user_name(victimnamecharsmax(name))
                    
            
client_print(idprint_chat"You got a assist of %s"name)
                
            if(
g_count_victim_human[id])
                
g_count_victim_human[id]--;
                
            
g_victim_done[victim][id] = false;
            
g_fDamage_Human[victim][id] = 0.0;
        }
            
        if(
is_user_alive(id)
        && !
zp_core_is_zombie(id)
        && !
g_he_attacker[id]
        && 
g_count_victim_zombie[id]
        && 
g_victim_done[victim][id]
        && !
zp_core_is_first_zombie(victim)
        && !
zp_class_nemesis_get(victim))
        {
            new 
name[32]
            
get_user_name(victimnamecharsmax(name))
                    
            
client_print(idprint_chat"You got a assist of %s"name)
                
            if(
g_count_victim_zombie[id])
                
g_count_victim_zombie[id]--;
                
            
g_victim_done[victim][id] = false;
            
g_fDamage_Zombie[victim][id] = 0.0;
        }
    }
    
    if(
zp_core_is_zombie(victim))
    {
        
g_count_victim_human[victim] = 0;
        
g_fDamage_Human[victim][attacker] = 0.0;
    }
    
    if(!
zp_core_is_zombie(victim))
    {
        
g_count_victim_zombie[victim] = 0;
        
g_fDamage_Zombie[victim][attacker] = 0.0;
    }
    
    
g_victim_done[victim][attacker] = false;
    
g_hp_victim[victim] = 0;
    
g_he_attacker[attacker] = false;


Last edited by sursista; 02-17-2022 at 15:01. Reason: edited code
sursista is offline
Send a message via MSN to sursista Send a message via Skype™ to sursista
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 11:43.


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