Raised This Month: $ Target: $400
 0% 

random_num(0,1) is ALWAYS 1


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
fmfs10
Senior Member
Join Date: Mar 2009
Location: Brasil
Old 04-16-2011 , 10:45   random_num(0,1) is ALWAYS 1
Reply With Quote #1

Hello! I've made a deathrun plugin for my server based on Deathrun Manager by xPaw

I did a function that happens in every new round, that gives 1 life to a random players, but giving a bigger chance to vips from my server to have this random life. Here is the code:

PHP Code:
// Random life to a player
stock random_life() {
    
    new 
bool:PlayerChecked
    
    
// Do a loop until it gets a player...
    
while(!PlayerChecked) {
        
        new 
iPlayers[32], Players
        get_players
iPlayersPlayers"c" );
        
        if(!
Players)     break
        
        new 
only_vips random_num(01)
        
        if(
only_vips) {
            
            new 
vip_id[33]
            new 
vip_slot = -1
            
            
for(new iPlayersi++) {
                
                if(
get_user_flags(iPlayers[i]) & ADMIN_RESERVATION) {
                    
vip_id[vip_slot+1] = iPlayers[i]
                    
vip_slot++
                }
            }
            
            if(
vip_slot != -1) {
                
                new 
vip_choosen random_num(0vip_slot+1)
                
                if(
is_user_connected(vip_id[vip_choosen])) {
                    
                    
g_Lifes[vip_id[vip_choosen]]++
                    
                    new 
name[64]
                    
get_user_name(vip_id[vip_choosen], name63)
                    
                    
set_hudmessage012800.040.7102.52.50.50.5);
                    
                    
// It shows (VIP) just for check if it was only_vips
                    // And it ALWAYS appear... lol
                    
ShowSyncHudMsgvip_id[vip_choosen], VidasHudSync2"%s ganhou uma vida extra! (VIP)"name);
                    
                    
PlayerChecked true
                
}
            }    
        }
        else {
            
            new 
Random_Player random_num(0Players-1)
            
            if(
is_user_connected(Random_Player)) {
                
                
g_Lifes[Random_Player]++
                
                new 
name[64]
                
get_user_name(Random_Playername63)
                
                
set_hudmessage012800.040.7102.52.50.50.5);
                
                
ShowSyncHudMsgRandom_PlayerVidasHudSync2"%s ganhou uma vida extra!"name);
                
                
PlayerChecked true
            
}
        }
    }
    

What's wrong with my code?
P.S.: I'm testing alone on my server...

Last edited by fmfs10; 04-16-2011 at 11:03.
fmfs10 is offline
 



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 20:11.


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