EasyPlayer creates new instance on every call?
Posted: Mon Sep 03, 2012 6:59 pm
I can't download the newest build yet, so I can't test this out for couple of days.
However, I was just wondering, if I get EasyPlayer from userid, and then later on check if an other EasyPlayer instance from the same userid is equal to the first EasyPlayer, will it be? Or would I have to compare like userid's or steamid's?
Example of what I mean:So would the same player be added to the players list on each spawn? If that's the case, I would have to do likeAnd I'm not asking how to add players to player list, I'm asking about the functionality of EasyPlayer, does it create a new instance, even if I'd call it on same userid?
However, I was just wondering, if I get EasyPlayer from userid, and then later on check if an other EasyPlayer instance from the same userid is equal to the first EasyPlayer, will it be? Or would I have to compare like userid's or steamid's?
Example of what I mean:
Syntax: Select all
from players import EasyPlayer
# Create player list for storing all the players (just an example)
players = []
@Event
def player_spawn(GameEvent):
userid = GameEvent.GetInt('userid')
player = EasyPlayer(userid)
# Add spawned player to players if he's not there already
if player not in players:
players.append(player)
Syntax: Select all
from players import EasyPlayer
# Create player list for storing all the players (just an example)
players = []
@Event
def player_spawn(GameEvent):
userid = GameEvent.GetInt('userid')
player = EasyPlayer(userid)
# Add spawned player to players if he's not there already
for p in players:
if player.steamid == p.steamid:
return
players.append(player)