Raised This Month: $ Target: $400
 0% 

[HELP] Fix method random_num


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
extream87
Senior Member
Join Date: Aug 2011
Old 03-11-2014 , 20:39   [HELP] Fix method random_num
Reply With Quote #1

What is the best method to do this?
Sometimes the hudmessage not appear but the sound works.
Code:
public plugin_init() { register_event("HLTV","rnstart","a", "1=0", "2=0"); } public rnstart(id) {     if(get_pcvar_num(rnstartcvar) == 1)     {     firstblood = 1           new rand = random_num(1,3)     switch(rand)     {     case 1:     {         set_hudmessage(255, 0, 255, -1.0, 0.30, 0, 6.0, 6.0)         show_hudmessage(0, "P R E P A R E 1 !")         client_cmd(0,"spk sound/Prepare1.wav")     }     case 2:     {         set_hudmessage(255, 0, 255, -1.0, 0.30, 0, 6.0, 6.0)         show_hudmessage(0, "P R E P A R E 2 !")         client_cmd(0,"spk sound/Prepare2.wav")     }     case 3:     {         set_hudmessage(255, 0, 255, -1.0, 0.30, 0, 6.0, 6.0)         show_hudmessage(0, "P R E P A R E 3 !")         client_cmd(0,"spk sound/Prepare3.wav")     }     }       } }

Last edited by extream87; 03-11-2014 at 20:43.
extream87 is offline
^SmileY
Veteran Member
Join Date: Jan 2010
Location: Brazil [<o>]
Old 03-11-2014 , 22:55   Re: [HELP] Fix method random_num
Reply With Quote #2

If you only use any variable one time, it is make no sense to create it!
Put it directly
new rand = random_num(1,3) switch(rand)

To

switch(random_num(1,3))
__________________
Projects:

- See my Git Hub: https://github.com/SmileYzn
PHP Code:
set_pcvar_num(pCvar, !get_pcvar_num(pCvar)); 
^SmileY is offline
Send a message via MSN to ^SmileY Send a message via Skype™ to ^SmileY
extream87
Senior Member
Join Date: Aug 2011
Old 03-12-2014 , 03:16   Re: [HELP] Fix method random_num
Reply With Quote #3

Yes is only in player spawn.

Well i've putted "," and i think now is working.

Code:
public plugin_init() { register_event("HLTV","rnstart","a", "1=0", "2=0"); } public rnstart(id) {     if(get_pcvar_num(rnstartcvar) == 1)     {     firstblood = 1           switch(random_num(1,3))     {     case 1:     {         set_hudmessage(255, 0, 255, -1.0, 0.30, 0, 6.0, 6.0),         show_hudmessage(0, "P R E P A R E 1 !"),         client_cmd(0,"spk sound/Prepare1.wav")     }     case 2:     {         set_hudmessage(255, 0, 255, -1.0, 0.30, 0, 6.0, 6.0),         show_hudmessage(0, "P R E P A R E 2 !"),         client_cmd(0,"spk sound/Prepare2.wav")     }     case 3:     {         set_hudmessage(255, 0, 255, -1.0, 0.30, 0, 6.0, 6.0),         show_hudmessage(0, "P R E P A R E 3 !"),         client_cmd(0,"spk sound/Prepare3.wav")     }     }       } }

Last edited by extream87; 03-12-2014 at 03:42.
extream87 is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 03-12-2014 , 03:41   Re: [HELP] Fix method random_num
Reply With Quote #4

That is common with HUD messages because they can easily be removed by other plugins or even the game itself without ever showing your message.
__________________
fysiks is offline
extream87
Senior Member
Join Date: Aug 2011
Old 03-12-2014 , 03:42   Re: [HELP] Fix method random_num
Reply With Quote #5

Ah ok fysiks, so it's normal?
extream87 is offline
Shooting King
RAAASENGAN
Join Date: Mar 2012
Location: India
Old 03-12-2014 , 04:09   Re: [HELP] Fix method random_num
Reply With Quote #6

Set Channel to -1 and try again.
__________________
As every time said, don't ever UNDERESTIMATE me.

Donate - Here
Shooting King is offline
extream87
Senior Member
Join Date: Aug 2011
Old 03-12-2014 , 09:57   Re: [HELP] Fix method random_num
Reply With Quote #7

Shooting_King: This?
Code:
switch(random_num(1,3-1))
extream87 is offline
Neeeeeeeeeel.-
Some Guy Yellin'
Join Date: Jul 2010
Location: Argentina
Old 03-12-2014 , 10:39   Re: [HELP] Fix method random_num
Reply With Quote #8

Quote:
Originally Posted by extream87 View Post
Shooting_King: This?
Code:
switch(random_num(1,3-1))
No, he was talking about hud message channel.

You should know that you cannot display more than 4 hud's at the same time.
__________________
Neeeeeeeeeel.- is offline
Send a message via Skype™ to Neeeeeeeeeel.-
extream87
Senior Member
Join Date: Aug 2011
Old 03-12-2014 , 10:44   Re: [HELP] Fix method random_num
Reply With Quote #9

Sure and when player spawn happen i dont have any hudmessage.
If you look to the code you see that are 3 hudmessages but only one is randomly chosen.

So what Shooting_King says is:
Code:
show_hudmessage(-1, "P R E P A R E 1 !"),
Im write now?
The -1 have the same value as 0?
Cause i need this message appear to all players.

Edit:
With -1 nothing appears.

Last edited by extream87; 03-12-2014 at 10:49.
extream87 is offline
Kiske
Veteran Member
Join Date: May 2009
Old 03-12-2014 , 13:14   Re: [HELP] Fix method random_num
Reply With Quote #10

Quote:
/**
* Sets format for hudmessage.
* Note - as of AMX Mod X 1.61, setting the channel to -1
* will automatically choose the next available HUD channel for a player.
*/
native set_hudmessage(red=200, green=100, blue=0, Float=-1.0, Float:y=0.35, effects=0, Float:fxtime=6.0, Float:holdtime=12.0, Float:fadeintime=0.1, Float:fadeouttime=0.2,channel=4);

/* Displays HUD message to given player. */
native show_hudmessage(index,const message[],any:...);
...
__________________

Kiske is offline
Send a message via Skype™ to Kiske
Reply


Thread Tools
Display Modes

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 06:01.


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