AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [HELP]Save Group Damage (https://forums.alliedmods.net/showthread.php?t=273295)

Depresie 10-17-2015 08:34

[HELP]Save Group Damage
 
So bassicaly i want to add the damage of all the players within togheter into a group damage bool , then display it on a hud
I tried several things, so far i only managed to count their damage togheter in a bool, but when a player joined, for him the group damage was 0...



PHP Code:


enum _
:pdata 
{
    
In_Party,
    
Position,
    
Amount_In_Party,
    
Block_Party,
    
UserName[32],
    
Damage_In_Party
}

new 
g_PartyData[33][pdata], Array:Party_Ids[33]


public 
fw_TakeDamage(victiminflictorattackerFloat:damagedamage_type)
{
    if (
victim == attacker || !is_user_connected(attacker))
        return 
HAM_IGNORED;
    
    if (
g_PartyData[attacker][In_Party])
    {
        new 
Players[32], user
        get_party_index
(attackerPlayers)
        for(new 
ig_PartyData[attacker][Amount_In_Party]; i++)
        {
            
user Players[i]
            if(
is_user_alive(attacker) && !zp_get_user_zombie(attacker))
            {
                
g_PartyData[attacker][Damage_In_Party] += floatround(damage)
                
client_print(userprint_chat"Members: %d"g_PartyData[user][Amount_In_Party])
                
                if(
g_PartyData[Damage_In_Party] >= get_pcvar_num(cvar_damage_reward))
                {
                    
zp_set_user_ammo_packs(userzp_get_user_ammo_packs(user) + get_pcvar_num(cvar_ammo_reward))
                    
g_PartyData[Damage_In_Party] -= g_PartyData[Damage_In_Party]
                    
                }
            }
        }
        
        
g_PlayerDamage[attacker] += floatround(damage)
        
        if(
g_PlayerDamage[attacker] >= 1000)
        {
            
g_PlayerScore[attacker] += 1
            g_PlayerDamage
[attacker] -= 1000
        
}
    }
    return 
HAM_HANDLED;
}

public 
PartyHud(taskid) {
    
    static 
id
    id 
ID_HUD
    
    
if(!is_user_connected(id)) {
        
remove_task(taskid)
        return
    }
    
    static 
CountPartyPartyMsg[256], Players[32], id2
    
static PartyDamage[16]
    
    
CountParty 0
    PartyMsg
[0] = 0
    
    get_party_index
(idPlayers)
    for(new 
ig_PartyData[id][Amount_In_Party]; i++) {
        
        
id2 Players[i]
        
        if(
CountParty)
            
add(PartyMsgcharsmax(PartyMsg), "^n")
        
        
format(PartyMsgcharsmax(PartyMsg), "%s[%d]^t^t^t^t%s"strlen(PartyMsg) ? PartyMsg "[DMG]  -  [Party Members]^n"g_PlayerDamage[id2], g_PartyData[id2][UserName])
        
CountParty++
        
    }
    
    
AddCommas(g_PartyData[Damage_In_Party], PartyDamage15);
    
    
set_hudmessage(255255255get_pcvar_float(cvar_hudx), get_pcvar_float(cvar_hudy), 06.01.0);
    
show_hudmessage(id"%s^n__________________^n|Damage : [%s / %d]|"PartyMsgPartyDamageget_pcvar_num(cvar_damage_reward))



Bugsy 10-17-2015 18:18

Re: [HELP]Save Group Damage
 
Quote:

Originally Posted by Depresie (Post 2353908)
So bassicaly i want to add the damage of all the players within togheter into a group damage bool , then display it on a hud
I tried several things, so far i only managed to count their damage togheter in a bool, but when a player joined, for him the group damage was 0...

Do you understand what a bool\boolean is? It's a data-type that stores a false (0) or true (non-zero) value only. When you say bool, do you mean array?

Chihuahuax 10-17-2015 23:44

Re: [HELP]Save Group Damage
 
PHP Code:

new FloatDamage_In_Party 

PHP Code:

Damage_In_Party += floatround(damage

?

Bugsy 10-17-2015 23:53

Re: [HELP]Save Group Damage
 
Just so you know, the damage value in Ham_TakeDamage is the total inflicted damage prior to factoring in the victims armor. If you want to get the actual loss in hp of the victim, you will need to retrieve pev_dmg_take in Ham_TakeDamage post.

Depresie 10-18-2015 03:09

Re: [HELP]Save Group Damage
 
as i said, i have tried with a bool before and i saved values in the bool via user in the loop, but when a player joined the group the group damage for him was 0 instead of the damage done by the group before he joined.

Last time i tried with arrays, i didnt know what the heck im doing, and the result code is above...
btw, total inflicted damage is what im looking for

If anyone can show me the way, that would be great, im trying to figure it out for 3 days...

@chihuahuax

That is a variable, if i will use that to store the values, it will store inside the damage done by all the players on the server, i need to store only for a specific group, also there could be more groups created

wickedd 10-18-2015 06:54

Re: [HELP]Save Group Damage
 
Quote:

Originally Posted by Depresie (Post 2354258)
as i said, i have tried with a bool before and i saved values in the bool via user in the loop, but when a player joined the group the group damage for him was 0 instead of the damage done by the group before he joined.

That's not true, because a bool is either true or false. You can't store anything in them.

Bugsy 10-18-2015 07:01

Re: [HELP]Save Group Damage
 
Quote:

Originally Posted by Depresie (Post 2354258)
as i said, i have tried with a bool before and i saved values in the bool via user in the loop, but when a player joined the group the group damage for him was 0 instead of the damage done by the group before he joined.

Last time i tried with arrays, i didnt know what the heck im doing, and the result code is above...
btw, total inflicted damage is what im looking for

You sound like you have no idea what you're talking about. Again, a bool means true or false, those are the only 2 possible values. What you are actually using, whether you want to accept it or not, is an array of integers (numbers).

You are defining an array type of Array: Party_Ids[33] but are not using any of the cellarray natives. If you are not using the cellarray natives, just define an array simply as Party_Ids[33] with no 'Array:' tag.

You need to provide more code if you want help--providing a piece of code that can be compiled is always preferred so the code can be troubleshooted. You left out the get_party_index() function which could be the part of your code that is broken. How many parties are there? Not enough info to know what is going on.

I see you have:
PHP Code:

g_PartyData[Damage_In_Party

then you have
PHP Code:

g_PartyData[attacker][Damage_In_Party

This is 2 dimensional array, you can't just give it 1 index and expect it to know what you are trying to do. The code is only as smart as you tell it to be, it cannot read you mind.

You need to re-think your data handling and be consistent with it. What I would do is use a bit-field for each group, and assign players to it. Then use a separate variable to keep track of how much damage is associated with that group.

Depresie 10-18-2015 07:44

Re: [HELP]Save Group Damage
 
Sorry, this is what i was calling a bool
Code:

new g_PartyDamage[33]
I use this stuff either to store values for a certain player, or i use it with true or false in case i want do disable/enable stuff for the player

About the Plugin:

The groups can be created by any player and can contain minimum 2 players to a maximum of 3/4 defined by cvar
Players can invite each other via a menu which is opened by writing /party command in chat

What im trying to do:

Add all the damage done by the players within the group togheter, at a certain value of damage cumulated, i want to reward all the members of the group 1 ammo pack

sorry, I know it is a little messy, i was testing many things inside it...

Full Code:

PHP Code:

#include <amxmodx>
#include <hamsandwich>
#include <zombieplague>

#define PLUGIN "New Plugin"
#define VERSION "1.0"
#define AUTHOR "Plugin"

#define TAG    "[Party]"
#define ID_HUD    (taskid - TASK_HUD)

enum (+= 77) {
    
TASK_HUD 777,
    
TASK_ACEPT
}

enum {
    
NONE = -1,
    
Master,
    
Start_Amount
}

enum _:pdata {
    
In_Party,
    
Position,
    
Amount_In_Party,
    
Block_Party,
    
UserName[32],
    
Damage_In_Party
}

enum _:DataCallBack {
    
MASTER,
    
USER
}

new 
g_PartyData[33][pdata], Array:Party_Ids[33], g_maxplayersg_MenuCallback[DataCallBack]
new 
g_PartyDamage[33], g_PlayerDamage[33], g_PlayerScore[33]

new 
cvar_time_aceptcvar_max_playerscvar_allow_botscvar_damage_rewardcvar_ammo_reward

new cvar_hudxcvar_hudy

public plugin_init() {
    
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
register_clcmd("say /party""cmdParty")
    
    
RegisterHam(Ham_TakeDamage"player""fw_TakeDamage")
    
    
cvar_time_acept register_cvar("party_time_acept","15")
    
cvar_max_players register_cvar("party_max_players","4")
    
cvar_allow_bots register_cvar("party_allow_bots","1")
    
cvar_damage_reward register_cvar("party_damage_reward""6000")
    
cvar_ammo_reward register_cvar("party_ammo_reward""1")
    
    
cvar_hudx register_cvar("myhudx""0.017")
    
cvar_hudy register_cvar("myhudy""0.18")
    
    
    
g_maxplayers get_maxplayers()
    
    
g_MenuCallback[MASTER] = menu_makecallback("check_master")
    
g_MenuCallback[USER] = menu_makecallback("check_user")
}

public 
plugin_cfg()
    for(new 
1<= g_maxplayersi++)
    
Party_Ids[i] = ArrayCreate(11)

public 
client_disconnect(id) {
    
    if(
g_PartyData[id][In_Party])
        
g_PartyData[id][Position] ? g_PartyData[id][Amount_In_Party] == destoy_party(id) : remove_party_user(id) : destoy_party(id)
    
    
g_PartyData[id][UserName][0] = 0
    g_PartyData
[id][Block_Party] = false
    
}



public 
cmdParty(id) {
    
    if(
g_PartyData[id][In_Party])
        
show_party_info_menu(id)
    else
        
show_party_menu(id)
    
    return 
PLUGIN_HANDLED
}

public 
fw_TakeDamage(victiminflictorattackerFloat:damagedamage_type)
{
    if (
victim == attacker || !is_user_connected(attacker))
        return 
HAM_IGNORED;
    
    if (
g_PartyData[attacker][In_Party])
    {
        new 
Players[32], user
        get_party_index
(attackerPlayers)
        for(new 
ig_PartyData[attacker][Amount_In_Party]; i++)
        {
            
user Players[i]
            if(
is_user_alive(attacker) && !zp_get_user_zombie(attacker))
            {
                
g_PartyData[attacker][Damage_In_Party] += floatround(damage)
                
client_print(userprint_chat"Members: %d"g_PartyData[user][Amount_In_Party])
                
                if(
g_PartyData[Damage_In_Party] >= get_pcvar_num(cvar_damage_reward))
                {
                    
zp_set_user_ammo_packs(userzp_get_user_ammo_packs(user) + get_pcvar_num(cvar_ammo_reward))
                    
g_PartyData[Damage_In_Party] -= g_PartyData[Damage_In_Party]
                    
                }
            }
        }
        
        
g_PlayerDamage[attacker] += floatround(damage)
        
        if(
g_PlayerDamage[attacker] >= 1000)
        {
            
g_PlayerScore[attacker] += 1
            g_PlayerDamage
[attacker] -= 1000
        
}
    }
    return 
HAM_HANDLED;
}



public 
show_party_menu(id) {
    
    new 
iMenu menu_create("Party Menu","party_menu"), BlockParty[50]
    
    
menu_additem(iMenu"\yCreate a Party""0")
    
    
formatex(BlockPartycharsmax(BlockParty), "\yBlock Party Invitations: \w%s",g_PartyData[id][Block_Party] ? "Yes" "No")
    
    
menu_additem(iMenuBlockParty"1")
    
    
menu_setprop(iMenuMPROP_EXITNAME"Exit")
    
menu_setprop(iMenuMPROP_EXITMEXIT_ALL)
    
    
menu_display(idiMenu0)
}

public 
show_party_info_menu(id) {
    
    new 
iMenu menu_create("Party Menu","party_info_menu")
    
    
menu_additem(iMenu"Add Members", .callback g_MenuCallback[MASTER])
    
menu_additem(iMenu"Kick Members", .callback g_MenuCallback[MASTER])
    
menu_additem(iMenu"Destroy Party", .callback g_MenuCallback[MASTER])
    
menu_additem(iMenu"Leave Party", .callback g_MenuCallback[USER])
    
    
menu_setprop(iMenuMPROP_EXITNAME"Exit")
    
menu_setprop(iMenuMPROP_EXITMEXIT_ALL)
    
    
menu_display(idiMenu)
}

public 
show_party_add_menu(id) {
    
    new 
iMenu menu_create(g_PartyData[id][In_Party] ? "\rAdd Members:" "\rCreate Party:""party_create_menu"), Poss[3], Name[32]
    
    for(new 
1<= g_maxplayersi++) {
        
        if(!
is_available_to_party(i) || id == i)
            continue;
        
        
get_user_name(iNamecharsmax(Name))
        
num_to_str(iPosscharsmax(Poss))
        
menu_additem(iMenuNamePoss)
    }
    
    
menu_setprop(iMenuMPROP_EXITNAME"Exit")
    
menu_setprop(iMenuMPROP_EXITMEXIT_ALL)
    
    
menu_display(idiMenu)
}

public 
show_party_kick_menu(id) {
    
    new 
iMenu menu_create("\rParty Kick Menu","party_kick_menu"), Players[32], Poss[3], user
    
    get_party_index
(idPlayers)
    
    for(new 
ig_PartyData[id][Amount_In_Party]; i++) {
        
user Players[i]
        
num_to_str(userPosscharsmax(Poss))
        
menu_additem(iMenug_PartyData[user][UserName], Poss)
    }
    
    
menu_setprop(iMenuMPROP_EXITNAME"Exit")
    
    
menu_display(idiMenu)
}

public 
show_party_invite_menu(id2MasterId) {
    
    new 
MenuTitle[128], iMenuStr_MasterId[3]
    
    
set_player_party_name(MasterId)
    
set_player_party_name(id2)
    
    
client_print(MasterIdprint_chat"%s Invitation Sent a %s"TAGg_PartyData[id2][UserName])
    
    
formatex(MenuTitlecharsmax(MenuTitle), "%s Sent Party Invitation to %s"g_PartyData[MasterId][UserName], g_PartyData[MasterId][In_Party] ? "Add" "Create")
    
    new 
UserTaskArgs[3]
    
    
UserTaskArgs[0] = iMenu menu_createMenuTitle "party_invite_menu")
    
UserTaskArgs[1] = MasterId
    
    num_to_str
(MasterIdStr_MasterIdcharsmax(Str_MasterId))
    
    
menu_additemiMenu "Accept"Str_MasterId)
    
menu_additemiMenu "Decline"Str_MasterId)
    
    if(
is_user_bot(id2) && get_pcvar_num(cvar_allow_bots)) {
        
party_invite_menu(id2iMenu0)
        return
    }
    
    
menu_setprop(iMenuMPROP_EXITMEXIT_NEVER)
    
    
menu_display(id2iMenu)
    
    
remove_task_acept(id2)
    
    
set_task(get_pcvar_float(cvar_time_acept), "Time_Acept"id2+TASK_ACEPTUserTaskArgs2)
}


public 
party_menu(idmenuitem) {
    
    if(
item == MENU_EXIT) {
        
menu_destroy(menu)
        return
    }
    
    if(
item) {
        
g_PartyData[id][Block_Party] = g_PartyData[id][Block_Party] ? false true
        show_party_menu
(id)
    }
    else
        
show_party_add_menu(id)
    
    
menu_destroy(menu)
    
}

public 
party_create_menu(idmenuitem) {
    
    if(
item == MENU_EXIT) {
        
menu_destroy(menu)
        return
    }
    
    new 
iKey[6], iAccessiCallbackid2
    
    menu_item_getinfo
(menuitemiAccessiKeycharsmax(iKey), __iCallback)
    
    
id2 str_to_num(iKey)
    
    if(!
is_available_to_party(id2))
        return
    
    
show_party_invite_menu(id2id)
    
    
menu_destroy(menu)
}

public 
party_invite_menu(idmenuitem) {
    
    if(
item == MENU_EXIT) {
        
menu_destroy(menu)
        
remove_task_acept(id)
        return
    }
    
    new 
iKey[6], iAccessiCallbackid_master
    
    menu_item_getinfo
(menuitemiAccessiKeycharsmax(iKey), __iCallback)
    
    
id_master str_to_num(iKey)
    
    switch(
item) {
        case 
0: {
            
            if(!
g_PartyData[id_master][In_Party]) {
                
create_party(id_masterid)
                
set_task_party_hud(id_master)
                
set_task_party_hud(id)
            }
            else {
                if(
g_PartyData[id_master][Amount_In_Party] == get_pcvar_num(cvar_max_players)) {
                    
                    
client_print(idprint_chat"%s The maximum number of Party Members was reached"TAG)
                    
client_print(id_masterprint_chat"%s Now the maximum number of Party Members was reached"TAG)
                    
                    
remove_task_acept(id)
                    
                    
menu_destroy(menu)
                    return
                }
                
                
add_party_user(id_masterid)
                
set_task_party_hud(id)
            }
            
            
client_print(id_masterprint_chat"%s %s Was added to the Party"TAGg_PartyData[id][UserName])
        }
        case 
1client_print(id_masterprint_chat"%s %s Declined the Party Invitation"TAGg_PartyData[id][UserName])
        }
    
    
remove_task_acept(id)
    
    
menu_destroy(menu)
}

public 
party_kick_menu(idmenuitem) {
    
    if(
item == MENU_EXIT) {
        
menu_destroy(menu)
        return
    }
    
    new 
iKey[6], iAccessiCallbackid2
    
    menu_item_getinfo
(menuitemiAccessiKeycharsmax(iKey), __iCallback)
    
    
id2 str_to_num(iKey)
    
    if(
is_user_connected(id2))
        
g_PartyData[id][Amount_In_Party] == destoy_party(id) : remove_party_user(id2)
    
    
menu_destroy(menu)
}

public 
party_info_menu(idmenu,item) {
    
    if(
item == MENU_EXIT) {
        
menu_destroy(menu)
        return
    }
    
    switch(
item) {
        case 
0: {
            if(
g_PartyData[id][Amount_In_Party] < get_pcvar_num(cvar_max_players))
                
show_party_add_menu(id)
            else
                
client_print(idprint_chat"%s Now you reached the maximum number of Party Members"TAG)
        }
        case 
1show_party_kick_menu(id)
            case 
2destoy_party(id)
            case 
3remove_party_user(id)
        }
    
    
menu_destroy(menu)
}

public 
PartyHud(taskid) {
    
    static 
id
    id 
ID_HUD
    
    
if(!is_user_connected(id)) {
        
remove_task(taskid)
        return
    }
    
    static 
CountPartyPartyMsg[256], Players[32], id2
    
static PartyDamage[16]
    
    
CountParty 0
    PartyMsg
[0] = 0
    
    get_party_index
(idPlayers)
    for(new 
ig_PartyData[id][Amount_In_Party]; i++) {
        
        
id2 Players[i]
        
        if(
CountParty)
            
add(PartyMsgcharsmax(PartyMsg), "^n")
        
        
format(PartyMsgcharsmax(PartyMsg), "%s[%d]^t^t^t^t%s"strlen(PartyMsg) ? PartyMsg "[DMG]  -  [Party Members]^n"g_PlayerDamage[id2], g_PartyData[id2][UserName])
        
CountParty++
        
    }
    
    
AddCommas(g_PartyData[Damage_In_Party], PartyDamage15);
    
    
set_hudmessage(255255255get_pcvar_float(cvar_hudx), get_pcvar_float(cvar_hudy), 06.01.0);
    
show_hudmessage(id"%s^n__________________^n|Damage : [%s / %d]|"PartyMsgPartyDamageget_pcvar_num(cvar_damage_reward))
}

public 
Time_Acept(UserTaskArgs[], taskid) {
    
    
taskid -= TASK_ACEPT;
    
    if(!
g_PartyData[taskid][In_Party]) {
        
        
client_print(UserTaskArgs[1], print_chat"%s %s Cancel the Party Invitation"TAGg_PartyData[taskid][UserName])
        
menu_destroy(UserTaskArgs[0])
        
show_menu(taskid0"^n"1)
    }
}

stock create_party(masterguest) {
    
    
set_party_member(mastermaster)
    
set_party_member(masterguest)
    
set_party_member(guestmaster)
    
set_party_member(guestguest)
    
    
set_party_vars(masterStart_Amount)
    
set_party_vars(guest, ++g_PartyData[master][Amount_In_Party])
}

stock add_party_user(masterguest) {
    
    new 
Players[32], memberamount g_PartyData[master][Amount_In_Party]
    
    
get_party_index(masterPlayers)
    
    for(new 
iamounti++) {
        
        
member Players[i]
        
        
set_party_member(guestmember)
        
set_party_member(memberguest)
        
g_PartyData[member][Amount_In_Party]++
        
    }
    
    
set_party_member(guestguest)
    
set_party_vars(guestamount+1)    
}

stock set_party_member(idid2)
    
ArrayPushCell(Party_Ids[id], id2)

stock set_party_vars(idamount) {
    
    
g_PartyData[id][In_Party] = true
    g_PartyData
[id][Position] = amount-1
    g_PartyData
[id][Amount_In_Party] = amount
    
}

stock destoy_party(id) {
    
    new 
Players[32], id2Amount g_PartyData[id][Amount_In_Party]
    
get_party_index(idPlayers)
    
    for(new 
iAmounti++) {
        
id2 Players[i]
        
clear_party_user(id2)
        
client_print(id2print_chat"%s The Party was Destroyed"TAG)
        
    }
}

stock remove_party_user(user) {
    
    new 
Players[32], idAmount g_PartyData[user][Amount_In_Party]
    
    
get_party_index(userPlayers)
    
    
clear_party_user(user)
    
    for(new 
iAmounti++) {
        
        
id Players[i]
        
        if(
id != user) {
            
            
ArrayClear(Party_Ids[id])
            
            for(new 
zAmountz++)                    
                if(
Players[z] != user)
                
set_party_member(idPlayers[z])
            
            
g_PartyData[id][Position] = i
            g_PartyData
[id][Amount_In_Party] = Amount-1
            client_print
(idprint_chat"%s %s Leave Party"TAGg_PartyData[user][UserName])
        }
    }
}

stock clear_party_user(id) {
    
    
ArrayClear(Party_Ids[id])
    
g_PartyData[id][In_Party] = false
    g_PartyData
[id][Position] = NONE
    g_PartyData
[id][Amount_In_Party] = NONE
    g_PlayerDamage
[id] = 0
    g_PlayerScore
[id] = 0
    remove_task_party_hud
(id)
    
}

stock set_task_party_hud(id)
    
set_task(1.0"PartyHud"id+TASK_HUD__"b")

stock remove_task_party_hud(id)
    
remove_task(id+TASK_HUD)

stock remove_task_acept(id)
    if(
task_exists(id+TASK_ACEPT))
    
remove_task(id+TASK_ACEPT)


stock set_player_party_name(id) {
    
    if(
g_PartyData[id][UserName][0])
        return 
0
    
    get_user_name
(idg_PartyData[id][UserName], charsmax(g_PartyData[][UserName]))
    
    return 
1
}

stock is_available_to_party(id) {
    
    if(!
is_user_connected(id) || g_PartyData[id][In_Party] || g_PartyData[id][Block_Party])
        return 
false
    
    
return true
}        

stock get_party_index(idplayers[]) {
    
    for(new 
ig_PartyData[id][Amount_In_Party]; i++)
        
players[i] = ArrayGetCell(Party_Ids[id], i)
    
    return 
players[0] ? 0
}

public 
check_master(id)
    return 
g_PartyData[id][Position] ? ITEM_DISABLED ITEM_ENABLED

public check_user(id)
    return 
g_PartyData[id][Position] ? ITEM_ENABLED ITEM_DISABLED

    
public AddCommasiNum szOutput[] , iLen 

    new 
szTmp15 ] , iOutputPos iNumPos iNumLen
     
    if ( 
iNum 
    { 
        
szOutputiOutputPos++ ] = '-'
        
iNum absiNum ); 
    } 
     
    
