Raised This Month: $32 Target: $400
 8% 

Solved How to get random number?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
MihaiGamerXD
Member
Join Date: Aug 2018
Old 12-03-2018 , 07:49   How to get random number?
Reply With Quote #1

Hello again, and I wanted to get random players from 1 to 3!
Example:
PHP Code:
new assassin_modenemesis_modeinfection_mode;
new 
g_mode random(3);
if (
g_mode == 1)
    
infection_mode true
if (g_mode == 2)
    
nemesis_mode true
if (g_mode == 3)
    
assassin_mode true 
I wanted to get random number for "random mode"!
Any ideas?

Last edited by MihaiGamerXD; 12-08-2018 at 05:18.
MihaiGamerXD is offline
Jess98
Junior Member
Join Date: Apr 2018
Old 12-03-2018 , 08:45   Re: How to get random number?
Reply With Quote #2

I think you should use the native named "random_num()" from amxmodx module. For an example;

Code:
new g_mode = random_num(1, 3)

if(random_num(1, 3) == 1)
{
     infection_mode = true 
}
else if(random_num(1, 3) == 2)
{
     nemesis_mode = true
}
else if(random_num(1, 3) == 3)
{
     assassin_mode = true  
}
1 = Minimum Value
3 = Maximum Value

Last edited by Jess98; 12-03-2018 at 08:47. Reason: Fixed a clerical error
Jess98 is offline
edon1337
Penguin Enthusiast
Join Date: Jun 2016
Location: Macedonia
Old 12-03-2018 , 09:01   Re: How to get random number?
Reply With Quote #3

PHP Code:
//// GLOBAL /////
enum
{
    
INFECTION 0,
    
NEMESIS,
    
ASSASSIN
}

new 
g_iMode;
////////////////////

new iRandomNum random_num1);

switch( 
iRandomNum )
{
    case 
1:
    {
        
g_iMode INFECTION;
    }

    case 
2:
    {
        
g_iMode NEMESIS:
    }

    case 
3:
    {
        
g_iMode ASSASSIN;
    }

__________________

Last edited by edon1337; 12-03-2018 at 09:02.
edon1337 is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 12-03-2018 , 09:30   Re: How to get random number?
Reply With Quote #4

Can do something like this:
PHP Code:
enum Modes
{
     
Infection,
     
Nemesis,
     
Assassin
}

new 
Modes:g_Mode;

g_Mode Modes:random_:Modes ); 
__________________

Last edited by Bugsy; 12-03-2018 at 09:30.
Bugsy is offline
MihaiGamerXD
Member
Join Date: Aug 2018
Old 12-03-2018 , 11:31   Re: How to get random number?
Reply With Quote #5

Nothing worked?! Oh my gosh! It looks like it's because of something...
Full code:
PHP Code:
/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <amxmisc>
#include <hamsandwich>
#include <fun>
#include <cstrike>
#include <fakemeta>

#define MAX_PLAYERS 32

const DMG_HEGRENADE = (1<<24)

new 
yourpoint[MAX_PLAYERS+1]

static 
zombie[33]
static 
nemesis[33]
static 
assassin[33]
static 
angry[33]

enum
{
    
INFECTION 0,
    
NEMESIS,
    
ASSASSIN
}

new 
g_mode

new timeleft

static spawn_start[33]

static 
spawn_music[33]

static 
scoremode[33]

new 
bird_point 0;
new 
pig_point 0;
new 
bird_score 0;
new 
pig_score 0;

new 
win_mode 0;

new const 
bird_music[] = "redswar/music/bird_respawn.wav"
new const pig_music[] = "redswar/music/pig_respawn.wav"
new const vip_music[] = "redswar/music/vip_respawn.wav"
new const zombie_music[] = "redswar/music/zombie_respawn.wav"
new const bird_winner[] = "redswar/music/bird_winner.wav"
new const pig_winner[] = "redswar/music/pig_winner.wav"
new const vip_winner[] = "redswar/music/vip_winner.wav"
new const zombie_winner[] = "redswar/music/zombie_winner.wav"
new const bird_levelup[] = "redswar/music/bird_levelup.wav"
new const pig_levelup[] = "redswar/music/pig_levelup.wav"
new const vip_levelup[] = "redswar/music/vip_levelup.wav"
new const zombie_levelup[] = "redswar/music/zombie_levelup.wav"
new const assassin_music[] = "redswar/music/assassin_mode.wav"
new const nine[] = "redswar/voices/9.wav"
new const eight[] = "redswar/voices/8.wav"
new const seven[] = "redswar/voices/7.wav"
new const six[] = "redswar/voices/6.wav"
new const five[] = "redswar/voices/5.wav"
new const four[] = "redswar/voices/4.wav"
new const three[] = "redswar/voices/3.wav"
new const two[] = "redswar/voices/2.wav"
new const one[] = "redswar/voices/1.wav"
new const bird_model[] = "models/player/redswar_bird/redswar_bird.mdl"
new const pig_model[] = "models/player/redswar_pig/redswar_pig.mdl"
new const vip_model[] = "models/player/redswar_vip/redswar_vip.mdl"
new const zombie_model[] = "models/player/redswar_zombie/redswar_zombie.mdl"
new const nemesis_model[] = "models/player/redswar_nemesis/redswar_nemesis.mdl"
new const assassin_model[] = "models/player/redswar_assassin/redswar_assassin.mdl"

