Skip to content

Commit

Permalink
Version 2.11 - Fixing bugs
Browse files Browse the repository at this point in the history
- Fixed finally chat spam of the advert when setting redie_advert_time to 0.0.
- Fixed -1 frag +1 death when dying as ghost.
- Fixed that weapons can be dropped for a short time after spawning as ghost.
- Added message when a ghost tries to drop a weapon.
  • Loading branch information
Chanz committed Jun 14, 2014
1 parent 526f1e0 commit f122361
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 17 deletions.
Binary file modified addons/sourcemod/plugins/redie.smx
Binary file not shown.
61 changes: 44 additions & 17 deletions addons/sourcemod/scripting/redie.sp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public Plugin:myinfo = {
name = "Redie and be a ghost",
author = "Chanz, MeoW",
description = "Return as a ghost after you died.",
version = "2.10",
version = "2.11",
url = "http://bcserv.eu/"
}

Expand All @@ -64,7 +64,8 @@ public Plugin:myinfo = {
***************************************************************************************/

#define LIFESTATE_DEAD 1
#define LIFESTATE_ALIVE 0

/***************************************************************************************
Expand Down Expand Up @@ -129,6 +130,7 @@ public OnPluginStart()

// Command Hooks (AddCommandListener) (If the command already exists, like the command kill, then hook it!)
AddCommandListener(CommandListener_Any);
AddCommandListener(CommandListener_Drop, "drop");

// Register New Commands (PluginManager_RegConsoleCmd) (If the command doesn't exist, hook it here)
PluginManager_RegConsoleCmd("sm_redie", Command_Redie, "After death you can use this command to respawn as a ghost");
Expand Down Expand Up @@ -251,11 +253,11 @@ public Action:NormalSoundHook_FlashLight(clients[64], &numClients, String:sample

public Action:Timer_ResetLifeState(Handle:timer)
{
LOOP_CLIENTS(client,CLIENTFILTER_ALL) {
LOOP_CLIENTS(client, CLIENTFILTER_INGAMEAUTH) {

if(g_bIsGhost[client]) {

SetEntProp(client, Prop_Send, "m_lifeState", 0);
SetEntProp(client, Prop_Send,"m_lifeState", LIFESTATE_ALIVE);
}
}
}
Expand Down Expand Up @@ -320,7 +322,7 @@ public Hook_ThinkPost_PlayerManager(entity)
return;
}

LOOP_CLIENTS(client,CLIENTFILTER_ALL) {
LOOP_CLIENTS(client, CLIENTFILTER_INGAMEAUTH) {

if(g_bIsGhost[client]) {

Expand Down Expand Up @@ -434,6 +436,14 @@ public Action:CommandListener_Any(client, const String:command[], argc)
return Plugin_Continue;
}

if (!Client_IsValid(client)) {
return Plugin_Continue;
}

if (!Client_IsAdmin(client)) {
return Plugin_Continue;
}

decl String:cmd[256];
GetCmdArgString(cmd, sizeof(cmd));

Expand All @@ -442,7 +452,24 @@ public Action:CommandListener_Any(client, const String:command[], argc)
}

// If there is any command which uses @dead or @alive we set the life states back to prevent that ghosts are treated as alive players.
SetLifeStateBack();
FlickerLifeState();
return Plugin_Continue;
}

public Action:CommandListener_Drop(client, const String:command[], argc)
{
if (g_iPlugin_Enable == 0) {
return Plugin_Continue;
}

if (!Client_IsValid(client)) {
return Plugin_Continue;
}

if (g_bIsGhost[client]) {
Client_PrintToChat(client, false, "{O}[{G}Redie{O}] {N} You can't drop weapons as ghost");
return Plugin_Stop;
}
return Plugin_Continue;
}

Expand All @@ -462,8 +489,6 @@ public Action:Command_Redie(client, args)

if (g_bIsGhost[client]) {

SetEntProp(client, Prop_Data, "m_iFrags", GetClientFrags(client) + 1);
SetEntProp(client, Prop_Data, "m_iDeaths", GetClientDeaths(client) - 1);
ForcePlayerSuicide(client);
return Plugin_Handled;
}
Expand Down Expand Up @@ -510,13 +535,11 @@ public Action:Event_RoundEnd(Handle:event, const String:name[], bool:dontBroadca

if (g_iPlugin_Enable != 0) {

LOOP_CLIENTS(client,CLIENTFILTER_ALL) {
LOOP_CLIENTS(client, CLIENTFILTER_INGAMEAUTH) {

if (g_bIsGhost[client]) {

SetEntProp(client, Prop_Send, "m_lifeState", 0);
SetEntProp(client, Prop_Data, "m_iFrags", GetClientFrags(client) + 1);
SetEntProp(client, Prop_Data, "m_iDeaths", GetClientDeaths(client) - 1);
SetEntProp(client, Prop_Send,"m_lifeState", LIFESTATE_ALIVE);
ForcePlayerSuicide(client);
}
}
Expand Down Expand Up @@ -581,6 +604,10 @@ public Action:Event_PlayerDeath(Handle:event, const String:name[], bool:dontBroa
new bool:handleEvent = g_bIsGhost[client];

if (g_bIsGhost[client]) {

Client_SetScore(client, Client_GetScore(client) + 1);
Client_SetDeaths(client, Client_GetDeaths(client) - 1);

new ragdoll = GetEntPropEnt(client, Prop_Send, "m_hRagdoll");
if (Entity_IsValid(ragdoll)) {
Entity_Kill(ragdoll);
Expand All @@ -590,7 +617,7 @@ public Action:Event_PlayerDeath(Handle:event, const String:name[], bool:dontBroa
Client_InitializeVariables(client);

// Lets test if the round is over by setting the life state of the ghosts for a short time.
SetLifeStateBack();
FlickerLifeState();

if (g_flPlugin_AutoGhostTime > 0.0) {
CreateTimer(g_flPlugin_AutoGhostTime, Timer_AutoGhostSpawn, GetClientUserId(client), TIMER_FLAG_NO_MAPCHANGE);
Expand Down Expand Up @@ -626,13 +653,13 @@ public Action:Event_PlayerFootstep(Handle:event, const String:name[], bool:dontB
***************************************************************************************/
SetLifeStateBack()
FlickerLifeState()
{
LOOP_CLIENTS(client,CLIENTFILTER_ALL) {
LOOP_CLIENTS(client,CLIENTFILTER_INGAMEAUTH) {

if(g_bIsGhost[client]) {

SetEntProp(client, Prop_Send, "m_lifeState", 1);
SetEntProp(client, Prop_Send, "m_lifeState", LIFESTATE_DEAD);
}
}
CreateTimer(0.2, Timer_ResetLifeState, INVALID_HANDLE, TIMER_FLAG_NO_MAPCHANGE);
Expand All @@ -644,7 +671,7 @@ ResetAllGhosts()

if (g_bIsGhost[client]) {

SetEntProp(client, Prop_Send, "m_lifeState", 0);
SetEntProp(client, Prop_Send,"m_lifeState", LIFESTATE_ALIVE);
ForcePlayerSuicide(client);
}
}
Expand Down

0 comments on commit f122361

Please sign in to comment.