|
Veteran Member
Join Date: Jun 2013
Location: IsValidClient()
|
05-05-2018
, 10:02
Re: [INC] Client MethodMap
|
#10
|
Quote:
Originally Posted by 404UNF
Oh nice! This is as far as I had gotten with mine:
Spoiler
PHP Code:
methodmap CBasePlayer __nullable__ < CBaseCombatCharacter
{
// Create a CBasePlayer instance from the given client index.
// @param clientIndex The client index to bind this methodmap to. Can be an invalid client index.
// You can use the CBaseEntity.IsValid property to check if the given client is valid or not.
public CBasePlayer(int clientIndex)
{
if (clientIndex == 0)
{
// special case for client 0 as that is the worldspawn entity,
// and technically not a valid client
return view_as<CBasePlayer>(INVALID_ENTITY);
}
return view_as<CBasePlayer>(new CBaseCombatCharacter(clientIndex));
}
// Get/set the player's class
property TFClassType Class
{
public get()
{
return TF2_GetPlayerClass(this.Index);
}
public set(TFClassType class)
{
TF2_SetPlayerClass(this.Index, class);
}
}
// Gets/sets the team this player belongs to.
// @return Player's current TFTeam
property TFTeam Team
{
public get()
{
return TF2_GetClientTeam(this.Index);
}
public set(TFTeam team)
{
TF2_ChangeClientTeam(this.Index, team);
}
}
// Check if client is in a condition
// @return True if client is in condition, false otherwise.
property bool IsInCondition
{
public get(TFCond condition)
{
return TF2_IsPlayerInCondition(this.Index, condition);
}
}
// Check if player is in a duel
property bool IsDuelling
{
public get()
{
return TF2_IsPlayerInDuel(this.Index);
}
}
// Is the player alive?
property bool IsAlive
{
public get()
{
return IsPlayerAlive(this.Index);
}
}
// Get/set player's current skin
property int Skin
{
public get()
{
return GetEntProp(this.Index, Prop_Send, "m_nSkin");
}
public set(int skin)
{
SetEntProp(this.Index, Prop_Send, skin);
}
}
// Add condition to player
public void AddCondition(TFCond condition, float duration, int inflictor)
{
TF2_AddCondition(this.Index, condition, duration, inflictor);
}
// Remove condition from player
public void RemoveCondition(TFCond condition)
{
TF2_RemoveCondition(this.Index, condition);
}
// Disguise player
// Only works for spies so add a spy check before this
public void DisguisePlayer(TFTeam team, TFClassType classType, int target)
{
TF2_DisguisePlayer(this.Index, team, classType, target);
}
// Respawn the player
public void Respawn
{
TF2_RespawnPlayer(this.Index);
}
};
|
Awesome! I've learned a valuable lesson, and that is method maps can make plugin's code a lot neater.
|
|
|
|