public plugin_precache() {
    
precache_sound(bird_music)
    
precache_sound(pig_music)
    
precache_sound(vip_music)
    
precache_sound(zombie_music)
    
precache_sound(bird_winner)
    
precache_sound(pig_winner)
    
precache_sound(vip_winner)
    
precache_sound(zombie_winner)
    
precache_sound(bird_levelup)
    
precache_sound(pig_levelup)
    
precache_sound(vip_levelup)
    
precache_sound(zombie_levelup)
    
precache_sound(assassin_music)
    
precache_sound(nine)
    
precache_sound(eight)
    
precache_sound(seven)
    
precache_sound(six)
    
precache_sound(five)
    
precache_sound(four)
    
precache_sound(three)
    
precache_sound(two)
    
precache_sound(one)
    
precache_model(bird_model)
    
precache_model(pig_model)
    
precache_model(vip_model)
    
precache_model(zombie_model)
    
precache_model(nemesis_model)
    
precache_model(assassin_model)
}

public 
plugin_init() {
    
register_plugin("Red's War""1.0""MihaiGamerXD")
    
set_task(1.0,"time_count",0,"",0,"b")
    
RegisterHam(Ham_Spawn"player""fwHamPlayerSpawnPost"1)
    
RegisterHam(Ham_Touch"armoury_entity""onPickUp")
    
RegisterHam(Ham_Touch"weaponbox""onPickUp")
    
RegisterHam(Ham_Touch"weapon_shield""onPickUp")
    
RegisterHam(Ham_TakeDamage"player""onDamage")
    
RegisterHam(Ham_Use"func_tank""onUse")
    
register_event("DeathMsg","onDeath","a")
    
register_event("30","TheEnd","a")
    
register_event("HLTV""event_new_round""a""1=0""2=0")
    
register_logevent("Bird_Win",6,"3=CTs_Win")
    
register_logevent("Pig_Win",6,"3=Terrorists_Win")
    
register_logevent("Bomb_Exploded",6,"3=Target_Bombed")
    
register_logevent("Hostages_Rescued",6,"3=All_Hostages_Rescued")
    
register_logevent("Hostages_Lost",6,"3=Hostages_Not_Rescued")
    
register_logevent("VIP_Dead",6,"3=VIP_Assassinated")
    
register_logevent("VIP_Lost",6,"3=VIP_Not_Escaped")
    
register_logevent("Team_Events"3"1=triggered")
    
register_logevent("onRoundEnd",2,"1=Round_End")
    
set_task(0.1,"RW_M",0,"",0,"b")
    
set_task(0.1,"ChangeTeam",0,"",0,"b")
}

public 
ChangeTeam() {
    new 
mapname[32]
    
get_mapname(mapname,31)
    if (
equal(mapname,"redswar_zm")) {
        new 
iPlayers[32], iNumiPlayer;
        
get_players(iPlayersiNum"ae","TERRORIST")
        for (new 
0iNumi++) {
            
iPlayer iPlayers[i]
            if (!
zombie[iPlayer] || !nemesis[iPlayer] || !assassin[iPlayer]) {
                
cs_set_user_team(iPlayerCS_TEAM_CT)
            }
        }
    }
}

public 
plugin_cfg() 

    
register_message(get_user_msgid("StatusIcon"), "Message_StatusIcon");
}

public 
Message_StatusIcon(iMsgIdiMsgDestid

    static 
szIcon[8]; 
    
get_msg_arg_string(2szIconcharsmax(szIcon)); 
    if( 
equal(szIcon"buyzone") )
    { 
        if( 
get_msg_arg_int(1) ) 
        { 
            
set_pdata_int(id235get_pdata_int(id235) & ~(1<<0));
            return 
PLUGIN_HANDLED
        } 
    } 
     
    return 
PLUGIN_CONTINUE
}

public 
onPickUp(entityid) {
    new 
mapname[32]
    
get_mapname(mapname,31)
    if (
equal(mapname,"redswar_zm")) {
        if (!
is_user_alive(id))
            return 
HAM_IGNORED;
        
        if (
zombie[id] || nemesis[id])
            return 
HAM_SUPERCEDE;
        
    }
    return 
HAM_IGNORED;
}

public 
onUse(thisidcalleridactivator)
{
    new 
mapname[32]
    
get_mapname(mapname,31)
    if (
equal(mapname,"redswar_zm")) {
        if (!
is_user_alive(idactivator))
            return 
HAM_IGNORED;
        
        if (
zombie[idactivator] || nemesis[idactivator])
            return 
HAM_SUPERCEDE;
        
    }
    return 
HAM_IGNORED;
}

