AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting (https://forums.alliedmods.net/forumdisplay.php?f=107)
-   -   respawner going crazy (https://forums.alliedmods.net/showthread.php?t=175738)

Jasonbourne 01-08-2012 06:59

respawner going crazy
 
where the spawn area turns into a kill zone by the map automatically
i want to detect a player death from prop/console within 0.5 seconds of spawn and then disable the plugin
Code:

// Includes
#pragma semicolon 1
#include <sourcemod>
#include <sdktools>
#include <cstrike>

// Plugin Info
#define PLUGIN_NAME "mgspawn"
#define PLUGIN_AUTHOR "Jason Bourne"
#define PLUGIN_DESC "Respawns players killed by world"
#define PLUGIN_VERSION "1.0.1"
#define PLUGIN_SITE "www.immersion-networks.com"

public Plugin:myinfo =
{
    name = PLUGIN_NAME,
    author = PLUGIN_AUTHOR,
    description = PLUGIN_DESC,
    version = PLUGIN_VERSION,
    url = PLUGIN_SITE
}

// Handles Define
new Handle:sm_mgspawn_enable = INVALID_HANDLE;
new Handle:sm_mgspawn_delay = INVALID_HANDLE;
new Handle:sm_mgspawn_spawnpoints = INVALID_HANDLE;
new dead[MAXPLAYERS+1];
new firsttimeload[MAXPLAYERS+1];

//Executed on plugin start
public OnPluginStart()
{
    // Hooking Events
    HookEvent("player_death", Event_Death);
    HookEvent("player_spawn", Event_Spawn);
   
    // Create Convars
    CreateConVar("sm_mgspawn_version", PLUGIN_VERSION, "mgspawn Version", FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY|FCVAR_DONTRECORD);
    sm_mgspawn_enable = CreateConVar("sm_mgspawn_enable", "1", "Enable mgspawn. [0 = FALSE, 1 = TRUE]");
    sm_mgspawn_delay = CreateConVar("sm_mgspawn_delay", "0.1", "Set respawn delay");
    sm_mgspawn_spawnpoints= CreateConVar("sm_mgspawn_spawnpoints", "1", "Set to 0 to enable for all maps or set to 1 to only enable when there are one team spawn points set");
   
   
}
public OnPluginEnd()
{
    //Remove Hook
    UnhookEvent("player_death", Event_Death);
    UnhookEvent("player_spawn", Event_Spawn);
}

public OnMapStart()
{
// Thanks to Spawn Tools 7
    new maxEnt = GetMaxEntities(), tsCount, ctsCount;
    decl String:sClassName[64];
    for (new i = MaxClients; i < maxEnt; i++)
    {
        if (IsValidEdict(i) && IsValidEntity(i) && GetEdictClassname(i, sClassName, sizeof(sClassName)))
        {
            if (StrEqual(sClassName, "info_player_terrorist"))
            {
                tsCount++;
            }
            else if (StrEqual(sClassName, "info_player_counterterrorist"))
            {
                ctsCount++;
            }
        }
    }
   
    // Activates or deactivates plugin based on map spawn condition
    if(GetConVarBool(sm_mgspawn_spawnpoints)) // if fuction is enabled
    {
        // Enables plugin if there is only one set of spawns
        if (tsCount==0 || ctsCount==0)
        {
        SetConVarInt(sm_mgspawn_enable, 1);
        }
        else
        {
        SetConVarInt(sm_mgspawn_enable, 0);
        }
    }
}

public Event_Death( Handle:Death_Event, const String:Death_Name[], bool:Death_Broadcast )
{
    if(GetConVarBool(sm_mgspawn_enable)) // if plugin is enabled
    {
       
        // Get event info
        new client = GetClientOfUserId( GetEventInt(Death_Event,"userid") );
        new attackerId = GetEventInt(Death_Event, "attacker");
        new attacker = GetClientOfUserId(attackerId);
       
        // Killed by world?
        if(attacker==0)
        {
            if ( client != 0 )
            {
                dead[client]++;
                new Float:respawndelaytime=GetConVarFloat(sm_mgspawn_delay);
                CreateTimer(respawndelaytime, RespawnClient, any:client);
               
            }
        }
        // Else bad luck your staying dead
    }
    // Else plugin not enabled
}

public Action:RespawnClient( Handle:timer, any:client )
{
    //Checks on client
    if ( IsValidEntity(client) && IsClientInGame(client) && IsClientObserver(client) && !IsPlayerAlive(client) )
    {
        CS_RespawnPlayer(client);
       
    }
   
}
public Event_Spawn( Handle:Spawn_Event, const String:Spawn_Name[], bool:dontbroadcast)
{   
    new client = GetClientOfUserId( GetEventInt(Spawn_Event,"userid") );
    if (firsttimeload[client]==1)
        {
            firsttimeload[client]=0;
            dead[client]=0;
            CreateTimer(0.8,CheckMapSlayer,client);
        }
   
}
public Action:CheckMapSlayer( Handle:timer, any:client )
{

    if (dead[client]>0)
    {
        SetConVarInt(sm_mgspawn_enable, 0);
    }
   
}

public OnClientPostAdminCheck(client)
{
    firsttimeload[client]=1;
}

why is this not working
the plugin stays enabled and ppl get respawn and killed over and over
no chance to move

Jasonbourne 01-08-2012 16:49

Re: respawner going crazy
 
issue resolved

http://forums.alliedmods.net/showthread.php?t=175680


All times are GMT -4. The time now is 14:51.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.