Add NameChange lua hook
This commit is contained in:
parent
0afaa1e977
commit
73d324b2a2
4 changed files with 5150 additions and 0 deletions
|
|
@ -1346,6 +1346,14 @@ static void SetPlayerName(INT32 playernum, char *newname)
|
|||
{
|
||||
if (strcasecmp(newname, player_names[playernum]) != 0)
|
||||
{
|
||||
if (!LUA_HookNameChange(&players[playernum], newname))
|
||||
{
|
||||
// Name change rejected by Lua
|
||||
if (playernum == consoleplayer)
|
||||
CV_StealthSet(cv_playername, player_names[consoleplayer]);
|
||||
return;
|
||||
}
|
||||
|
||||
if (netgame)
|
||||
HU_AddChatText(va("\x82*%s renamed to %s", player_names[playernum], newname), false);
|
||||
|
||||
|
|
|
|||
|
|
@ -63,6 +63,7 @@ automatically.
|
|||
X (ShieldSpecial),/* shield abilities */\
|
||||
X (PlayerCanDamage),/* P_PlayerCanDamage */\
|
||||
X (PlayerQuit),\
|
||||
X (NameChange),\
|
||||
X (IntermissionThinker),/* Y_Ticker */\
|
||||
X (TeamSwitch),/* team switching in... uh... *what* speak, spit it the fuck out */\
|
||||
X (ViewpointSwitch),/* spy mode (no trickstabs) */\
|
||||
|
|
@ -139,6 +140,7 @@ int LUA_HookMapThingSpawn(mobj_t *, mapthing_t *);
|
|||
int LUA_HookFollowMobj(player_t *, mobj_t *);
|
||||
int LUA_HookPlayerCanDamage(player_t *, mobj_t *);
|
||||
void LUA_HookPlayerQuit(player_t *, kickreason_t);
|
||||
int LUA_HookNameChange(player_t *plr, const char *name);
|
||||
int LUA_HookTeamSwitch(player_t *, int newteam, boolean fromspectators, boolean tryingautobalance, boolean tryingscramble);
|
||||
int LUA_HookViewpointSwitch(player_t *player, player_t *newdisplayplayer, boolean forced);
|
||||
int LUA_HookSeenPlayer(player_t *player, player_t *seenfriend);
|
||||
|
|
|
|||
|
|
@ -904,6 +904,18 @@ void LUA_HookPlayerQuit(player_t *plr, kickreason_t reason)
|
|||
}
|
||||
}
|
||||
|
||||
int LUA_HookNameChange(player_t *plr, const char *name)
|
||||
{
|
||||
Hook_State hook;
|
||||
if (prepare_hook(&hook, true, HOOK(NameChange)))
|
||||
{
|
||||
LUA_PushUserdata(gL, plr, META_PLAYER); // Player that changed name
|
||||
lua_pushstring(gL, name); // New player name
|
||||
call_hooks(&hook, 1, res_false);
|
||||
}
|
||||
return hook.status;
|
||||
}
|
||||
|
||||
int LUA_HookTeamSwitch(player_t *player, int newteam, boolean fromspectators, boolean tryingautobalance, boolean tryingscramble)
|
||||
{
|
||||
Hook_State hook;
|
||||
|
|
|
|||
5128
src/netcode/d_netcmd.c
Normal file
5128
src/netcode/d_netcmd.c
Normal file
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue