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

Solved How to get random number?


Post New Thread Reply   
 
Thread Tools Display Modes
MihaiGamerXD
Member
Join Date: Aug 2018
Old 12-05-2018 , 13:09   Re: How to get random number?
Reply With Quote #11

I just found from Zombie Plague Crazy Night plugin, but I don't understand somewhere.
What is "start_mode" or something like that? It doesn't exist!

Last edited by MihaiGamerXD; 12-05-2018 at 13:09.
MihaiGamerXD is offline
MihaiGamerXD
Member
Join Date: Aug 2018
Old 12-05-2018 , 14:36   Re: How to get random number?
Reply With Quote #12

Anyway...
Still doesn't work if I don't know how to get random num! But if you'll help me for other ideas, it will work!
As just as I tried:

PHP Code:
public round_started() {
    new 
id get_random_player("a")
    if (
random_num(1,3) == 1)
        
INFECTION true
    
else if (random_num(1,3) == 2)
        
NEMESIS true
    
else if (random_num(1,3) == 3)
        
ASSASSIN true
    
if (INFECTION == true) {
        
//Do something for infection
    
}
    else if (
NEMESIS == true) {
        
//Do something for nemesis
    
}
    else if (
ASSASSIN == true) {
        
//Do something for assassin
    
}


Last edited by MihaiGamerXD; 12-05-2018 at 14:36.
MihaiGamerXD is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 12-05-2018 , 18:01   Re: How to get random number?
Reply With Quote #13

Here is a working example:
PHP Code:
#include <amxmodx>

enum Modes
{
     
Infection,
     
Nemesis,
     
Assassin
}

new const 
g_szModesModes ][] = 
{
    
"Infection",
    
"Nemesis",
    
"Assassin"
};

new 
Modes:g_Mode;

public 
plugin_init() 
{
    
g_Mode Modes:random_:Modes );  
    
    
server_print"Random mode is %s" g_szModesg_Mode ] );

__________________
Bugsy is offline
MihaiGamerXD
Member
Join Date: Aug 2018
Old 12-06-2018 , 14:25   Re: How to get random number?
Reply With Quote #14

Yes, but still doesn't work! As you say:

PHP Code:
public new_round() {
    new 
mapname[32]
    
get_mapname(mapname,31)
    if (
equal(mapname,"redswar_zm")) {
        new 
id get_random_player("a")
        
g_mode Modes:random(_:Modes)
        if (
g_mode == INFECTION) {
            
zombie[id] = true
            nemesis
[id] = false
            assassin
[id] = false
            cs_set_user_team
(id,CS_TEAM_T)
            
strip_user_weapons(id)
            
give_item(id,"waepon_knife")
            
set_user_health(id,500)
            
set_user_maxspeed(id,320.0)
            
client_cmd(id,"stopsound")
            
client_cmd(id,"spk %s",zombie_music)
        }
        else if (
g_mode == NEMESIS) {
            
zombie[id] = false
            nemesis
[id] = true
            assassin
[id] = false
            cs_set_user_team
(id,CS_TEAM_T)
            
strip_user_weapons(id)
            
give_item(id,"waepon_knife")
            
set_user_health(id,10000)
            
set_user_maxspeed(id,160.0)
            
client_cmd(id,"stopsound")
            
client_cmd(id,"spk %s",zombie_music)
        }
        else if (
g_mode == ASSASSIN) {
            
zombie[id] = false
            nemesis
[id] = false
            assassin
[id] = true
            cs_set_user_team
(id,CS_TEAM_T)
            
strip_user_weapons(id)
            
give_item(id,"waepon_knife")
            
set_user_health(id,5000)
            
set_user_maxspeed(id,1280.0)
            
client_cmd(id,"stopsound")
            
client_cmd(id,"spk %s",assassin_music)
        }
        new 
iPlayers[32], iNumiPlayer;
        
get_players(iPlayersiNum"a")
        for (new 
0iNumi++) {
            
iPlayer iPlayers[i]
            if (
iPlayer != id) {
                
set_user_maxspeed(iPlayer,320.0)
                
cs_set_user_team(iPlayer,CS_TEAM_CT)
                
zombie[iPlayer] = false
                nemesis
[iPlayer] = false
                assassin
[iPlayer] = false
            
}
        }
    }

MihaiGamerXD is offline
CrazY.
Veteran Member
Join Date: May 2015
Location: SP, Brazil
Old 12-06-2018 , 15:13   Re: How to get random number?
Reply With Quote #15

You should specify what is not working. Debug your code.
__________________









Last edited by CrazY.; 12-06-2018 at 15:14.
CrazY. is offline
MihaiGamerXD
Member
Join Date: Aug 2018
Old 12-07-2018 , 14:17   Re: How to get random number?
Reply With Quote #16

Sorry again, but the problem was at here:
PHP Code:
if (!zombie[iPlayer] || !nemesis[iPlayer] || !assassin[iPlayer]) 
must be changed to
PHP Code:
if (!zombie[iPlayer] && !nemesis[iPlayer] && !assassin[iPlayer]) 
so I was wrong again and again! I think I was noob at it! Isn't it?
MihaiGamerXD is offline
CrazY.
Veteran Member
Join Date: May 2015
Location: SP, Brazil
Old 12-07-2018 , 14:48   Re: How to get random number?
Reply With Quote #17

I don't see where that is related to last post you did.
__________________








CrazY. is offline
MihaiGamerXD
Member
Join Date: Aug 2018
Old 12-08-2018 , 05:19   Re: How to get random number?
Reply With Quote #18

Quote:
Originally Posted by CrazY. View Post
I don't see where that is related to last post you did.
Go to the previous post! You'll see here! If you can't find it, go to the previous page, find somewhere!

Last edited by MihaiGamerXD; 12-08-2018 at 05:20.
MihaiGamerXD 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 21:57.


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