Thread: Bet
View Single Post
Nextra
Veteran Member
Join Date: Apr 2008
Location: Germany
Old 01-20-2010 , 14:23   Re: Bet v1.1
Reply With Quote #18

Quote:
Originally Posted by vilaemail View Post
-say bet can not be hooked. look here: http://forums.alliedmods.net/showthread.php?t=103434
-Team variable IS necessary because I am checking which team he placed bet on (not the team he is on!)
-Incorrect! I am checking FindOdds in sayBet only if user typed odds! But if he/she typed bet, findOdds will never be tested before the Bet function (if user typed odds the code will never enter Bet function). And I must test in Bet function because that's the only way to get the actual odds for betting!

Thanks for constructive comments, I hope for more of them in future.

Thank you all for translations!
- OK, sorry. I wasn't aware of that and figured it could be a proper optimization. Thats for clearing that up.
- No. You do not need it in the FindOdds function. See below to how you can change the function.
- You are right, I didn't look at the code too close here.

PHP Code:
    for (i=0i<playerCounti++)
    {
        
//player = Players[i]  - no need for this
        //team = cs_get_user_team(Players[i]) - no need for this either
        
switch(cs_get_user_team(Players[i]))
        {
            case 
CS_TEAM_T:
            {
                
aliveT++
            }
            case 
CS_TEAM_CT:
            {
                
aliveCT++
            }
        }
    } 
More suggestions (though minimal ones):
- You could use static arrays in the say function as it is called quite frequently.
- What purpose does the "critical" variable have? I do not see why it is necessary.
- In giveMoney you use id and player to hold the same variable. Remove one of them.
- Using equali you can remove strtolower on the arguments.
- There are some instances where you declare a variable and then assign it on the next line. You use both styles and you could decide on either doing it separately or on one line.
PHP Code:
new userMoney
userMoney 
cs_get_user_money(id)
// -->
new userMoney cs_get_user_money(id
__________________
In Flames we trust!
Nextra is offline