Playerlib
From EventScripts Community Encyclopedia
|
[edit] Module: playerlib[edit] Module OverviewEventScripts version: 2.0.0.250a [edit] Table of Contents
[edit] DescriptionPlayerlib provides provides access to getting and setting player properties. It also includes some commonly used player functions. [edit] Quick ExamplePlayer object usage examples: import playerlib # Create a Player object myPlayer = playerlib.getPlayer(event_var['userid']) # Now use it to get the amount of ammo in the player's primary weapon myAmmo = myPlayer.get('ammo', 'primary') # and set the amount of ammo in the player's pistol clip myPlayer.set('clip', ['secondary', '34']) import playerlib def player_hurt(event_var): # Make the victim pop into the air like popcorn victim = playerlib.getPlayer(event_var['userid']) victim.push(0, 700, 1)) Player Attributes: ### Contains everything from es.createplayerlist ### # First, let's get their name myname = myPlayer.name # Now let's get their model model = myPlayer.model # Now let's set their model myPlayer.model = '[path_to_model]' # Now let's tell him what model he is es.tell(event_var['userid'), "Hello %s your current model is: %s" % (myname, model)) # Kills mykills = myPlayer.kills # Deaths mydeaths = myPlayer.deaths # SteamID mysteamID = myPlayer.steamid # Teamid 0 == unassigned, 1 == Spectator, 2 == T and 3 == CT myteam = myPlayer.teamid # Armor myarmor = myPlayer.armor # Is dead 1 = dead, 0 = alive amIdead = myPlayer.isdead # Is bot 1 = bot, 0 = human amIabot = myPlayer.isbot # Am I a spectator spectator = myPlayer.isobserver # Health myhealth = myPlayer.health # Serial number serialnumber = myPlayer.serialnumber # Weapon returns weapon_<name> myweapon = myPlayer.weapon # Handle handle = myPlayer.handle # Ping myping = myPlayer.ping # Packet loss packetloss = myPlayer.packetloss # Time player has been connected (returns float don't know if it's in minutes or seconds please update) timeconnected = myPlayer.timeconnected # IP address myIP = myPlayer.address # X position (Pitch) myPitch = myPlayer.x # Y position (Yaw) myYaw = myPlayer.y # Z position (Roll) myRoll = myPlayer.z Player list usage: import es import playerlib # Creates a list of Player objects using a filter myPlayerList = playerlib.getPlayerList('#ct,#alive') # Go through the players, get some attributes and print them to the chat area for ply in myPlayerList: es.msg(ply.weapon) # Now you can get their Userid from the filtered getPlayerList es.tell(ply.userid, 'You are a living CT!') getPlayerList filters: import playerlib # Saves a filter function for adding an unique filter to existing filters "#all", "#t", etc. playerlib.registerPlayerListFilter(filtername, filterfunction) # The following are some example player list filters, all are used by default: playerlib.returnAlive(x) playerlib.returnAll(x) playerlib.returnBot(x) playerlib.returnDead(x) playerlib.returnHuman(x) playerlib.returnTeam0(x) playerlib.returnTeam1(x) playerlib.returnTeam2(x) playerlib.returnTeam3(x) # Unregisters a getPlayerList filter playerlib.unregisterPlayerListFilter(filtername) [edit] Module Content[edit] Classes[edit] Methods
[edit] See Also
[edit] Notes
|
|