public 
RW_M() {
    new 
iPlayers[32], iNumiPlayer;
    
get_players(iPlayers,iNum,"a")
    for (new 
0iNumi++) {
        
iPlayer iPlayers[i]
        if (
is_user_alive(iPlayer)) {
            new 
mapname[32]
            
get_mapname(mapname,31)
            if (
equal(mapname,"redswar_zm")) {
                if (
cs_get_user_team(iPlayer) == CS_TEAM_CT) {
                    
cs_set_user_model(iPlayer,"redswar_bird")
                }
                else if (
cs_get_user_team(iPlayer) == CS_TEAM_T) {
                    if (
zombie[iPlayer])
                        
cs_set_user_model(iPlayer,"redswar_zombie")
                    else if (
nemesis[iPlayer])
                        
cs_set_user_model(iPlayer,"redswar_nemesis")
                    else if (
assassin[iPlayer])
                        
cs_set_user_model(iPlayer,"redswar_assassin")
                }
            }
            else {
                if (
cs_get_user_team(iPlayer) == CS_TEAM_CT) {
                    if (
cs_get_user_vip(iPlayer)) {
                        
cs_set_user_model(iPlayer,"redswar_vip")
                    }
                    else {
                        
cs_set_user_model(iPlayer,"redswar_bird")
                    }
                }
                else if (
cs_get_user_team(iPlayer) == CS_TEAM_T) {
                    
cs_set_user_model(iPlayer,"redswar_pig")
                }
            }
        }
    }
}

public 
onRoundEnd() {
    new 
mapname[32]
    
get_mapname(mapname,31)
    if (
equali(mapname,"redswar_tdm")) {
        new 
id[32], numtarget
        get_players
(id,num,"ch")
        for (new 
0numi++) {
            
target id[i]
            
client_print(target,print_chat,"[Red's War] Something's wrong! The Round is over in Team Deathmatch Mode!")
        }
    }
}

public 
time_count() {
    new 
id[32], numtarget;
    
get_players(id,num,"ch")
    for (new 
0numi++) {
        
target id[i]
        if (!
scoremode[target]) {
            new 
mapname[32]
            
get_mapname(mapname,31)
            if (
equal(mapname,"redswar_tdm")) {
                
timeleft get_timeleft()
                
set_hudmessage(2552550, -1.00.0101.01.00.10.9)
                
show_hudmessage(target"Timeleft: %d:%02d", (timeleft/60),(timeleft%60))
                if (
timeleft == 9) {
                    
client_cmd(target,"spk %s"nine)
                }
                if (
timeleft == 8) {
                    
client_cmd(target,"spk %s"eight)
                }
                if (
timeleft == 7) {
                    
client_cmd(target,"spk %s"seven)
                }
                if (
timeleft == 6) {
                    
client_cmd(target,"spk %s"six)
                }
                if (
timeleft == 5) {
                    
client_cmd(target,"spk %s"five)
                }
                if (
timeleft == 4) {
                    
client_cmd(target,"spk %s"four)
                }
                if (
timeleft == 3) {
                    
client_cmd(target,"spk %s"three)
                }
                if (
timeleft == 2) {
                    
client_cmd(target,"spk %s"two)
                }
                if (
timeleft == 1) {
                    
client_cmd(target,"spk %s"one)
                }
            }
        }
    }
}

