AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Skills float (https://forums.alliedmods.net/showthread.php?t=243182)

darklite 06-30-2014 17:29

Skills float
 
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% ]

Flick3rR 06-30-2014 17:40

Re: help pleasee
 
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)



darklite 06-30-2014 17:46

Re: help pleasee
 
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 ...

mottzi 06-30-2014 17:47

Re: help pleasee
 
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)



Flick3rR 06-30-2014 17:54

Re: help pleasee
 
Quote:

Originally Posted by darklite (Post 2159976)
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:

darklite 06-30-2014 17:56

Re: help pleasee
 
lol . i've test it before !

mottzi 06-30-2014 18:04

Re: help pleasee
 
Can you post the whole code? It's quite difficult to say whats wrong when we don't have the source.

darklite 06-30-2014 18:13

Re: help pleasee
 
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)



Flick3rR 06-30-2014 18:19

Re: Skills float
 
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]) 


darklite 06-30-2014 18:23

Re: Skills float
 
lool my mistake is i didn't notice that there's a difference between float and Float . tnx anyway ^_^


All times are GMT -4. The time now is 21:14.

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