Raised This Month: $32 Target: $400
 8% 

[Sloved] Put commas between Health


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
bakir123
Senior Member
Join Date: Jan 2015
Location: Palestine, Hebron
Old 09-04-2015 , 12:35   [Sloved] Put commas between Health
Reply With Quote #1

Hello, i want to add commas between health of zombie and human and who have more 1000
ex : 4000 = 4,000

this codes:
PHP Code:
// Show HUD Task
public ShowHUD(taskid)
{
    static 
id
    id 
ID_SHOWHUD;
    
    
// Player died?
    
if (!g_isalive[id])
    {
        
// Get spectating target
        
id pev(idPEV_SPEC_TARGET)
        
        
// Target not alive
        
if (!g_isalive[id]) return;
    }
    
    
// Format classname
    
static class[32], redgreenblue
    
    
if (g_zombie[id]) // zombies
    
{
        
red 250
        green 
250
        blue 
10
        
        
if (g_nemesis[id])
            
formatex(class, charsmax(class), "%L"ID_SHOWHUD"CLASS_NEMESIS")
        else if (
g_assassin[id])
            
formatex(class, charsmax(class), "%L"ID_SHOWHUD"CLASS_ASSASSIN")
        else
            
copy(class, charsmax(class), g_zombie_classname[id])
    }
    else 
// humans
    
{
        
red 0
        green 
180
        blue 
255
        
        
if (g_survivor[id])
            
formatex(class, charsmax(class), "%L"ID_SHOWHUD"CLASS_SURVIVOR")
        else if (
g_sniper[id])
            
formatex(class, charsmax(class), "%L"ID_SHOWHUD"CLASS_SNIPER")
        else
            
formatex(class, charsmax(class), "%L"ID_SHOWHUD"CLASS_HUMAN")
    }
    
    
// Spectating someone else?
    
if (id != ID_SHOWHUD)
    {
    
// Show name, health, class, and ammo packs and armor
        
set_hudmessage(27119224HUD_SPECT_XHUD_SPECT_Y06.01.10.00.0, -1)
        
ShowSyncHudMsg(ID_SHOWHUDg_MsgSync2"%L %s^nHP: %d - %L %s - %L %d - %L %d^nFrom: %s, %s"ID_SHOWHUD"SPECTATING"g_playername[id],
        
pev(idpev_health), ID_SHOWHUD"CLASS_CLASS", class, ID_SHOWHUD"AMMO_PACKS1"g_ammopacks[id], ID_SHOWHUD"ARMOR"pev(idpev_armorvalue), g_country[id], g_city[id])
    }
    else
    {
        
        
// Show health, class and ammo packs and armor
        
set_hudmessage(redgreenblueHUD_STATS_XHUD_STATS_Y06.01.10.00.0, -1)
        
ShowSyncHudMsg(ID_SHOWHUDg_MsgSync2"%L: %d - %L %s - %L %d - %L %d"id"ZOMBIE_ATTRIB1"pev(ID_SHOWHUDpev_health), ID_SHOWHUD"CLASS_CLASS",
        class, 
ID_SHOWHUD"AMMO_PACKS1"g_ammopacks[ID_SHOWHUD], ID_SHOWHUD"ARMOR"pev(ID_SHOWHUDpev_armorvalue))
    }

then i want to add commas here

PHP Code:
    // Retrieve zombie class id
    
static buffer[2], dummyclassid
    menu_item_getinfo
(menuiditemdummybuffercharsmax(buffer), __dummy)
    
classid buffer[0]
    
    
// Store selection for the next infection
    
g_zombieclassnext[id] = classid
    
    
static name[32]
    
ArrayGetString(g_zclass_nameg_zombieclassnext[id], namecharsmax(name))
    
    
// Show selected zombie class info and stats
    
zp_colored_print(id"^x04[ZP]^x01 %L^x01:^x04 %s"id"ZOMBIE_SELECT"name)
    
zp_colored_print(id"^x04[ZP]^x01 %L^x01:^x04 %d^x01 |^x01 %L^x01:^x04 %d^x01 |^x01 %L^x01:^x04 %d^x01 |^x01 %L^x01:^x04 %d%%"id"ZOMBIE_ATTRIB1"ArrayGetCell(g_zclass_hpg_zombieclassnext[id]), id"ZOMBIE_ATTRIB2"ArrayGetCell(g_zclass_spdg_zombieclassnext[id]),
    
id"ZOMBIE_ATTRIB3"floatround(Float:ArrayGetCell(g_zclass_gravg_zombieclassnext[id]) * 800.0), id"ZOMBIE_ATTRIB4"floatround(Float:ArrayGetCell(g_zclass_kbg_zombieclassnext[id]) * 100.0))
    
    
menu_destroy(menuid)
    return 
PLUGIN_HANDLED;

and in this link : https://forums.alliedmods.net/showthread.php?t=149882

pelase help.
thanks anyway.

Last edited by bakir123; 09-08-2015 at 08:07.
bakir123 is offline
Send a message via Skype™ to bakir123
Chihuahuax
Senior Member
Join Date: Oct 2014
Location: Malaysia
Old 09-06-2015 , 01:21   Re: HELP Put commas between Health
Reply With Quote #2

PHP Code:
AddCommasiNum szOutput[] , iLen )
{
    static 
szTmp15 ] , iOutputPos iNumPos iNumLen;
    
