Random Numbers
Ok for my "weapon Jams" plugin im trying to make a random weapon jam function . but what I have seems to be crashing my server . any ideas whats wrong with this function here?
Code:
|
Re: Random Numbers
Everything look fine but I don't know why you did that above. Your just putting more use code into your plugin that you really don't need too. Checking if it the cvar is zero and returning. When you can do like below and remove unnecessary code.
I suggest you try loading up the AMX Mod X Bin Logger. It will tell you the exact line it crashed on. It a useful tool when debugging stuff too Code:
|
Re: Random Numbers
well the idea was that if the random cvars is 0 , which is the default , then not to run that function at all . other wise it will generate a random number between 0 and 200 the other cvar. so first it checks to see if there using the random function cvar , if they are and the number is not 0 , then it will generate a number. i found the problem that made it crash .
Code:
using only 1 = sign (assignemnt) made it crash , but its still not generating a random number any ideas ???:cry: |
Re: Random Numbers
try this and tell me
Code:
|
Re: Random Numbers
i didn't mean to bump but when u try editing a post with a small tags it will goes screwed up..anyways thats not the point if that didn't work try switchin from random_float to random_num and leaving the pcvars on floarts and then try doing the oppiste
|
Re: Random Numbers
yes i know the psots are very weird when you try to edit it ends up a very weird code . lol . np . :) but if the cvars are both integers why try them as flaots ? here let me show my whole code LOL
Code:
|
Re: Random Numbers
g_iRatio == random_num(get_pcvar_num(g_iRandom),get_pcvar _num(g_iRatio));
to g_iRatio = random_num(get_pcvar_num(g_iRandom),get_pcvar _num(g_iRatio)); |
Re: Random Numbers
also when you check a value if equals zero. you don't need to "if(a==0)" just"if(!a)"
|
Re: Random Numbers
no that was the first way i did it . with 2 == instead of 1 . and it crashed my server . then i took it out and 2 worked but didnt generate a radnom number :cry:
|
Re: Random Numbers
It's stupid that you're not following teame06's advice. While it doesn't make too much of a performance difference, logic would dictate you do it the way teame06 advised. If nothing else, it looks a hell of a lot cleaner his way.
|
| All times are GMT -4. The time now is 06:49. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.