Raised This Month: $51 Target: $400
 12% 

Solved [CS:GO] GetRandomInt not working properly?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
manicogaming
AlliedModders Donor
Join Date: Aug 2014
Old 12-19-2018 , 21:40   [CS:GO] GetRandomInt not working properly?
Reply With Quote #1

I'm trying to give bots random Private Ranks and random Coins but for some reason it picks a random Coin and gives the same one to every bot and for the Private Rank it gives every bot a random Private Rank.

PHP Code:
public void OnClientPostAdminCheck(int client)
{
    if(
IsFakeClient(client))
    {
        
g_iCoin[client] = GetRandomInt(874,970); //This gets a random Coin and applies that same coin to every bot
        
g_iProfileRank[client] = GetRandomInt(1,40); //This gives bots a Private Rank from 1 to 40 with no problem
    
}


Last edited by manicogaming; 11-04-2020 at 14:45.
manicogaming is offline
Lubricant Jam
AlliedModders Donor
Join Date: Oct 2016
Location: United Kingdom
Old 12-20-2018 , 03:50   Re: [CS:GO] GetRandomInt not working properly?
Reply With Quote #2

Quote:
Originally Posted by manicogmaing View Post
I'm trying to give bots random Private Ranks and random Coins but for some reason it picks a random Coin and gives the same one to every bot and for the Private Rank it gives every bot a random Private Rank.

PHP Code:
public void OnClientPostAdminCheck(int client)
{
    if(
IsFakeClient(client))
    {
        
g_iCoin[client] = GetRandomInt(874,970); //This gets a random Coin and applies that same coin to every bot
        
g_iProfileRank[client] = GetRandomInt(1,40); //This gives bots a Private Rank from 1 to 40 with no problem
    
}

You could try looping through players.

EDIT: Nvm, I read your post wrong.

Last edited by Lubricant Jam; 12-20-2018 at 03:51.
Lubricant Jam is offline
Indarello
Senior Member
Join Date: Nov 2015
Location: Russia
Old 12-20-2018 , 10:13   Re: [CS:GO] GetRandomInt not working properly?
Reply With Quote #3

g_iCoin[client] = GetRandomInt(874,970);
g_iProfileRank[client] = GetRandomInt(1,40);
PrintToServer("[%d] [%N]", g_iCoin[client], client); //this is debug

Last edited by Indarello; 12-20-2018 at 10:15.
Indarello is offline
manicogaming
AlliedModders Donor
Join Date: Aug 2014
Old 12-20-2018 , 10:35   Re: [CS:GO] GetRandomInt not working properly?
Reply With Quote #4

Quote:
Originally Posted by Indarello View Post
g_iCoin[client] = GetRandomInt(874,970);
g_iProfileRank[client] = GetRandomInt(1,40);
PrintToServer("[%d] [%N]", g_iCoin[client], client); //this is debug
With the debug I saw that every bot is getting a random number between 874 and 970 as intented but they all the same coin that the first bot got as a random.

Code:
[918] [[XeT]X-Tender]
[898] [[[MxD]]Azimuth]
[954] [Your_Baby]
[903] [killplz]
[947] [Tetra DemoN]
[907] [NiP dennis]
[906] [[SPI]LastMAnStanDINg]
[932] [[RAM]Tuna_Taco_2]
[930] [Data]
[892] [Shader_90]
[881] [Mdoziaa]
[935] [Wah-Wah Effect]
[917] [Astralis device]
[898] [NiP f0rest]
[926] [[[tiMmaH!]]RamboGunther1337]
[936] [Selcuk87]
The coin 918 is the DreamHack Cluj-Napoca 2015 CS:GO Finalist so every bot gets that one instead of giving the ones that are in brackets for every single bot.
manicogaming is offline
Mitchell
~lick~
Join Date: Mar 2010
Old 12-20-2018 , 11:34   Re: [CS:GO] GetRandomInt not working properly?
Reply With Quote #5

Have you tried this manually, maybe bots are different since they all have the same account/steamid.
Mitchell is offline
Indarello
Senior Member
Join Date: Nov 2015
Location: Russia
Old 12-20-2018 , 11:42   Re: [CS:GO] GetRandomInt not working properly?
Reply With Quote #6

With this debug you can find that another part of code is wrong, to fix you need to find yourself or give us more code

Last edited by Indarello; 12-20-2018 at 12:15.
Indarello is offline
eyal282
Veteran Member
Join Date: Aug 2011
Old 12-20-2018 , 11:50   Re: [CS:GO] GetRandomInt not working properly?
Reply With Quote #7

Use OnClientPostAdminCheck and ignore the client index completely, instead just loop all players.
__________________
I am available to make plugins for pay.

Discord: Eyal282#1334
eyal282 is offline
manicogaming
AlliedModders Donor
Join Date: Aug 2014
Old 12-20-2018 , 11:52   Re: [CS:GO] GetRandomInt not working properly?
Reply With Quote #8

Quote:
Originally Posted by Indarello View Post
With this debug you can find that anither part of code is wrong, to fix you need to find yourself or give us more code
Here's the full code of the plugin. Yes it is an edited version of the Level Ranks Fake Rank plugin.
Attached Files
File Type: sp Get Plugin or Get Source (levelsranks_fakerank.sp - 61 views - 5.0 KB)
manicogaming is offline
Indarello
Senior Member
Join Date: Nov 2015
Location: Russia
Old 12-20-2018 , 12:56   Re: [CS:GO] GetRandomInt not working properly?
Reply With Quote #9

g_iCoinOffset
I dont see where you get it
Indarello is offline
manicogaming
AlliedModders Donor
Join Date: Aug 2014
Old 12-20-2018 , 13:02   Re: [CS:GO] GetRandomInt not working properly?
Reply With Quote #10

Quote:
Originally Posted by Indarello View Post
g_iCoinOffset
I dont see where you get it
It's on the function OnMapStart
PHP Code:
g_iCoinOffset FindSendPropInfo("CCSPlayerResource""m_nActiveCoinRank"); 
manicogaming 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 00:43.


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