Es.isbot
[edit] Method: isbotModule: es [edit] Method Overview[edit] Table of Contents
[edit] Description
http://eventscripts.com/pages/Es_isbot [edit] Arguments
[edit] ExamplesSimple Example def player_spawn(event_var): if not es.isbot(event_var['userid']): es.msg("#multi", "Userid: " + str(event_var['userid']) + " is not a bot!") else es.msg("#multi", "Userid: " + str(event_var['userid']) + " is a bot!") Advanced Example - Using langlib and playerlib Strings file: language.ini [isbot: player] en="You are $bot!" fr="Vous ĂȘtes $bot!" [isbot: all] en=" is $bot!" fr=" est $bot!" [not a bot] en="not a bot" fr="pas un bot" [a bot] en="a bot" fr="un bot" Script name : bot_example text= None def load(): global text text = langlib.Strings(es.getAddonPath("bot_example") + "/language.ini") def player_spawn(event_var): player= playerlib.getPlayer(event_var['userid']) tokens = {} tokens['name'] = player.get("name") if not es.isbot(event_var['userid']): tokens['bot'] = text("not a bot", None, player.get("lang")) es.tell(event_var['userid'], text("isbot: player", tokens, player.get("lang"))) else tokens['bot'] = text("a bot", None, player.get("lang")) es.msg("#multi", tokens['name'] + " " + text("isbot: all", tokens)) [edit] NotesIn the advanced example we showed the use of both playerlib and langlib along with the es.isbot command. To use playerlib and langlib you must import both of them ('import playerlib' and 'import langlib'). See langlib and playerlib for more help and examples. Text is set to None and is global because it is outside of any classes or functions. On load event the advanced example gets all the strings from a file, in the case 'language.ini', located in the same directory as the .py script, this case 'bot_example.py'. On player_spawn event it gets a players attributes etc using the playerlib function 'getplayer(<userid>)'. Following this we define a array called tokens to store all of the variables to be replaced into the strings loaded earlier into text. After this we check if the player is not a bot, if they are not then we set the bot variable to be replaced to a string from within text. If the player is a bot then is does the same except we cannot tell the bot that it is one, so we set token['bot'] to the right string and shortly following this we send a msg to all saying that <player> is or isn't a bot using the strings we have made up. I hope this help! :D
[edit] See Also |
|
