Raised This Month: $ Target: $400
 0% 

Hud Messages...


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
BioHazardousWaste
Senior Member
Join Date: Apr 2005
Location: Ontario, Canada =)
Old 04-23-2005 , 20:29   Hud Messages...
Reply With Quote #1

Hey guys, i'm just wondering if anyone has an idea why this hud message won't show when teh debug under it does show?

Code:
        if (PlayerExp[id] >= ExperienceForLevel[PlayerLevel[id]+1])         {             PlayerLevel[id] += 1                         set_hudmessage(255, 255, 255, 2.0, 1.0, 1, 6.0, 15.0, 0.1, 0.2, 4)             show_hudmessage(0, "Congratulations on achieving level #%i", PlayerLevel[id])//doesn't show             PlayerMaxFocus[id] = PlayerLevel[id] +10             PlayerFocus[id] = PlayerMaxFocus[id]             //debug             client_print(id, print_console, "Player #%i reached level #%i", id, PlayerLevel[id])//shows             CheckLevel(id)         }
__________________
"What then is truth? Truths are illusions which we have forgotten are illusions - they are metaphors that have become worn out... this (truth) is the duty to lie according to a fixed convention.

-Friedrich Nietzsche
BioHazardousWaste is offline
Send a message via MSN to BioHazardousWaste
v3x
Veteran Member
Join Date: Oct 2004
Location: US
Old 04-23-2005 , 21:03  
Reply With Quote #2

Try using format(), see if that helps.
__________________
What am I doing these days? Well, I run my own Rust server. It's heavily modded. If you'd like to join, the ip is 167.114.101.67:28116

I also created a website called Rust Tools. It will calculate and tell you the raw amounts of resources needed to craft items.
v3x is offline
xeroblood
BANNED
Join Date: Mar 2004
Location: Toronto, Canada
Old 04-23-2005 , 21:57  
Reply With Quote #3

Yes, v3x is right, the show_hudmessage() function doesn't accept (and parse) variable arguments after the string (like format() does), so you will have to format your string first, and then pass the end-result string to show_hudmessage()
xeroblood is offline
Send a message via MSN to xeroblood
BioHazardousWaste
Senior Member
Join Date: Apr 2005
Location: Ontario, Canada =)
Old 04-23-2005 , 22:02  
Reply With Quote #4

Ok.. so here's what confuses me the most:

When I play alone, it works fine... when I play with someone else, it's all screwey. Now I found the problem with my write message thing. It was because I was sending it to people who didn't exists. I had it in a for loop 1 - 32. I added the check is_user_alive to all my code, so that should a) cut out unnecessary code, and b) hopefully fix this problem too.
__________________
"What then is truth? Truths are illusions which we have forgotten are illusions - they are metaphors that have become worn out... this (truth) is the duty to lie according to a fixed convention.

-Friedrich Nietzsche
BioHazardousWaste is offline
Send a message via MSN to BioHazardousWaste
teame06
i have a hat
Join Date: Feb 2005
Location: Hat City
Old 04-23-2005 , 22:10  
Reply With Quote #5

Quote:
Originally Posted by BioHazardousWaste
Ok.. so here's what confuses me the most:

When I play alone, it works fine... when I play with someone else, it's all screwey. Now I found the problem with my write message thing. It was because I was sending it to people who didn't exists. I had it in a for loop 1 - 32. I added the check is_user_alive to all my code, so that should a) cut out unnecessary code, and b) hopefully fix this problem too.
Question.

what code are you using to loop 1 - 32? something similar?

Code:
new maxplayers = get_maxplayers() new j for(j=1; j <= maxplayers; j++) {     // Code Something here? }
__________________
No private support via Instant Message
GunGame:SM Released
teame06 is offline
Send a message via AIM to teame06
BioHazardousWaste
Senior Member
Join Date: Apr 2005
Location: Ontario, Canada =)
Old 04-23-2005 , 22:19  
Reply With Quote #6