szTmp[0]='^0',iOutputPos=iNumPos=iNumLen=0;
    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;

just an example

Last edited by Chihuahuax; 09-06-2015 at 01:26.
Chihuahuax is offline
Send a message via Skype™ to Chihuahuax
thekiller123
Member
Join Date: Dec 2012
Old 09-06-2015 , 06:32   Re: HELP Put commas between Health
Reply With Quote #3

Try this:

PHP Code:
#include <amxmodx>

native zp_get_user_zombie(index);
new 
g_status_sync;

public 
plugin_init()
{
    
register_plugin("PGL-Zombie Stats""1.0""Hattrick");
    
register_event("StatusValue""showStatus""be""1=2""2!0");
    
register_event("StatusValue""hideStatus""be""1=1""2=0");
    
g_status_sync CreateHudSyncObj();
}

public 
showStatus(id)
{
    static 
HealthString[16];
    if (
is_user_connected(id) && !zp_get_user_zombie(id))
    {
        new 
name[32], pid read_data(2);
        
get_user_name(pidname31);
        if (
zp_get_user_zombie(pid))
        {
            
AddCommas(get_user_health(pid), HealthString15);
            
set_hudmessage(2551010, -1.00.6010.013.00.010.01, -1);
            
ShowSyncHudMsg(idg_status_sync"%s^nHP: %d"nameHealthString);
        }
    }
}

public 
hideStatus(id)
{
    
ClearSyncHud(idg_status_sync);
}

