Raised This Month: $52 Target: $400
 13% 

[SOLVED][CSS]Simple problem Random


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Nerus
Senior Member
Join Date: Aug 2010
Location: Poland
Old 07-17-2015 , 06:39   [SOLVED][CSS]Simple problem Random
Reply With Quote #1

Hi guys I tried to use GetRandomInt couple times in same frame of the game.

Example:
PHP Code:
public bool RandomBotUse()
{
    
//SetRandomSeed(GetTime());
    
if(GetRandomInt(01)) return true;
    return 
false;
}

public 
void RandomWireSet()
{
    
//SetRandomSeed(GetTime());
    
wire_set GetRandomInt(14);    
}

public 
void RandomWireSelect()
{
    
//SetRandomSeed(GetTime());
    
wire_selected GetRandomInt(14);    

Problem:
Quote:
First function and second working great, but last one not always return 0.
I can use only one time in frame GetRandom with same values ?

Regards,
Nerus.

Last edited by Nerus; 01-15-2016 at 06:43.
Nerus is offline
berni
SourceMod Plugin Approver
Join Date: May 2007
Location: Austria
Old 07-17-2015 , 07:42   Re: Simple problem Random
Reply With Quote #2

GetRandomInt() has proven to be very unreliable for me in the past.
It's probably based on the HL2 SDK random function, which implementation is pretty poor.

You could use GetURandomInt instead. You can find a sample function here:

https://github.com/bcserv/smlib/blob.../math.inc#L149
__________________
Why reinvent the wheel ? Download smlib with over 350 useful functions.

When people ask me "Plz" just because it's shorter than "Please" I feel perfectly justified to answer "No" because it's shorter than "Yes"
powered by Core i7 3770k | 32GB DDR3 1886Mhz | 2x Vertex4 SSD Raid0
berni is offline
Nerus
Senior Member
Join Date: Aug 2010
Location: Poland
Old 07-17-2015 , 08:14   Re: Simple problem Random
Reply With Quote #3

Quote:
Originally Posted by berni View Post
GetRandomInt() has proven to be very unreliable for me in the past.
It's probably based on the HL2 SDK random function, which implementation is pretty poor.

You could use GetURandomInt instead. You can find a sample function here:

https://github.com/bcserv/smlib/blob.../math.inc#L149
Thx 4 help.

By the way, when u will fix Smlib ? I know that is loot of work.

Regards,
Nerus.
Nerus is offline
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:24.


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