PDA

View Full Version : Respawn Conflicts ?


Peoples Army
08-07-2007, 19:31
My plugin round end protection seems to be conflicting with HLStatsX plugin . At the end of the round when players get switched by that plugin , when they respawn , they respawn but not protected(takedamage 0) i was thinking maybee when they respawn there entity properties were reset . any ideas on hoow to fix this ?

pRED*
08-07-2007, 19:56
Yeah respawning resets most things.

You could make a bool variable (something like roundended), set it to true when the round ends (as well as removing all damage) and then set it to false when the next round starts.

Hook the event 'player_spawn', check if roundended is true and if it is, remove damage again.

Peoples Army
08-07-2007, 20:00
good idea :wink:

heres my new code



/*
Round End Protection
This Plugin Will Stop Players From Being Harmed/Killed After The ROund Has Ended
*/
#include <sourcemod>
#include <clients>
#include <sdktools>
#define VERSION "0.3" //plugin version
new Handle: Switch;
new bool:RoundEnded;
public Plugin:myinfo =
{
name = "Round End Protection",
author = "Peoples Army",
description = "Keeps Players From Being Killed At ROund End",
version = VERSION,
url = "www.sourcemod.net (http://www.sourcemod.net)"
}
// hook round end event on plugin start
public OnPluginStart()
{
Switch = CreateConVar("round_end_on","1","1 Turns The Plugin On 0 Is Off",FCVAR_NOTIFY);
HookEvent("round_end",StopKills, EventHookMode_Pre);
HookEvent("round_start",ResetMode);
HookEvent("player_spawn",SpawnEvent);
}
// force godmode on all players for round end
public Action:StopKills(Handle: event , const String: name[] , bool: dontBroadcast)
{
if(GetConVarInt(Switch))
{
new PLAYERS = GetMaxClients();
RoundEnded = true;

for(new j = 1 ; j <= PLAYERS ; ++j)
{
//if(IsClientConnected(j))
SetEntProp(j, Prop_Data, "m_takedamage", 0 , 1);
}
}
}
public ResetMode(Handle: event , const String: name[] , bool: dontBroadcast)
{
if(GetConVarInt(Switch))
{
new PLAYERS = GetMaxClients();
RoundEnded = false;

for(new j = 1 ; j <= PLAYERS ; ++j)
{
//if(IsClientConnected(j))
SetEntProp(j, Prop_Data, "m_takedamage", 2 , 1);
}
}
}
public SpawnEvent(Handle:event,const String:name[],bool:dontBroadcast)
{
new clientID = GetEventInt(event,"userid");
new client = GetClientOfUserId(clientID);

if(RoundEnded == true)
{
SetEntProp(client, Prop_Data, "m_takedamage", 0 , 1);
}
}