This site is a testing version, but all data is shared with the live forum.


Raised This Month: $ Target: $400
 0% 

Solved respawn bots at afk 10s for Hl2dm server


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
hl2dmgamer
Junior Member
Join Date: Dec 2023
Old 12-10-2023 , 06:44   respawn bots at afk 10s for Hl2dm server
Reply With Quote #1

Hi, is it possible to change this code from a kill function to a respawn function?
Thank you
PHP Code:
#include <sdktools>
#include <simple_colors>
#include <sourcemod>
#include <halflife>
#include <sdkhooks>
#include <sdktools_hooks>
#include <sdktools_stocks>


#pragma semicolon 1
#pragma newdecls required

int g_iCampTime;
int g_iSlapDamage;

float g_fRadius;
//int g_iBeamSprite = -1;
//int g_iHaloSprite = -1;
float g_fLastPos[MAXPLAYERS 1][3];
float g_fSpawnEyeAng[MAXPLAYERS 1][3];

Handle g_hTimerChecker[MAXPLAYERS 1];

int g_iCampCount[MAXPLAYERS 1];

#define            NAME         "antiCBot"
#define            AUTHOR        "TRON"
#define            VERSION        "4.0"

public Plugin myinfo =

    
name    NAME,
    
author    AUTHOR,
    
version    VERSION,
};

public 
void OnPluginStart()
{
    
HookEvent("round_end"Event_RoundEndEventHookMode_Pre);
    
HookEvent("player_spawn"Event_PlayerSpawnEventHookMode_Post);
    
HookEvent("player_death"Event_PlayerDeath);

    
LoadTranslations("Bot_AntiCamp.phrases");
    
LoadSettings();
}

public 
void OnMapStart()
{
    
//g_iBeamSprite = PrecacheModel("materials/sprites/laserbeam.vmt", true);
    //g_iHaloSprite = PrecacheModel("materials/sprites/halo01.vmt", true);
    
PrecacheSound("buttons/button1.wav"true);

   
LoadSettings();
}

void LoadSettings()
{
    
char sBuffer[256];
    
BuildPath(Path_SMsBuffersizeof(sBuffer), "configs/Bot_AntiCamp.cfg");

    if(!
FileExists(sBuffer))
    {
        
SetFailState("File doesnt exist: %s"sBuffer);
        return;
    }

    
KeyValues kv = new KeyValues("Configs1");

    if(!
kv.ImportFromFile(sBuffer))
    {
        
delete kv;
        
SetFailState("File not found %s!"sBuffer);
        return;
    }

    
g_iCampTime kv.GetNum("camp_time");
    
g_iSlapDamage kv.GetNum("slap_damage");
    
g_fRadius kv.GetFloat("radius");

    
delete kv;
}

public 
void OnClientDisconnect(int iClient)
{
    
DeleteTimer(iClient);
    
g_iCampCount[iClient] = 0;
}

public 
Action Event_RoundEnd(Event hEventchar[] sEvNamebool bDontBroadcast)
{
    for(
int i 1<= MaxClientsi++)
    {
        if(
IsFakeClient(i))
        {
            
DeleteTimer(i);
            
g_iCampCount[i] = 0;
        }
    }
}

public 
Action Event_PlayerDeath(Event hEventchar[] sEvNamebool bDontBroadcast)
{
    
int iClient GetClientOfUserId(hEvent.GetInt("userid"));

    
DeleteTimer(iClient);
}

public 
Action Event_PlayerSpawn(Event hEventchar[] sEvNamebool bDontBroadcast)
{
    
//if(IsWarmup()) return;

    
int iClient GetClientOfUserId(hEvent.GetInt("userid"));

    
GetClientAbsOrigin(iClientg_fLastPos[iClient]);
    
GetClientAbsOrigin(iClientg_fSpawnEyeAng[iClient]);

    
DeleteTimer(iClient);
    
g_hTimerChecker[iClient] = CreateTimer(2.0Timer_CheckerGetClientUserId(iClient), TIMER_REPEAT TIMER_FLAG_NO_MAPCHANGE);
}

public 
Action Timer_Checker(Handle hTimerany iClientUserId)
{
    
int iClient GetClientOfUserId(iClientUserId);

    if(!
iClient || !IsPlayerAlive(iClient)|| !IsFakeClient(iClient))
    {
        
g_hTimerChecker[iClient] = null;
        return 
Plugin_Stop;
    }

    if(
g_hTimerChecker[iClient] == null) return Plugin_Stop;

    if(
IsCamping(iClient)) g_iCampCount[iClient] += 2;
    else 
g_iCampCount[iClient] = 0;

    if(
g_iCampCount[iClient] == g_iCampTime)
        for(
int i 1<= MaxClientsi++)
            
//S_PrintToChat(i, "%T", "Camp_Message1", i, iClient);

    
if(g_iCampCount[iClient] >= g_iCampTime)
    {
        
float fVec[3];
        
GetClientAbsOrigin(iClientfVec);
        
fVec[2] += 10;

        
//TE_SetupBeamRingPoint(fVec, 10.0, 375.0, g_iBeamSprite, g_iHaloSprite, 0, 10, 0.6, 10.0, 0.5, GetClientTeam(iClient) == 3 ? {0, 0, 150, 255} : {150, 0, 0, 255}, 10, 0);
        //TE_SendToAll();

        //EmitAmbientSound("buttons/blip1.wav", fVec, iClient, SNDLEVEL_RAIDSIREN);

        
SlapPlayer(iClientg_iSlapDamagetrue);
    }

    return 
Plugin_Continue;
}

bool IsCamping(int iClient)
{
    
float fCurrentPos[3];
    
GetClientAbsOrigin(iClientfCurrentPos);

    if(
g_fRadius GetVectorDistance(g_fSpawnEyeAng[iClient], fCurrentPos)) return false;

    if(
g_fRadius GetVectorDistance(g_fLastPos[iClient], fCurrentPos)) return true;

    
g_fLastPos[iClient] = fCurrentPos;
    return 
false;
}

void DeleteTimer(int iClient)
{
    if(
g_hTimerChecker[iClient] != null)
    {
        
KillTimer(g_hTimerChecker[iClient]);
        
g_hTimerChecker[iClient] = null;
    }
}

// bool IsWarmup()
// {
    // return (GameRules_GetProp("m_bWarmupPeriod") == 1);
// } 

Last edited by hl2dmgamer; 12-12-2023 at 16:42. Reason: Solved
hl2dmgamer is offline
101
Member
Join Date: Nov 2023
Old 12-11-2023 , 03:20   Re: respawn bots at afk 10s for Hl2dm server
Reply With Quote #2

its better for u to find another community that provides useful answer and fast response .
by the way , no one on the earth could understand what exactly u want
101 is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


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


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