Raised This Month: $ Target: $400
 0% 

Why are variables not getting filled?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
hlstriker
Green Gaben
Join Date: Mar 2006
Location: OH-IO!
Old 09-26-2006 , 17:16   Why are variables not getting filled?
Reply With Quote #1

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; }
hlstriker is offline
Greenberet
AMX Mod X Beta Tester
Join Date: Apr 2004
Location: Vienna
Old 09-26-2006 , 17:48   Re: Why are variables not getting filled?
Reply With Quote #2

you aren't passing any player id's into the function
Greenberet is offline
Send a message via ICQ to Greenberet Send a message via MSN to Greenberet
hlstriker
Green Gaben
Join Date: Mar 2006
Location: OH-IO!
Old 09-26-2006 , 17:52   Re: Why are variables not getting filled?
Reply With Quote #3

How am I supposed to pass it with a set_task?
hlstriker is offline
TheNewt
Donor
Join Date: Jun 2006
Location: Where I live.
Old 09-26-2006 , 18:06   Re: Why are variables not getting filled?
Reply With Quote #4

Code:
set_task(0.5,"Do_Func",id)
Try that. Instead of 0
__________________
Quote:
toe3_ left the chat room. (G-lined (AUTO Excessive connections from a single host.))
TheNewt is offline
Emp`
AMX Mod X Plugin Approver
Join Date: Aug 2005
Location: Decapod 10
Old 09-26-2006 , 18:07   Re: Why are variables not getting filled?
Reply With Quote #5

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
	}
 }
Emp` is offline
Send a message via AIM to Emp` Send a message via MSN to Emp` Send a message via Yahoo to Emp` Send a message via Skype™ to Emp`
hlstriker
Green Gaben
Join Date: Mar 2006
Location: OH-IO!
Old 09-26-2006 , 18:27   Re: Why are variables not getting filled?
Reply With Quote #6

Quote:
Originally Posted by Emp` View Post
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.
hlstriker is offline
Zenith77
Veteran Member
Join Date: Aug 2005
Old 09-26-2006 , 20:04   Re: Why are variables not getting filled?
Reply With Quote #7

He gave you a code snippet, in the hopes that you would edit it, not completly use it as it.
__________________
Quote:
Originally Posted by phorelyph View Post
your retatred
Zenith77 is offline
hlstriker
Green Gaben
Join Date: Mar 2006
Location: OH-IO!
Old 09-26-2006 , 21:38   Re: Why are variables not getting filled?
Reply With Quote #8

Quote:
Originally Posted by Zenith77 View Post
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 !
hlstriker is offline
stupok
Veteran Member
Join Date: Feb 2006
Old 09-26-2006 , 22:23   Re: Why are variables not getting filled?
Reply With Quote #9

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

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;  }
stupok is offline
wonsae
Senior Member
Join Date: Jan 2006
Location: Behind you >:D
Old 09-26-2006 , 22:39   Re: Why are variables not getting filled?
Reply With Quote #10

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);
    }

wonsae 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 04:49.


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