public 
onDamage(victiminflictorattackerFloat:damagedmg_bits) {
    if (
dmg_bits DMG_FALL || (dmg_bits DMG_HEGRENADE && victim == attacker))
        return 
HAM_SUPERCEDE;
    
    new 
mapname[32]
    
get_mapname(mapname,31)
    if (
equal(mapname,"redswar_zm")) {
        if (
zombie[attacker] && !zombie[victim]) {
            if (
get_birds() == 1)
                return 
HAM_IGNORED;
            
            
zombie[victim] = true
            cs_set_user_team
(victim,CS_TEAM_T)
            
strip_user_weapons(victim)
            
give_item(victim,"weapon_knife")
            
set_user_health(victim,500)
            if (
is_user_alive(attacker)) {
                
yourpoint[attacker] += 1
                
new iAmount get_user_frags(attacker)+1
                set_user_frags
(attacker,iAmount)
                if (
yourpoint[attacker] == 10) {
                    if (
cs_get_user_team(attacker) == CS_TEAM_T) {
                        
scoremode[attacker] = true
                        client_cmd
(attacker,"stopsound")
                        
client_cmd(attacker,"spk %s",zombie_levelup)
                        
set_hudmessage(02550, -1.00.5500.54.0)
                        
show_hudmessage(attacker"10 Infects!!!")
                        
set_task(4.0,"stop_score_mode",attacker,"",0,"a",1)
                    }
                }
                if (
yourpoint[attacker] == 20) {
                    if (
cs_get_user_team(attacker) == CS_TEAM_T) {
                        
scoremode[attacker] = true
                        client_cmd
(attacker,"stopsound")
                        
client_cmd(attacker,"spk %s",zombie_levelup)
                        
set_hudmessage(02550, -1.00.5500.54.0)
                        
show_hudmessage(attacker"20 Infects!!!")
                        
set_task(4.0,"stop_score_mode",attacker,"",0,"a",1)
                    }
                }
                if (
yourpoint[attacker] == 40) {
                    if (
cs_get_user_team(attacker) == CS_TEAM_T) {
                        
scoremode[attacker] = true
                        client_cmd
(attacker,"stopsound")
                        
client_cmd(attacker,"spk %s",zombie_levelup)
                        
set_hudmessage(02550, -1.00.5500.54.0)
                        
show_hudmessage(attacker"40 Infects!!!")
                        
set_task(4.0,"stop_score_mode",attacker,"",0,"a",1)
                    }
                }
                if (
yourpoint[attacker] == 80) {
                    if (
cs_get_user_team(attacker) == CS_TEAM_T) {
                        
scoremode[attacker] = true
                        client_cmd
(attacker,"stopsound")
                        
client_cmd(attacker,"spk %s",zombie_levelup)
                        
set_hudmessage(02550, -1.00.5500.54.0)
                        
show_hudmessage(attacker"80 Infects!!!")
                        
set_task(4.0,"stop_score_mode",attacker,"",0,"a",1)
                    }
                }
            }
            
            return 
HAM_SUPERCEDE;
        }
        else if (
nemesis[attacker] || assassin[attacker]) {
            if (!
angry[victim])
                
user_kill(victim)
            
            if (
is_user_alive(attacker)) {
                
yourpoint[attacker] += 1
                
new iAmount get_user_frags(attacker)+1
                set_user_frags
(attacker,iAmount)
                if (
yourpoint[attacker] == 10) {
                    if (
cs_get_user_team(attacker) == CS_TEAM_T) {
                        
scoremode[attacker] = true
                        client_cmd
(attacker,"stopsound")
                        
client_cmd(attacker,"spk %s",zombie_levelup)
                        
set_hudmessage(02550, -1.00.5500.54.0)
                        
show_hudmessage(attacker"10 Kills!!!")
                        
set_task(4.0,"stop_score_mode",attacker,"",0,"a",1)
                    }
                }
                if (
yourpoint[attacker] == 20) {
                    if (
cs_get_user_team(attacker) == CS_TEAM_T) {
                        
scoremode[attacker] = true
                        client_cmd
(attacker,"stopsound")
                        
client_cmd(attacker,"spk %s",zombie_levelup)
                        
set_hudmessage(02550, -1.00.5500.54.0)
                        
show_hudmessage(attacker"20 Kills!!!")
                        
set_task(4.0,"stop_score_mode",attacker,"",0,"a",1)
                    }
                }
                if (
yourpoint[attacker] == 40) {
                    if (
cs_get_user_team(attacker) == CS_TEAM_T) {
                        
scoremode[attacker] = true
                        client_cmd
(attacker,"stopsound")
                        
client_cmd(attacker,"spk %s",zombie_levelup)
                        
set_hudmessage(02550, -1.00.5500.54.0)
                        
show_hudmessage(attacker"40 Kills!!!")
                        
set_task(4.0,"stop_score_mode",attacker,"",0,"a",1)
                    }
                }
                if (
yourpoint[attacker] == 80) {
                    if (
cs_get_user_team(attacker) == CS_TEAM_T) {
                        
scoremode[attacker] = true
                        client_cmd
(attacker,"stopsound")
                        
client_cmd(attacker,"spk %s",zombie_levelup)
                        
set_hudmessage(02550, -1.00.5500.54.0)
                        
show_hudmessage(attacker"80 Kills!!!")
                        
set_task(4.0,"stop_score_mode",attacker,"",0,"a",1)
                    }
                }
            }
        }
    }
    
    return 
HAM_IGNORED;
}