Ok.. wtf? I was just playing a lone and it worked fine, some random asshole (not really i'm just upset) joined then it doesn't work... Relevant code follows:

Code:
public DoNewRound() {         for(new i=1;i<=32;i++)         {       if(is_user_alive(i))             //debug             client_print(0, print_console, "Testing player #%i", i)                     RefreshExperience(i)             CheckLevel(i)             UpdateFocus(i)         } } public RefreshExperience(id) {     //kaput (gebroken) lol     new ExpMessage[128]     format(ExpMessage, 127, "Exp: %i / %i", PlayerExp[id], ExperienceForLevel[PlayerLevel[id] + 1])         message_begin(MSG_ONE, get_user_msgid("StatusText"), {0, 0, 0}, id);     write_byte(0);     write_string(ExpMessage);     message_end(); }//works fine public CheckLevel(id) {     //debug     client_print(0, print_console, "Checking player %i's level (%i) exp", id, PlayerExp[id])     if (PlayerLevel[id]<100)     {           if (PlayerExp[id] >= ExperienceForLevel[PlayerLevel[id]+1])         {             PlayerLevel[id] += 1                         set_hudmessage(255, 255, 255, 2.0, 1.0, 1, 6.0, 15.0, 0.1, 0.2, 4)             show_hudmessage(id, "Congratulations on achieving level #%i", PlayerLevel[id])//broken             PlayerMaxFocus[id] = PlayerLevel[id] +10             PlayerFocus[id] = PlayerMaxFocus[id]             //debug             client_print(id, print_console, "Player #%i reached level #%i", id, PlayerLevel[id])//works             CheckLevel(id)         }     }         if (PlayerLevel[id]>0)     {         if (PlayerExp[id] < ExperienceForLevel[PlayerLevel[id]])         {             PlayerLevel[id] -= 1                     set_hudmessage(255, 255, 255, 2.0, 1.0, 1, 6.0, 15.0, 0.1, 0.2, 4)             show_hudmessage(id, "You've lost a level! You are now level #%i", PlayerLevel[id])//broken             //debug             client_print(id, print_console, "Player #%i lost a level. They are now level #%i", id, PlayerLevel[id])//works             PlayerMaxFocus[id] = PlayerLevel[id] +10             PlayerFocus[id] = PlayerMaxFocus[id]             CheckLevel(id)         }     }     } public UpdateFocus(id) {     if(is_user_alive(id))     {         PlayerMaxFocus[id] = PlayerLevel[id] + 10//check required for admin set exp command         PlayerFocus[id] = PlayerFocus[id] + 2         //debug         client_print(id, print_console, "Setting maxfocus to Level(%i) + 10 (=%i)", PlayerLevel[id], PlayerMaxFocus[id])         if (PlayerFocus[id] > PlayerMaxFocus[id])         {             PlayerFocus[id] = PlayerMaxFocus[id]         }                 //debug         //client_print(i, print_chat, "set focus to: %i", PlayerFocus[id])             new Message[128] = ""         format(Message, 127, "FOCUS: %i/%i", PlayerFocus[id], PlayerMaxFocus[id])             set_hudmessage(255, 255, 255, 0.05, 0.75, 2, 0.02, 3.0, 0.01, 0.1, 2)         show_hudmessage(id, Message)     }     new ident[1]     ident[0] = id     set_task(1.0, "RefreshFocus", 451+id, ident, 1) } //for timed function only public RefreshFocus(ident[],TaskID) {     new id = ident[0]     UpdateFocus(id) } There we go, that's done at the begining of every round, now please tell me why the messages only work when there is only 1 person in the server (game is not officialy started).  And why in God's name does the focus update for only me, and never anyone else?
__________________
"What then is truth? Truths are illusions which we have forgotten are illusions - they are metaphors that have become worn out... this (truth) is the duty to lie according to a fixed convention.

-Friedrich Nietzsche
BioHazardousWaste is offline
Send a message via MSN to BioHazardousWaste
v3x
Veteran Member
Join Date: Oct 2004
Location: US
Old 04-23-2005 , 22:24  
Reply With Quote #7

Well.. When you're doing a loop like that.. Use something like this.

Code:
public myFunc() {     new players[32]     new player,num,i     get_players(players,num,"a")     // Doesn't return dead players     for(i=0;i<num;i++) {         player = players[i]         // Do something with player     }     return PLUGIN_HANDLED }
__________________
What am I doing these days? Well, I run my own Rust server. It's heavily modded. If you'd like to join, the ip is 167.114.101.67:28116

I also created a website called Rust Tools. It will calculate and tell you the raw amounts of resources needed to craft items.
v3x is offline
teame06
i have a hat
Join Date: Feb 2005
Location: Hat City
Old 04-23-2005 , 22:27  
Reply With Quote #8

Code:
show_hudmessage(id, "Congratulations on achieving level #%i", PlayerLevel[id])//broken to format(cong, 63, ""Congratulations on achieving level #%i", PlayerLevel[id]) show_hudmessage(id, cong)

Code:
show_hudmessage(id, "You've lost a level! You are now level #%i", PlayerLevel[id])//broken to format(lost, 63, "You've lost a level! You are now level #%i", PlayerLevel[id]) show_hudmessage(id, lost)
__________________
No private support via Instant Message
GunGame:SM Released
teame06 is offline
Send a message via AIM to teame06
BioHazardousWaste
Senior Member
Join Date: Apr 2005
Location: Ontario, Canada =)
Old 04-23-2005 , 22:27  
Reply With Quote #9

ok thanx, but i don't think that's going to help solve the problem lol
__________________
"What then is truth? Truths are illusions which we have forgotten are illusions - they are metaphors that have become worn out... this (truth) is the duty to lie according to a fixed convention.

-Friedrich Nietzsche
BioHazardousWaste is offline
Send a message via MSN to BioHazardousWaste
xeroblood
BANNED
Join Date: Mar 2004
Location: Toronto, Canada
Old 04-23-2005 , 22:27  
Reply With Quote #10

Quote:
Originally Posted by BioHazardousWaste
Code:
    message_begin(MSG_ONE, get_user_msgid("StatusText"), {0, 0, 0}, id);
Please replace MSG_ONE with MSG_ONE_UNRELIABLE so that people's servers don't randomly crash..

It doesn't mean your message won't be sent, it just means that HL won't crash if it can't be sent.. Even if it is not crashing for you now, it could in the future for anyone, if the message simply can't be sent for any number of reasons..
xeroblood is offline
Send a message via MSN to xeroblood
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 09:51.


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