Raised This Month: $ Target: $400
 0% 

Skills float


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
darklite
Member
Join Date: Jun 2014
Old 06-30-2014 , 17:29   Skills float
Reply With Quote #1

hey, i'm a new one(still learning) . my problem is i need how to set a float number and read it in hud . like this(just a ex)

[ Name : darklite | Health: x | Skills : 1.6% ]

Last edited by darklite; 06-30-2014 at 18:15. Reason: changing the title because its so newbie
darklite is offline
Flick3rR
Veteran Member
Join Date: Feb 2014
Location: Bulgaria, Stara Zagora
Old 06-30-2014 , 17:40   Re: help pleasee
Reply With Quote #2

Let the code say it.
PHP Code:
public Function(id)
{
    
set_hudmessage(25500, -1.0, -1.00_12.0__, -1)
    
    new 
string[32]
    new 
Float:MyFloat 1.6 //Here is your float
    
float_to_str(MyFloatstringcharsmax(string)) 
    
show_hudmessage(id"My float is %s"string)

__________________
Flick3rR is offline
Send a message via Skype™ to Flick3rR
darklite
Member
Join Date: Jun 2014
Old 06-30-2014 , 17:46   Re: help pleasee
Reply With Quote #3

already made it :v
when i add cvar and i check in DeathMsg if headshot i try to add a float like cvar = register_cvar("float_hs","1.40")

if (read_data(3)).... Skills[id] += get_pcvar_float(cvar))

but in hud does not appear the cvar ...
darklite is offline
Flick3rR
Veteran Member
Join Date: Feb 2014
Location: Bulgaria, Stara Zagora
Old 06-30-2014 , 17:54   Re: help pleasee
Reply With Quote #4

Quote:
Originally Posted by darklite View Post
already made it :v
when i add cvar and i check in DeathMsg if headshot i try to add a float like cvar = register_cvar("float_hs","1.40")

if (read_data(3)).... Skills[id] += get_pcvar_float(cvar))

but in hud does not appear the cvar ...
In this case your Skills[id] should be tagged with Float:
__________________

Last edited by Flick3rR; 06-30-2014 at 17:54.
Flick3rR is offline
Send a message via Skype™ to Flick3rR
mottzi
Veteran Member
Join Date: May 2010
Location: Switzerland
Old 06-30-2014 , 17:47   Re: help pleasee
Reply With Quote #5

You dont need to convert the float to a string, use '%f' to format the output.

PHP Code:
public Function(id)
{
    
set_hudmessage(25500, -1.0, -1.00_12.0__, -1)
    
    new 
Float:MyFloat 1.6 //Here is your float
    
show_hudmessage(id"My float is %f"MyFloat)

mottzi is offline
Send a message via MSN to mottzi
darklite
Member
Join Date: Jun 2014
Old 06-30-2014 , 17:56   Re: help pleasee
Reply With Quote #6

lol . i've test it before !
darklite is offline
mottzi
Veteran Member
Join Date: May 2010
Location: Switzerland
Old 06-30-2014 , 18:04   Re: help pleasee
Reply With Quote #7

Can you post the whole code? It's quite difficult to say whats wrong when we don't have the source.
mottzi is offline
Send a message via MSN to mottzi
darklite
Member
Join Date: Jun 2014
Old 06-30-2014 , 18:13   Re: help pleasee
Reply With Quote #8

PHP Code:
/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <amxmisc>

new Skills[33]
new 
g_AddSkills[2];

public 
plugin_init() {
    
    
g_AddSkills[0]  = register_cvar("skills_normal","1.20")
    
g_AddSkills[1]  = register_cvar("skills_headshot","1.30")
    
    
register_clcmd("say /skills","showskills")
    
    
register_event"DeathMsg""Hook_Death""a" );
    
}
public 
Hook_Death()
{
    new 
killer   read_data);
    new 
hs         read_data);
    
    if(
hs)
        
Skills[killer] += get_pcvar_float(g_AddSkills[1])
    else
        
Skills[killer] += get_pcvar_float(g_AddSkills[0])
}
public 
showskills(id){
    new 
Floats
    Floats 
float:Skills[id]
    
client_print(id,print_chat,"Your Skills %f",Floats)

darklite is offline
Flick3rR
Veteran Member
Join Date: Feb 2014
Location: Bulgaria, Stara Zagora
Old 06-30-2014 , 18:19   Re: Skills float
Reply With Quote #9

The tag should not be here:
PHP Code:
Floats float:Skills[id
It should be Float: tag, and put it where you create the new variable. You have to change this:
PHP Code:
new Float:Skills[33
And now you have that Skills, which is always float, unless you floatround it.

P.S.: You can also do this:
PHP Code:
Skills[killer] += get_pcvar_float(g_AddSkills[hs 0]) 
Instead of this:
PHP Code:
    if(hs)
        
Skills[killer] += get_pcvar_float(g_AddSkills[1])
    else
        
Skills[killer] += get_pcvar_float(g_AddSkills[0]) 
__________________

Last edited by Flick3rR; 06-30-2014 at 18:20.
Flick3rR is offline
Send a message via Skype™ to Flick3rR
darklite
Member
Join Date: Jun 2014
Old 06-30-2014 , 18:23   Re: Skills float
Reply With Quote #10

lool my mistake is i didn't notice that there's a difference between float and Float . tnx anyway ^_^
darklite is offline
Reply


Thread Tools
Display Modes

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 21:14.


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