public 
onDeath() {
    new 
iKiller read_data(1)
    new 
iVictim read_data(2)
    new 
mapname[32]
    
get_mapname(mapname,31)
    if (
equal(mapname,"redswar_tdm") || equal(mapname,"redswar_bd") || equal(mapname,"redswar_hr") || equal(mapname,"redswar_vip")) {
        if (
iKiller && iVictim && iKiller != iVictim) {
            if (
is_user_alive(iKiller)) {
                if (
cs_get_user_team(iKiller) == CS_TEAM_CT) {
                    
bird_point++
                }
                else if (
cs_get_user_team(iKiller) == CS_TEAM_T) {
                    
pig_point++
                }
                
yourpoint[iKiller] += 1
                
if (yourpoint[iKiller] == 10) {
                    if (
cs_get_user_team(iKiller) == CS_TEAM_CT) {
                        if (
cs_get_user_vip(iKiller)) {
                            
scoremode[iKiller] = true
                            client_cmd
(iKiller,"stopsound")
                            
client_cmd(iKiller,"spk %s",vip_levelup)
                            
set_hudmessage(00255, -1.00.5500.54.0)
                            
show_hudmessage(iKiller"10 Kills!!!")
                            
set_task(4.0,"stop_score_mode",iKiller,"",0,"a",1)
                        }
                        else {
                            
scoremode[iKiller] = true
                            client_cmd
(iKiller,"stopsound")
                            
client_cmd(iKiller,"spk %s",bird_levelup)
                            
set_hudmessage(25500, -1.00.5500.54.0)
                            
show_hudmessage(iKiller"10 Kills!!!")
                            
set_task(4.0,"stop_score_mode",iKiller,"",0,"a",1)
                        }
                    }
                    else if (
cs_get_user_team(iKiller) == CS_TEAM_T) {
                        
scoremode[iKiller] = true
                        client_cmd
(iKiller,"stopsound")
                        
client_cmd(iKiller,"spk %s",pig_levelup)
                        
set_hudmessage(02550, -1.00.5500.53.0)
                        
show_hudmessage(iKiller"10 Kills!!!")
                        
set_task(3.0,"stop_score_mode",iKiller,"",0,"a",1)
                    }
                }
                if (
yourpoint[iKiller] == 20) {
                    if (
cs_get_user_team(iKiller) == CS_TEAM_CT) {
                        if (
cs_get_user_vip(iKiller)) {
                            
scoremode[iKiller] = true
                            client_cmd
(iKiller,"stopsound")
                            
client_cmd(iKiller,"spk %s",vip_levelup)
                            
set_hudmessage(00255, -1.00.5500.54.0)
                            
show_hudmessage(iKiller"20 Kills!!!")
                            
set_task(4.0,"stop_score_mode",iKiller,"",0,"a",1)
                        }
                        else {
                            
scoremode[iKiller] = true
                            client_cmd
(iKiller,"stopsound")
                            
client_cmd(iKiller,"spk %s",bird_levelup)
                            
set_hudmessage(25500, -1.00.5500.54.0)
                            
show_hudmessage(iKiller"20 Kills!!!")
                            
set_task(4.0,"stop_score_mode",iKiller,"",0,"a",1)
                        }
                    }
                    else if (
cs_get_user_team(iKiller) == CS_TEAM_T) {
                        
scoremode[iKiller] = true
                        client_cmd
(iKiller,"stopsound")
                        
client_cmd(iKiller,"spk %s",pig_levelup)
                        
set_hudmessage(02550, -1.00.5500.53.0)
                        
show_hudmessage(iKiller"20 Kills!!!")
                        
set_task(3.0,"stop_score_mode",iKiller,"",0,"a",1)
                    }
                }
                if (
yourpoint[iKiller] == 40) {
                    if (
cs_get_user_team(iKiller) == CS_TEAM_CT) {
                        if (
cs_get_user_vip(iKiller)) {
                            
scoremode[iKiller] = true
                            client_cmd
(iKiller,"stopsound")
                            
client_cmd(iKiller,"spk %s",vip_levelup)
                            
set_hudmessage(00255, -1.00.5500.54.0)
                            
show_hudmessage(iKiller"40 Kills!!!")
                            
set_task(4.0,"stop_score_mode",iKiller,"",0,"a",1)
                        }
                        else {
                            
scoremode[iKiller] = true
                            client_cmd
(iKiller,"stopsound")
                            
client_cmd(iKiller,"spk %s",bird_levelup)
                            
set_hudmessage(25500, -1.00.5500.54.0)
                            
show_hudmessage(iKiller"40 Kills!!!")
                            
set_task(4.0,"stop_score_mode",iKiller,"",0,"a",1)
                        }
                    }
                    else if (
cs_get_user_team(iKiller) == CS_TEAM_T) {
                        
scoremode[iKiller] = true
                        client_cmd
(iKiller,"stopsound")
                        
client_cmd(iKiller,"spk %s",pig_levelup)
                        
set_hudmessage(02550, -1.00.5500.53.0)
                        
show_hudmessage(iKiller"40 Kills!!!")
                        
set_task(3.0,"stop_score_mode",iKiller,"",0,"a",1)
                    }
                }
                if (
yourpoint[iKiller] == 80) {
                    if (
cs_get_user_team(iKiller) == CS_TEAM_CT) {
                        if (
cs_get_user_vip(iKiller)) {
                            
scoremode[iKiller] = true
                            client_cmd
(iKiller,"stopsound")
                            
client_cmd(iKiller,"spk %s",vip_levelup)
                            
set_hudmessage(00255, -1.00.5500.54.0)
                            
show_hudmessage(iKiller"80 Kills!!!")
                            
set_task(4.0,"stop_score_mode",iKiller,"",0,"a",1)
                        }
                        else {
                            
scoremode[iKiller] = true
                            client_cmd
(iKiller,"stopsound")
                            
client_cmd(iKiller,"spk %s",bird_levelup)
                            
set_hudmessage(25500, -1.00.5500.54.0)
                            
show_hudmessage(iKiller"80 Kills!!!")
                            
set_task(4.0,"stop_score_mode",iKiller,"",0,"a",1)
                        }
                    }
                    else if (
cs_get_user_team(iKiller) == CS_TEAM_T) {
                        
scoremode[iKiller] = true
                        client_cmd
(iKiller,"stopsound")
                        
client_cmd(iKiller,"spk %s",pig_levelup)
                        
set_hudmessage(02550, -1.00.5500.53.0)
                        
show_hudmessage(iKiller"80 Kills!!!")
                        
set_task(3.0,"stop_score_mode",iKiller,"",0,"a",1)
                    }
                }
            }
        }
    }
    else if (
equal(mapname,"redswar_zm")) {
        if (
iKiller && iVictim && iKiller != iVictim) {
            if (
is_user_alive(iKiller)) {
                
yourpoint[iKiller] += 1
                
if (yourpoint[iKiller] == 10) {
                    if (
cs_get_user_team(iKiller) == CS_TEAM_CT) {
                        
scoremode[iKiller] = true
                        client_cmd
(iKiller,"stopsound")
                        
client_cmd(iKiller,"spk %s",bird_levelup)
                        
set_hudmessage(25500, -1.00.5500.54.0)
                        
show_hudmessage(iKiller"10 Kills!!!")
                        
set_task(4.0,"stop_score_mode",iKiller,"",0,"a",1)
                    }
                    else if (
cs_get_user_team(iKiller) == CS_TEAM_T) {
                        
scoremode[iKiller] = true
                        client_cmd
(iKiller,"stopsound")
                        
client_cmd(iKiller,"spk %s",zombie_levelup)
                        
set_hudmessage(02550, -1.00.5500.54.0)
                        
show_hudmessage(iKiller"10 Kills!!!")
                        
set_task(4.0,"stop_score_mode",iKiller,"",0,"a",1)
                    }
                }
                if (
yourpoint[iKiller] == 20) {
                    if (
cs_get_user_team(iKiller) == CS_TEAM_CT) {
                        
scoremode[iKiller] = true
                        client_cmd
(iKiller,"stopsound")
                        
client_cmd(iKiller,"spk %s",bird_levelup)
                        
set_hudmessage(25500, -1.00.5500.54.0)
                        
show_hudmessage(iKiller"20 Kills!!!")
                        
set_task(4.0,"stop_score_mode",iKiller,"",0,"a",1)
                    }
                    else if (
cs_get_user_team(iKiller) == CS_TEAM_T) {
                        
scoremode[iKiller] = true
                        client_cmd
(iKiller,"stopsound")
                        
client_cmd(iKiller,"spk %s",zombie_levelup)
                        
set_hudmessage(02550, -1.00.5500.54.0)
                        
show_hudmessage(iKiller"20 Kills!!!")
                        
set_task(4.0,"stop_score_mode",iKiller,"",0,"a",1)
                    }
                }
                if (
yourpoint[iKiller] == 40) {
                    if (
cs_get_user_team(iKiller) == CS_TEAM_CT) {
                        
scoremode[iKiller] = true
                        client_cmd
(iKiller,"stopsound")
                        
client_cmd(iKiller,"spk %s",bird_levelup)
                        
set_hudmessage(25500, -1.00.5500.54.0)
                        
show_hudmessage(iKiller"40 Kills!!!")
                        
set_task(4.0,"stop_score_mode",iKiller,"",0,"a",1)
                    }
                    else if (
cs_get_user_team(iKiller) == CS_TEAM_T) {
                        
scoremode[iKiller] = true
                        client_cmd
(iKiller,"stopsound")
                        
client_cmd(iKiller,"spk %s",zombie_levelup)
                        
set_hudmessage(02550, -1.00.5500.54.0)
                        
show_hudmessage(iKiller"40 Kills!!!")
                        
set_task(4.0,"stop_score_mode",iKiller,"",0,"a",1)
                    }
                }
                if (
yourpoint[iKiller] == 80) {
                    if (
cs_get_user_team(iKiller) == CS_TEAM_CT) {
                        
scoremode[iKiller] = true
                        client_cmd
(iKiller,"stopsound")
                        
client_cmd(iKiller,"spk %s",bird_levelup)
                        
set_hudmessage(25500, -1.00.5500.54.0)
                        
show_hudmessage(iKiller"80 Kills!!!")
                        
set_task(4.0,"stop_score_mode",iKiller,"",0,"a",1)
                    }
                    else if (
cs_get_user_team(iKiller) == CS_TEAM_T) {
                        
scoremode[iKiller] = true
                        client_cmd
(iKiller,"stopsound")
                        
client_cmd(iKiller,"spk %s",zombie_levelup)
                        
set_hudmessage(02550, -1.00.5500.54.0)
                        
show_hudmessage(iKiller"80 Kills!!!")
                        
set_task(4.0,"stop_score_mode",iKiller,"",0,"a",1)
                    }
                }
            }
        }
    }
}

