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

[REQ] Progress bar


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
spirit
Senior Member
Join Date: Jul 2009
Location: Quimper
Old 06-15-2012 , 06:14   [REQ] Progress bar
Reply With Quote #1

Hi all,

I seach how to made progress bar with this style:

| | | | | | | | | | -> for 100%

| | | | | ->for 50%

for show all time for the player.
I use the global var for made this percent 'g_playerexp[33]'
spirit is offline
Larcyn
Senior Member
Join Date: Oct 2010
Old 06-15-2012 , 07:48   Re: [REQ] Progress bar
Reply With Quote #2

You could use a while loop and for each time you loop, a "| " should be added into your main string.

You must tell how much XP the player should have when he should reach 100% also, otherwise we're not able to know what you define as 100%.
__________________

Taking private requests, PM me for information.
Selling HideNSeek & Jailbreak plugins.

Selling Achievement API System (PHP &
MySQL / nVault)

Last edited by Larcyn; 06-15-2012 at 07:50.
Larcyn is offline
spirit
Senior Member
Join Date: Jul 2009
Location: Quimper
Old 06-15-2012 , 11:49   Re: [REQ] Progress bar
Reply With Quote #3

For 100% of g_playerexp[33] it's 10 000xp

Last edited by spirit; 06-15-2012 at 11:49.
spirit is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 06-15-2012 , 11:55   Re: [REQ] Progress bar
Reply With Quote #4

Code:
#define MAX_BARS    10 stock ProgressBar(Float:percent, output[], len) {         new bars = floatround(MAX_BARS * percent / 100.0);     new ret;         while(bars --> 0) {         ret = add(output, len, "|");     }         output[ret] = EOS;     return ret;     }

Code:
new barString[MAX_BARS + 1]; ProgressBar(50.0, barString, charsmax(barString)); // barString = "|||||"
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
<VeCo>
Veteran Member
Join Date: Jul 2009
Location: Bulgaria
Old 06-15-2012 , 11:57   Re: [REQ] Progress bar
Reply With Quote #5

PHP Code:
while(bars --> 0) { 

o.o
__________________

Last edited by <VeCo>; 06-15-2012 at 11:57.
<VeCo> is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 06-15-2012 , 12:06   Re: [REQ] Progress bar
Reply With Quote #6

Quote:
Originally Posted by <VeCo> View Post
PHP Code:
while(bars --> 0) { 

o.o
It's a fun coding illusion.

Code:
while(bars-- > 0) // or while(--bars >= 0)
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
<VeCo>
Veteran Member
Join Date: Jul 2009
Location: Bulgaria
Old 06-15-2012 , 12:11   Re: [REQ] Progress bar
Reply With Quote #7

Quote:
Originally Posted by Exolent[jNr] View Post
It's a fun coding illusion.


Code:
while(bars-- > 0)</p><p>&nbsp;</p><p>// or</p><p>&nbsp;</p><p>while(--bars >= 0)

Cool.
__________________

Last edited by <VeCo>; 06-15-2012 at 12:12.
<VeCo> is offline
spirit
Senior Member
Join Date: Jul 2009
Location: Quimper
Old 06-15-2012 , 16:49   Re: [REQ] Progress bar
Reply With Quote #8

I trying this but not work :s

PHP Code:
#include <amxmodx>
#include <engine>

#define MAX_BARS    10
#define MAX_XP_PER_LEVEL 10000

new g_playerexp[33]

new 
HudSyncObj
new barString[MAX_BARS 1]

public 
plugin_init()
{
    new 
iThinkingEntity create_entity("info_target")
    new 
szClass[] = "ShowHudExp"
    
if( iThinkingEntity )
    {
        
entity_set_string(iThinkingEntityEV_SZ_classnameszClass)
        
entity_set_float(iThinkingEntityEV_FL_nextthinkget_gametime() + 0.1)
        
register_think(szClassszClass)
    }
    else
        
set_task(0.1szClass, -65496879641, .flags="b");

    
register_clcmd("say ho""ho")
    
register_clcmd("say hi""lol")
    
HudSyncObj CreateHudSyncObj()    
}

public 
client_putinserver(id)
{
    
g_playerexp[id] = 0
}

public 
ho(id)
{
    
g_playerexp[id] = 50
}

public 
lol(id)
{
    
g_playerexp[id] = 100
}

public 
ShowHudExp(ent)
{
    if(
ent && is_valid_ent(ent))
    {
        
entity_set_float(entEV_FL_nextthinkget_gametime() + 0.1)
    }

    new 
iPlayers[32], iNumid
    get_players
(iPlayersiNum"ch")
    
set_hudmessage(2552552550.020.200.0000010.1010.0000010.000001)
    
    for(new 
ii<iNumi++)
    {
        
id iPlayers[i]
        new 
Float:percentage = (g_playerexp[id] * 100.0)  / MAX_XP_PER_LEVEL
        ProgressBar
(percentagebarStringcharsmax(barString))
        
        
ShowSyncHudMsg(id,  HudSyncObj"Exp: %s",  barString)
    }
}

stock ProgressBar(Float:percentoutput[], len
{
    new 
bars floatround(MAX_BARS percent 100.0)
    new 
ret
    
    
while(bars --> 0
        
ret add(outputlen"|");

    
output[ret] = EOS
    
return ret;


Last edited by spirit; 06-16-2012 at 03:28.
spirit 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 13:06.


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