Raised This Month: $ Target: $400
 0% 

Help Me With Hud For Spectator


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
gabuch2
AlliedModders Donor
Join Date: Mar 2011
Location: Chile
Old 05-19-2020 , 20:21   Re: Help Me With Hud For Spectator
Reply With Quote #1

If the first parameter of ShowSyncHudMsg is 0 it will show to all players.

Loop through all players and check if they're spectator with cs_get_user_team()

Code:
public show() {     if(!c4pl)     {         remove_task(652450)         return     }     if(c4cd>=0.0)     {         temp=c4cd/c4max         if(temp>=0.5)         {             r=510*(1.0-temp)             g=255.0         }         if(temp<0.5)         {             r=255.0             g=510*temp         }             for(new i = 1; i <= get_maxplayers();i++)     {         if(is_user_connected(i) && cs_get_user_team(i) == CS_TEAM_SPECTATOR)         {             set_hudmessage(floatround(r),floatround(g),0,-1.0,0.80,0,_,1.0,_,_,4)             ShowSyncHudMsg(i,msg,"Anda a Defusear la bomba!!! Faltan %d segundos antes de que explote.",floatround(c4cd))         }     }     c4cd-=1.0 }

Untested
__________________

Last edited by gabuch2; 05-19-2020 at 20:24. Reason: Should set hudmessage only if player is valid. Fixed off by 1 error.
gabuch2 is offline
Arje
Senior Member
Join Date: Apr 2020
Location: Córdoba, Argentina
Old 05-20-2020 , 12:45   Re: Help Me With Hud For Spectator
Reply With Quote #2

Quote:
Originally Posted by Gabe Iggy View Post
If the first parameter of ShowSyncHudMsg is 0 it will show to all players.

Loop through all players and check if they're spectator with cs_get_user_team()

Code:
public show() {     if(!c4pl)     {         remove_task(652450)         return     }     if(c4cd>=0.0)     {         temp=c4cd/c4max         if(temp>=0.5)         {             r=510*(1.0-temp)             g=255.0         }         if(temp<0.5)         {             r=255.0             g=510*temp         }             for(new i = 1; i <= get_maxplayers();i++)     {         if(is_user_connected(i) && cs_get_user_team(i) == CS_TEAM_SPECTATOR)         {             set_hudmessage(floatround(r),floatround(g),0,-1.0,0.80,0,_,1.0,_,_,4)             ShowSyncHudMsg(i,msg,"Anda a Defusear la bomba!!! Faltan %d segundos antes de que explote.",floatround(c4cd))         }     }     c4cd-=1.0 }

Untested
Thank you! works correctly;
I had corrected it before, I had a small typing error, but you corrected the code so I don't have to upload mine, thanks again!
Arje is offline
Arje
Senior Member
Join Date: Apr 2020
Location: Córdoba, Argentina
Old 06-03-2020 , 17:29   Re: Help Me With Hud For Spectator
Reply With Quote #3

Quote:
Originally Posted by Gabe Iggy View Post
If the first parameter of ShowSyncHudMsg is 0 it will show to all players.

Loop through all players and check if they're spectator with cs_get_user_team()

Code:
public show() {     if(!c4pl)     {         remove_task(652450)         return     }     if(c4cd>=0.0)     {         temp=c4cd/c4max         if(temp>=0.5)         {             r=510*(1.0-temp)             g=255.0         }         if(temp<0.5)         {             r=255.0             g=510*temp         }             for(new i = 1; i <= get_maxplayers();i++)     {         if(is_user_connected(i) && cs_get_user_team(i) == CS_TEAM_SPECTATOR)         {             set_hudmessage(floatround(r),floatround(g),0,-1.0,0.80,0,_,1.0,_,_,4)             ShowSyncHudMsg(i,msg,"Anda a Defusear la bomba!!! Faltan %d segundos antes de que explote.",floatround(c4cd))         }     }     c4cd-=1.0 }

Untested
Hi! I have another question, because the hud is still in the next round if there is mp_freezetime? and how could that be arranged?
Arje 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 17:03.


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