AddCommas(iNumszOutput[], iLen)
{
    static 
szTmp[15], iOutputPosiNumPosiNumLen;
    
szTmp[0]='^0',iOutputPos=iNumPos=iNumLen=0;
    if (
iNum 0)
    {
        
szOutput[iOutputPos++] = '-';
        
iNum abs(iNum);
    }

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


Last edited by thekiller123; 09-20-2015 at 09:05.
thekiller123 is offline
bakir123
Senior Member
Join Date: Jan 2015
Location: Palestine, Hebron
Old 09-06-2015 , 10:04   Re: HELP Put commas between Health
Reply With Quote #4

TheKiller, thaks , but i got error , error : agrument type mismatch <agrument 1>, now try to put here commas https://forums.alliedmods.net/showthread.php?t=149882
download it, and add commas there, thanks.

Last edited by bakir123; 09-06-2015 at 10:11.
bakir123 is offline
Send a message via Skype™ to bakir123
thekiller123
Member
Join Date: Dec 2012
Old 09-06-2015 , 10:31   Re: HELP Put commas between Health
Reply With Quote #5

PHP Code:
#include <amxmodx>

native zp_get_user_zombie(index);
new 
g_status_sync;

public 
plugin_init()
{
    
register_plugin("PGL-Zombie Stats""1.0""Hattrick");
    
register_event("StatusValue""showStatus""be""1=2""2!0");
    
register_event("StatusValue""hideStatus""be""1=1""2=0");
    
g_status_sync CreateHudSyncObj();
}

public 
showStatus(id)
{
    static 
HealthString[16];
    if (
is_user_connected(id) && !zp_get_user_zombie(id))
    {
        new 
name[32], pid read_data(2);
        
get_user_name(pidname31);
        if (
zp_get_user_zombie(pid))
        {
            
AddCommas(get_user_health(pid), HealthString15);
            
set_hudmessage(2551010, -1.00.6010.013.00.010.01, -1);
            
ShowSyncHudMsg(idg_status_sync"%s^nHP: %d"nameHealthString);
        }
    }
}

public 
hideStatus(id)
{
    
ClearSyncHud(idg_status_sync);
}

AddCommas(iNumszOutput[], iLen)
{
    static 
szTmp[15], iOutputPosiNumPosiNumLen;
    
szTmp[0]='^0',iOutputPos=iNumPos=iNumLen=0;
    if (
iNum 0)
    {
        
szOutput[iOutputPos++] = '-';
        
iNum abs(iNum);
    }

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


Last edited by thekiller123; 09-07-2015 at 08:20.
thekiller123 is offline
bakir123
Senior Member
Join Date: Jan 2015
Location: Palestine, Hebron
Old 09-06-2015 , 11:31   Re: HELP Put commas between Health
Reply With Quote #6

well, it's compiled, but this have a bug, This bug is, when you show health of zombie, you will show just 52 or 50 hp
you can't see full health, if it have. i really can't show more 52 wtf !
bakir123 is offline
Send a message via Skype™ to bakir123
Old 09-07-2015, 02:12
Chihuahuax
This message has been deleted by Chihuahuax. Reason: fail
thekiller123
Member
Join Date: Dec 2012
Old 09-07-2015 , 08:16   Re: HELP Put commas between Health
Reply With Quote #7

Try:

PHP Code:
#include <amxmodx>

native zp_get_user_zombie(index);
new 
g_status_sync;

public 
plugin_init()
{
    
register_plugin("PGL-Zombie Stats""1.0""Hattrick");
    
register_event("StatusValue""showStatus""be""1=2""2!0");
    
register_event("StatusValue""hideStatus""be""1=1""2=0");
    
g_status_sync CreateHudSyncObj();
}

public 
showStatus(id)
{
    static 
HealthString[16];
    if (
is_user_connected(id) && !zp_get_user_zombie(id))
    {
        new 
name[32], pid read_data(2);
        
get_user_name(pidname31);
        if (
zp_get_user_zombie(pid))
        {
            
AddCommas(get_user_health(pid), HealthString15);
            
set_hudmessage(2551010, -1.00.6010.013.00.010.01, -1);
            
ShowSyncHudMsg(idg_status_sync"%s^nHP: %d"nameHealthString);
        }
    }
}

public 
hideStatus(id)
{
    
ClearSyncHud(idg_status_sync);
}

AddCommas(iNumszOutput[], iLen)
{
    static 
szTmp[15], iOutputPosiNumPosiNumLen;
    
szTmp[0]='^0',iOutputPos=iNumPos=iNumLen=0;
    if (
iNum 0)
    {
        
szOutput[iOutputPos++] = '-';
        
iNum abs(iNum);
    }

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


Last edited by thekiller123; 09-07-2015 at 08:17.
thekiller123 is offline
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 17:11.


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