public 
event_new_round() {
    new 
id[32], numtarget
    get_players
(id,num,"ch")
    for (new 
0numi++) {
        
target id[i]
        
spawn_start[target] = true
        win_mode 
0
    
}
    
set_task(0.1,"ZombieTime")
    
set_task(5.0,"CheckNemesis",0,"",0,"b")
}

public 
ZombieTime() {
    new 
mapname[32]
    
get_mapname(mapname,31)
    if (
equal(mapname,"redswar_zm")) {
        new 
id get_random_player("a")
        new 
RandomNum random_num(1,3)
        switch (
RandomNum)
        {
            case 
1:
            {
                
g_mode INFECTION;
            }
            
            case 
2:
            {
                
g_mode NEMESIS;
            }
            
            case 
3:
            {
                
g_mode ASSASSIN;
            }
        }
        if (
g_mode == INFECTION) {
            
zombie[id] = true
            cs_set_user_team
(id,CS_TEAM_T)
            
strip_user_weapons(id)
            
give_item(id,"weapon_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) {
            
nemesis[id] = true
            cs_set_user_team
(id,CS_TEAM_T)
            
strip_user_weapons(id)
            
give_item(id,"weapon_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) {
            
assassin[id] = true
            cs_set_user_team
(id,CS_TEAM_T)
            
strip_user_weapons(id)
            
give_item(id,"weapon_knife")
            
set_user_health(id,5000)
            
set_user_maxspeed(id,1280.0)
            
client_cmd(0,"stopsound")
            
client_cmd(0,"spk %s",assassin_music)
        }
        new 
iPlayers[32], iNumiPlayer;
        
get_players(iPlayersiNum"a")
        for (new 
0iNumi++) {
            
iPlayer iPlayers[i]
            if (
iPlayer != id) {
                
zombie[iPlayer] = false
                nemesis
[iPlayer] = false
                assassin
[iPlayer] = false
                angry
[iPlayer] = false
                set_user_maxspeed
(iPlayer,320.0)
                
cs_set_user_team(iPlayer,CS_TEAM_CT)
            }
        }
    }
}

public 
CheckNemesis() {
    if (
get_birds() == && g_mode == NEMESIS) {
        new 
iPlayers[32], iNumiPlayer;
        
get_players(iPlayersiNum"a")
        for (new 
0iNumi++) {
            
iPlayer iPlayers[i]
            if (
nemesis[iPlayer]) {
                
nemesis[iPlayer] = false
                assassin
[iPlayer] = true
                set_user_health
(iPlayer,5000)
                
set_user_maxspeed(iPlayer,1280.0)
                
client_cmd(0,"stopsound")
                
client_cmd(0,"spk %s",assassin_music)
                
g_mode ASSASSIN
            
}
            else {
                
angry[iPlayer] = true
                set_user_health
(iPlayer,5000)
                
strip_user_weapons(iPlayer)
                
give_item(iPlayer,"weapon_xm1014")
                
set_user_maxspeed(iPlayer,1280.0)
            }
        }
    }
}

public 
fwHamPlayerSpawnPost(id) {
    if (
spawn_start[id]) {
        
spawn_music[id] = true
        spawn_start
[id] = false
    
}
    new 
mapname[32]
    
get_mapname(mapname,31)
    if (
equal(mapname,"redswar_tdm") || equal(mapname,"redswar_bd") || equal(mapname,"redswar_hr") || equal(mapname,"redswar_vip")) {
        if (
spawn_music[id]) {
            if (
is_user_alive(id)) {
                if (
cs_get_user_team(id) == CS_TEAM_CT) {
                    if (
cs_get_user_vip(id) == 1) {
                        
client_cmd(id,"stopsound")
                        
client_cmd(id,"spk %s",vip_music)
                        
spawn_music[id] = false
                    
}
                    else {
                        
client_cmd(id,"stopsound")
                        
client_cmd(id,"spk %s",bird_music)
                        
spawn_music[id] = false
                    
}
                }
                else if (
cs_get_user_team(id) == CS_TEAM_T) {
                    
client_cmd(id,"stopsound")
                    
client_cmd(id,"spk %s",pig_music)
                    
spawn_music[id] = false
                
}
            }
        }
    }
    else if (
equal(mapname,"redswar_zm")) {
        if (
spawn_music[id]) {
            if (
is_user_alive(id)) {
                
client_cmd(id,"stopsound")
                
client_cmd(id,"spk %s",bird_music)
                
spawn_music[id] = false
            
}
        }
    }
}

public 
stop_score_mode(id) { 
    
scoremode[id] = false
}

public 
Bird_Win(id) {
    if (
win_mode == 0) {
        
bird_score++
        
win_mode 1
    
}
}

public 
Pig_Win(id) {
    if (
win_mode == 0) {
        
pig_score++
        
win_mode 1
    
}
}

public 
Bomb_Exploded(id) {
    if (
win_mode == 0) {
        
pig_score++
        
win_mode 1
    
}
}

public 
Hostages_Rescued(id) {
    if (
win_mode == 0) {
        
bird_score++
        
win_mode 1
    
}
}

public 
Hostages_Lost(id) {
    if (
win_mode == 0) {
        
pig_score++
        
win_mode 1
    
}
}

public 
VIP_Dead(id) {
    if (
win_mode == 0) {
        
pig_score++
        
win_mode 1
    
}
}

public 
VIP_Lost(id) {
    if (
win_mode == 0) {
        
pig_score++
        
win_mode 1
    
}
}

public 
TheEnd() {
    new 
mapname[32]
    
get_mapname(mapname,31)
    if (
equal(mapname,"redswar_tdm")) {
        if (
bird_point pig_point) {
            
client_cmd(0,"stopsound")
            
client_cmd(0,"spk %s",bird_winner)
        }
        else if (
bird_point pig_point) {
            
client_cmd(0,"stopsound")
            
client_cmd(0,"spk %s",pig_winner)
        }
    }
    else if (
equal(mapname,"redswar_bd") || equal(mapname,"redswar_hr") || equal(mapname,"redswar_vip")) {
        if (
bird_score pig_score) {
            new 
id[32], numtarget
            get_players
(id,num,"ch")
            for (new 
0numi++) {
                
target id[i]
                if (
cs_get_user_vip(target)) {
                    
client_cmd(target,"stopsound")
                    
client_cmd(target,"spk %s",vip_winner)
                }
                else {
                    
client_cmd(target,"stopsound")
                    
client_cmd(target,"spk %s",bird_winner)
                }
            }
        }
        else if (
bird_score pig_score) {
            
client_cmd(0,"stopsound")
            
client_cmd(0,"spk %s",pig_winner)
        }
    }
    else if (
equal(mapname,"redswar_zm")) {
        if (
bird_score pig_score) {
            
client_cmd(0,"stopsound")
            
client_cmd(0,"spk %s",bird_winner)
        }
        else if (
bird_score pig_score) {
            
client_cmd(0,"stopsound")
            
client_cmd(0,"spk %s",zombie_winner)
        }
    }
}

public 
Team_Events( ) 
{
    if (
win_mode == 0) {
    new 
szEvent64 ]
    
read_logargv(2szEventcharsmax(szEvent))
    
    if (
equal(szEvent,"Defused_The_Bomb")) {
        
bird_score++
        
win_mode 1
    
}
    
    else if (
equal(szEvent,"Escaped_As_VIP")) {
        
bird_score++
        
win_mode 1
    
}
    }
}

public 
client_putinserver(id) {
    
spawn_music[id] = true
    spawn_start
[id] = true
}

public 
client_connect(id) {
    
yourpoint[id] = 0
}

public 
client_disconnect(id) {
    
yourpoint[id] = 0
    scoremode
[id] = false
}

stock get_random_player(const flags[]="", const team[]="") {
    new 
iPlayers[32], iNum;
    
get_players(iPlayersiNumflagsteam)
    
    return (
iNum 0) ? iPlayers[random(iNum)] : -1;
}

get_birds() {
    new 
players[32], pnumbirdsid;
    
get_players(playerspnum"i");

    for (--
pnumpnum >= 0pnum--)
    {
        
id players[pnum];

        if (!
zombie[id])
            
birds++;
    }

    return 
birds;

Why doesn't it working?! Is somewhere wrong?
MihaiGamerXD is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 12-03-2018 , 21:15   Re: How to get random number?
Reply With Quote #6

What part doesn't work? If you've got the answer to "How to get a random number?" then this thread is complete (you've been given three working examples). If you are having another problem, post a new thread with that specific problem.

P.S. Bugsy's solution is the most efficient. Jess98's is the least efficient and poorly coded.
__________________
fysiks is offline
Jess98
Junior Member
Join Date: Apr 2018
Old 12-04-2018 , 06:32   Re: How to get random number?
Reply With Quote #7

Quote:
Originally Posted by fysiks View Post
What part doesn't work? If you've got the answer to "How to get a random number?" then this thread is complete (you've been given three working examples). If you are having another problem, post a new thread with that specific problem.

P.S. Bugsy's solution is the most efficient. Jess98's is the least efficient and poorly coded.
Unfortunately yes but.. Actually, I just wrote it insignificant for tried to explain the logic of that native as simply to him.
Jess98 is offline
MihaiGamerXD
Member
Join Date: Aug 2018
Old 12-04-2018 , 11:29   Re: How to get random number?
Reply With Quote #8

Ok then, but show me a full example of Bugsy please.
like if().
MihaiGamerXD is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 12-04-2018 , 13:35   Re: How to get random number?
Reply With Quote #9

Quote:
Originally Posted by MihaiGamerXD View Post
Ok then, but show me a full example of Bugsy please.
like if().
Are you really asking examples for an if? Just open any plugin ever made I guess.
__________________
HamletEagle is offline
iceeedr
Veteran Member
Join Date: Apr 2017
Location: Brazil
Old 12-04-2018 , 13:46   Re: How to get random number?
Reply With Quote #10

I'm wondering how a person, throws a plugin (with his name) but does not know an example of how to use something as basic as "if ()" ... ??
__________________


Quote:
Originally Posted by fysiks View Post
Please stop trying to help. You appear to just be posting random stuff. Wait until you actually understand more about AMX Mod X and how the game works.
https://iceeedr.com.br/
iceeedr is offline
Send a message via Skype™ to iceeedr
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 02:34.


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