I work heavily with HL log files, so I wanted a function to return a player's name in HL log format, rather than just their name in-game. For instead, instead, instead of "Warthog" I would want to return "Warthog<1><0:0:12345><CT>"
So below is the function for this - it is based off of get_user_name() in that you pass the ID, string to copy the data into, and the length. It also returns 0 or 1 based on if the user was found.
Code:
// similar to the stock get_user_name, but return the log name for the player: name<userid><authid><team>
stock get_log_user_name(id, log_user_name[], length)
{
// if not a valid player, return that the function failed
if(id < 1 || id > 32)
{
log_user_name[0] = 0
return 0
}
// if a valid player, set the log user name
else
{
static name[32], userid, authid[32], team[16]
// get the player name, userid, authid, and team
get_user_name(id, name, 31)
userid = get_user_userid(id)
get_user_authid(id, authid, 31)
get_user_team(id, team, 15)
// concatenate the values together into the user name log format
formatex(log_user_name, length, "%s<%d><%s><%s>", name, userid, authid, team)
}
// return success
return 1
}