ItsMods
[Tutorial] Basic usage of level.players - Printable Version

+- ItsMods (https://www.itsmods.com)
+-- Forum: Archive (https://www.itsmods.com/Forum-Archive.html)
+--- Forum: Archive (https://www.itsmods.com/Forum-Archive--64.html)
+--- Thread: [Tutorial] Basic usage of level.players (/Thread-Tutorial-Basic-usage-of-level-players.html)

Pages: 1 2


Basic usage of level.players - Pozzuh - 04-03-2011

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.


RE: Basic usage of level.players - iAegle - 04-03-2011

Thanks this is really usefull Smile


RE: Basic usage of level.players - rotceh_dnih - 04-03-2011

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" ); }



RE: Basic usage of level.players - iAegle - 04-03-2011

(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


RE: Basic usage of level.players - rotceh_dnih - 04-03-2011

thanks heaps but what about a thread would that be
Code:
player thread dostuff();



RE: Basic usage of level.players - Pozzuh - 04-03-2011

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();



RE: Basic usage of level.players - rotceh_dnih - 04-03-2011

arr ok thanks that works but the message repeats itself all the time and dose not reset on death
if know what i mean


RE: Basic usage of level.players - iAegle - 04-03-2011

(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



RE: Basic usage of level.players - rotceh_dnih - 04-03-2011

any ideas how i can do it then? Angel


RE: Basic usage of level.players - Nekochan - 07-10-2011

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" ); } } }