iNumLen num_to_striNum szTmp charsmaxszTmp ) ); 

    if ( 
iNumLen <= 
    { 
        
iOutputPos += copyszOutputiOutputPos ] , iLen szTmp ); 
    } 
    else 
    { 
        while ( ( 
iNumPos iNumLen ) && ( iOutputPos iLen ) )  
        { 
            
szOutputiOutputPos++ ] = szTmpiNumPos++ ]; 
         
            if( ( 
iNumLen iNumPos ) && !( ( iNumLen iNumPos ) % ) )  
                
szOutputiOutputPos++ ] = ','
        } 
         
        
szOutputiOutputPos ] = EOS
    } 
     
    return 
iOutputPos



Bugsy 10-18-2015 08:01

Re: [HELP]Save Group Damage
 
Everything works perfectly except for when a new member is added to the group? Could you just set g_PartyData[id][Damage_In_Party] to the party damage?

Depresie 10-18-2015 08:15

Re: [HELP]Save Group Damage
 
The way i got it partialy working was using an Array like this , with the multi dimensional array i couldn't get anything done...

PHP Code:

new g_PartyDamage[33

Then i made a loop inside take damage and i store all the damage into g_PartyDamage[33] like this

PHP Code:

new Players[32], user
        get_party_index
(attackerPlayers)
        for(new 
ig_PartyData[attacker][Amount_In_Party]; i++)
        {
            
user Players[i]
            if(
is_user_alive(attacker) && !zp_get_user_zombie(attacker))
            {
                
g_PartyDamage[user] += floatround(damage)
           
                if(
g_PartyDamage[user] >= get_pcvar_num(cvar_damage_reward))
                {
                    
zp_set_user_ammo_packs(userzp_get_user_ammo_packs(user) + get_pcvar_num(cvar_ammo_reward))
                    
g_PartyDamage[user] -= g_PartyDamage[user]
                    
                }
            }
        } 

Everything worked fine, the damage of the players within the group was stored togheter inside g_PartyDamage[33]

But when a new player joined, for him the PartyDamage displayed on the hud was 0 ...

I tried multi dimensional arrays, normal arrays, anything i could of seen and think off for 3-4 days... then i felt like i wanted to kill myself and came here...


All times are GMT -4. The time now is 22:03.

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