AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Why are variables not getting filled? (https://forums.alliedmods.net/showthread.php?t=45243)

hlstriker 09-26-2006 17:16

Why are variables not getting filled?
 
Hi, the variables to show for the set_hudmessage are not filling or something. In game the hud message is showing where the variables should be with all 0's. I put all of this in a prethink and it worked fine but I don't want it there.

Code:
public plugin_init() {     set_task(0.49,"hudHP",0,"",0,"b"); } public hudHP(id) {     new ping, loss;     new health = get_user_health(id);     new armor = get_user_armor(id);     new frags = get_user_frags(id);     new deaths = get_user_deaths(id);     get_user_ping(id, ping, loss);         set_hudmessage(255, 0, 0, -1.3, 1.3, 0, 0.0, 0.5, 0.0, 0.0, 4);     show_hudmessage(id, "Health: %d - Armor: %d ^n Frags: %d - Deaths: %d ^n Ping: %d - Loss: %d", health, armor, frags, deaths, ping, loss);         return PLUGIN_CONTINUE; }

Greenberet 09-26-2006 17:48

Re: Why are variables not getting filled?
 
you aren't passing any player id's into the function

hlstriker 09-26-2006 17:52

Re: Why are variables not getting filled?
 
How am I supposed to pass it with a set_task?

TheNewt 09-26-2006 18:06

Re: Why are variables not getting filled?
 
Code:
set_task(0.5,"Do_Func",id)
Try that. Instead of 0

Emp` 09-26-2006 18:07

Re: Why are variables not getting filled?
 
Code:

public my_loop()
 {
        new players[MAX_PLAYERS], id
        get_players(players, pnum)

        for ( new i = 0; i < pnum; i++ )
        {
                id = players[i]

                //you would want to put your stuff here
        }
 }


hlstriker 09-26-2006 18:27

Re: Why are variables not getting filled?
 
Quote:

Originally Posted by Emp` (Post 384932)
Code:

public my_loop()
 {
        new players[MAX_PLAYERS], id
        get_players(players, pnum)

        for ( new i = 0; i < pnum; i++ )
        {
                id = players[i]

                //you would want to put your stuff here
        }
 }


That code displayed these errors on compile...
Quote:

/home/groups/amxmodx/tmp3/phpbh7iN8.sma(120) : error 017: undefined symbol "MAX_PLAYERS"
/home/groups/amxmodx/tmp3/phpbh7iN8.sma(120) : error 029: invalid expression, assumed zero
/home/groups/amxmodx/tmp3/phpbh7iN8.sma(120 -- 121) : warning 215: expression has no effect
/home/groups/amxmodx/tmp3/phpbh7iN8.sma(121) : error 017: undefined symbol "players"
/home/groups/amxmodx/tmp3/phpbh7iN8.sma(121) : fatal error 107: too many error messages on one line
@Mystic Death
Setting 0 to id gave me errors too.

Zenith77 09-26-2006 20:04

Re: Why are variables not getting filled?
 
He gave you a code snippet, in the hopes that you would edit it, not completly use it as it.

hlstriker 09-26-2006 21:38

Re: Why are variables not getting filled?
 
Quote:

Originally Posted by Zenith77 (Post 384970)
He gave you a code snippet, in the hopes that you would edit it, not completly use it as it.

I am still trying to learn, and am not very good at coding. I do what I can and ask for help with the questions I have. I do not know how to debug this by myself that is why I posted the compile errors in the hope that someone could tell me what I needed to do. I am not just going to mooch the code off of everyone if I know how to do it or if I cannot find it. I always try and search before I post too. Sorry if you all think i'm mooching with all of the nooby questions i've been asking, but I really am trying to learn. Asking questions, seeing the code, and seeing what it does in game really does teach. I thank you all for your help so far :)!

stupok 09-26-2006 22:23

Re: Why are variables not getting filled?
 
Ok I spent a few moments playing with the code they gave you, I don't know for sure if this code will work, but it compiled with no errors. I cannot try it out right now.

I suspect that it will work just fine :up:

MY VERSION:
Code:
#include <amxmodx> #include <amxmisc> #define PLUGIN "New Plug-In" #define VERSION "1.0" #define AUTHOR "Kamil" new id public plugin_init() {     register_plugin(PLUGIN, VERSION, AUTHOR)     set_task(0.49,"my_loop",id); } public my_loop(id)  {     new ping, loss;     get_user_ping(id, ping, loss);         new health = get_user_health(id);     new armor = get_user_armor(id);     new frags = get_user_frags(id);     new deaths = get_user_deaths(id);             set_hudmessage(255, 0, 0, -1.3, 1.3, 0, 0.0, 0.5, 0.0, 0.0, 4);             show_hudmessage(id, "Health: %d - Armor: %d ^n Frags: %d - Deaths: %d ^n Ping: %d - Loss: %d", health, armor, frags, deaths, ping, loss);             return PLUGIN_CONTINUE;  }

wonsae 09-26-2006 22:39

Re: Why are variables not getting filled?
 
PHP Code:

public plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
set_task(2.0,"loop",0,"",0,"b");
}

public 
loop()
{
    new 
players[32], id
    get_players
(playerspnum)
    
    for ( new 
0pnumi++ )
    {
        new 
pingloss;
        
        
get_user_ping(players[i], pingloss);
        
        new 
health get_user_health(players[i]);
        new 
armor get_user_armor(players[i]);
        new 
frags get_user_frags(players[i]);
        new 
deaths get_user_deaths(players[i]);
        
        
set_hudmessage(25500, -1.31.300.00.50.00.04);
        
show_hudmessage(players[i], "Health: %d - Armor: %d ^n Frags: %d - Deaths: %d ^n Ping: %d - Loss: %d"healtharmorfragsdeathspingloss);
    }




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

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