ItsMods

Full Version: Basic usage of level.players
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
level.players is a global var with all the players that are currently on the server.
You have a lot of uses for level.players like counting players that have the 'a' in their name. Or threading on everyone. And a lot more.

Here are some examples
Code:
//script that kills everyone.
for(i=0;i<level.players.size;i++)
{
    player = level.players[i];
    
    player suicide();
}

//Kills all the players with 1337 in their name
for(i=0;i<level.players.size;i++)
{
    player = level.players[i];
    
    if(IsSubStr(player.name, "1337" ))
        player suicide();
}

//Kills everyone who has the isNoob var set to true
for(i=0;i<level.players.size;i++)
{
    player = level.players[i];
    
    if(player.isNoob == true)
        player suicide();
}

//Counts all players that have more then 10 kills
for(i=0;i<level.players.size;i++)
{
    player = level.players[i];
    
    if(player.pers["kills"] > 10)
        level.PlayersWithTenKills ++;
}

I hope you guys can use this for something. Post your questions below.
Thanks this is really usefull Smile
could you please show how to call thread with count kill's?

like would this work
Code:
for(i=0;i<level.players.size;i++)
{
    player = level.players[i];
    
    if(player.pers["kills"] > 10)
        level.PlayersWithTenKills ++;
       self iPrintlnBold( "^1welldone 10kills" );

}
(04-03-2011, 13:50)rotceh_dnih Wrote: [ -> ]could you please show how to call thread with count kill's?

like would this work
Code:
for(i=0;i<level.players.size;i++)
{
    player = level.players[i];
    
    if(player.pers["kills"] > 10)
        level.PlayersWithTenKills ++;
       self iPrintlnBold( "^1welldone 10kills" );

}

Code:
for(i=0;i<level.players.size;i++)
{
    player = level.players[i];
    
    if(player.pers["kills"] > 10)
        level.PlayersWithTenKills ++;
       player iPrintlnBold( "^1welldone 10kills" );

}
This is the right one, self is always an entity but in this case its the player.. so you have to use Player instead of Self
thanks heaps but what about a thread would that be
Code:
player thread dostuff();
Code:
CountKills()
{
    for(i=0;i<level.players.size;i++)
    {
        player = level.players[i];
        
        if(player.pers["kills"] > 10)
        {
            level.PlayersWithTenKills ++;
            player iPrintlnBold( "^1welldone 10kills" );
        }
    }
}

Would be the function. And you don't want to thread it on a person, so you should use:
Code:
thread CountKills();
NOT
Code:
self thread CountKills();
arr ok thanks that works but the message repeats itself all the time and dose not reset on death
if know what i mean
(04-03-2011, 14:23)rotceh_dnih Wrote: [ -> ]arr ok thanks that works but the message repeats itself all the time and dose not reset on death
if know what i mean
thats coz its a for loop ... and if you die you dont have less kills so
any ideas how i can do it then? Angel
Code:
CountKills()
{
    for(i=0;i<level.players.size;i++)
    {
        player = level.players[i];
        
        if(player.pers["headshots"] > 100)
        {
            level.aimbotplayers ++;
            player iPrintlnBold( "^1AIM BOT DETECTED" );
        }
    }
}
Pages: 1 2