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

How can I do only 1 Terrorist?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
MihaiGamerXD
Member
Join Date: Aug 2018
Old 11-27-2018 , 03:31   How can I do only 1 Terrorist?
Reply With Quote #1

Hello again. I want to know how can I do just one terrorist? Example, when the random player has been choosed, the other players except the random player will change the team to CT, like on ZP.

I tried this code:

PHP Code:
/* Plugin generated by AMXX-Studio */

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

public plugin_init() {
    
register_plugin("Red's War Zombie Mode""1.0""MihaiGamerXD")
    
register_event("HLTV","onNewRound","a","1=0","2=0")
}

public 
onNewRound() {
    
set_task(1.0,"ZombieTime",0,"",0,"a",1)
}

public 
ZombieTime() {
    new 
iPlayers[32], iNum
    get_players
(iPlayers,iNum,"a")
    for (new 
0iNumi++) {
        new 
target iPlayers[random(i)]
        if (
is_user_alive(iPlayers[i])) {
            if (
iPlayers[i] != target) {
                
cs_set_user_team(iPlayers[i],CS_TEAM_CT)
            }
        }
    }

And it doesn't work! Any ideas?
MihaiGamerXD is offline
shauli
Member
Join Date: Jun 2018
Old 11-27-2018 , 05:21   Re: How can I do only 1 Terrorist?
Reply With Quote #2

Move this line:
PHP Code:
new target iPlayers[random(i)] 
to before the for loop starts, because you want to get the random player only 1 time. Also change random(i) to random(iNum).

The is_user_alive condition is useless in this case because you already have flag "a" in get_players, so every player in the array is guaranteed to be alive.

In your set_task you have the flag "a", which means "repeat X amount of time" and 1 as the amount of times to repeat, which is already the default scenario with set_task, and since all your other parameters are empty you can just write it like this:
PHP Code:
set_task(1.0,"ZombieTime"

Last edited by shauli; 11-27-2018 at 05:23.
shauli is offline
MihaiGamerXD
Member
Join Date: Aug 2018
Old 11-27-2018 , 10:05   Re: How can I do only 1 Terrorist?
Reply With Quote #3

I'm sorry, but I tried this code and it worked:
PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <fun>
#include <cstrike>
#include <hamsandwich>

public plugin_init() {
    
register_plugin("Red's War Zombie Mode""1.0""MihaiGamerXD")
    
register_event("HLTV","onNewRound","a","1=0","2=0")
    
register_logevent("onRoundEnd",2,"1=Round_End")
    
RegisterHam(Ham_TakeDamage,"player","onDamage",1)
}

public 
onNewRound() {
    
set_task(0.1,"ZombieTime",0,"",0,"a",1)
}

public 
ZombieTime() {
    new 
target get_random_player("a")
    
cs_set_user_team(target,CS_TEAM_T)
    
strip_user_weapons(target)
    
give_item(target,"weapon_knife")
    new 
iPlayers[32], iNumiPlayer
    get_players
(iPlayers,iNum,"a")
    for (new 
0iNumi++) {
        
iPlayer iPlayers[i]
        if (
iPlayer != target) {
            
cs_set_user_team(iPlayer,CS_TEAM_CT)
        }
    }
}

stock get_random_player(const flags[]="", const team[]="")
{
    new 
players[32], pnum;
    
get_players(playerspnumflagsteam);

    return (
pnum 0) ? players[random(pnum)] : -1;

I did this for myself!
So thank you for helping me!

Last edited by MihaiGamerXD; 11-27-2018 at 10:06.
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 19:01.


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