AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Teammates not updating (https://forums.alliedmods.net/showthread.php?t=308152)

sekac 06-08-2018 14:27

Teammates not updating
 
I have this code for showing teammates money but when someone switches teams it doesn't update...

PHP Code:

#include <amxmodx>
#include <cstrike>
#include <hamsandwich>

#define NAME "show teammate's money"
#define VERSION "1.3.1"
#define AUTHOR "K.K.Lv"

new g_max_playersg_sync_creat_listsyncObjectg_pFreezeTimefreezetime

new bool:g_teammate[33]

public 
plugin_init()
{
    
register_plugin(NAMEVERSIONAUTHOR)
    
    
register_event("HLTV""FreezeTimeStart""a""1=0""2=0")
    
    
register_event("StatusValue""set_team""be""1=1")
    
    
register_event("StatusValue""EventStatusValue""be""1=2""2!0")
    
    
RegisterHam(Ham_Spawn"player""player_spawn"1)
    
    
g_max_players get_maxplayers()
    
g_pFreezeTime get_cvar_pointer("mp_freezetime")
    
    
syncObject CreateHudSyncObj()
}

public 
plugin_precache() g_sync_creat_list CreateHudSyncObj()

public 
player_spawn(client) if(freezetimeset_task(1.0"show_money"client, .flags="a", .repeat=get_pcvar_num(g_pFreezeTime))

public 
show_money(client)
{
    if(!
is_user_alive(client) || !is_user_connected(client)) return
    
    static 
message[1024]
    static 
name[32]
    
    new 
moneyidlen
    
    
for (id 1id <= g_max_playersid++)
    {
        if (
id != client && is_user_connected(id) && cs_get_user_team(id) == cs_get_user_team(client))
        {
            
money cs_get_user_money(id)
            
get_user_name(idname31)
            
len += format(message[len], charsmax(message) - len"%-22.22s$%d^n"namemoney)
        }
    }
    
set_hudmessage(10020000.050.3500.021.00.10.22)
    
ShowSyncHudMsg(clientg_sync_creat_listmessage)
}

public 
FreezeTimeStart() {
    
freezetime true
    
if(task_exists(9778)) remove_task(9778)
    
set_task(get_pcvar_float(g_pFreezeTime), "freezetime_ended"9778)
}

public 
freezetime_ended() {
    
freezetime false
    remove_task
(9778)
}

public 
set_team(idg_teammate[id] = bool:(read_data(2) == 1)

public 
EventStatusValue(id)
{
    if(
is_user_connected(id) && !is_user_bot(id)) 
    {
        new 
targetName[32], targetid read_data(2)
        
get_user_name(targetidtargetName31)   
        new 
playerTeam get_user_team(id), targetTeam get_user_team(targetid), money cs_get_user_money(targetid)
        
        if (
playerTeam == targetTeam
        {
            
set_hudmessage(255255255, -1.00.4210.010.90.010.01, -1)
            
ShowSyncHudMsg(idsyncObject"%s : $%d"targetNamemoney)
        }
    }
    return 
PLUGIN_CONTINUE



Napoleon_be 06-09-2018 10:51

Re: Teammates not updating
 
try using the technique Arkshine uses right here: https://forums.alliedmods.net/showthread.php?t=56370

Call your show_money function where ever u need it.

maqi 06-10-2018 14:10

Re: Teammates not updating
 
You already registered a new round with HLTV, why are you using player spawn event dependant on freezetime, those 2 are not really connected ( technically ) :D

You should just Loop through all players in FreezeTimeStart and show them the hud. No need to make a repeating task even. Then you can easily use what napoleon wrote to update if someone joins a team.

sekac 06-11-2018 07:08

Re: Teammates not updating
 
I will change all of that when I have time. Thank you all.


All times are GMT -4. The time now is 04:34.

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