Raised This Month: $51 Target: $400
 12% 

[CS:S] C4 Autoplanter


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
r3v
Senior Member
Join Date: Feb 2016
Location: Lithuania, Vilnius
Old 02-13-2022 , 05:59   [CS:S] C4 Autoplanter
Reply With Quote #1

Hello,
I have autoplanter plugin from https://github.com/b3none/retakes-autoplant, but i need to work perfectly for CS:Source. The problem is, when new round starts and freeze time ends, planted bomb appears (without model) only blinking and playing beep sound. Screenshot how it looks like: https://steamuserimages-a.akamaihd.n...etterbox=false
Anyone can help me?

Last edited by r3v; 02-16-2022 at 05:17.
r3v is offline
r3v
Senior Member
Join Date: Feb 2016
Location: Lithuania, Vilnius
Old 02-13-2022 , 06:02   Re: [CS:S] C4 Autoplanter
Reply With Quote #2

No error logs.
PHP Code:
#include <sourcemod>
#include <sdktools>
#include <cstrike>

#pragma newdecls required
#pragma semicolon 1

int bomber;
int bombsite;
bool hasBombBeenDeleted;
float bombPosition[3];
Handle bombTimer;
int bombTicking;

ConVar isPluginEnabled;
ConVar freezeTime;

enum //Bombsites
{
    
BOMBSITE_INVALID = -1,
    
BOMBSITE_A 0,
    
BOMBSITE_B 1
}

public 
Plugin myinfo =
{
    
name "[Retakes] Autoplant",
    
author "B3none",
    
description "Automatically plant the bomb at the start of the round. This will work with all versions of the retakes plugin.",
    
version "2.1.1",
    
url "https://github.com/b3none"
};

public 
void OnPluginStart()
{
    
isPluginEnabled CreateConVar("sm_autoplant_enabled""1""Should the autoplant plugin be enabled"_true0.0true1.0);

    
freezeTime FindConVar("mp_freezetime");

    
bombTicking FindSendPropInfo("CPlantedC4""m_bBombTicking");

    
HookEvent("round_start"OnRoundStartEventHookMode_PostNoCopy);
    
HookEvent("round_end"OnRoundEndEventHookMode_PostNoCopy);
}

public 
Action OnRoundStart(Event eEvent, const char[] sNamebool bDontBroadcast)
{
    
hasBombBeenDeleted false;
    
    if (!
isPluginEnabled.BoolValue)
    {
        return 
Plugin_Continue;
    }
    
    
bomber GetBomber();
    
    if (
IsValidClient(bomber))
    {
        
bombsite GetNearestBombsite(bomber);
        
        
int bomb GetPlayerWeaponSlot(bomber4);
        
        
hasBombBeenDeleted SafeRemoveWeapon(bomberbomb);
        
        
GetClientAbsOrigin(bomberbombPosition);
        
        
delete bombTimer;
        
        
bombTimer CreateTimer(freezeTime.FloatValuePlantBombbomber);
    }
    
    return 
Plugin_Continue;
}

public 
void OnRoundEnd(Event event, const char[] sNamebool bDontBroadcast)
{
    
delete bombTimer;
}

public 
Action PlantBomb(Handle timerint client)
{
    
bombTimer INVALID_HANDLE;

    if (
IsValidClient(client) || !hasBombBeenDeleted)
    {
        if (
hasBombBeenDeleted)
        {
            
int bombEntity CreateEntityByName("planted_c4");

            
SetEntData(bombEntitybombTicking11true);
            
SendBombPlanted(client);

            if (
DispatchSpawn(bombEntity))
            {
                
ActivateEntity(bombEntity);
                
TeleportEntity(bombEntitybombPositionNULL_VECTORNULL_VECTOR);

                if (!(
GetEntityFlags(bombEntity) & FL_ONGROUND))
                {
                    
float direction[3];
                    
float floor[3];

                    
Handle trace;

                    
direction[0] = 89.0;

                    
TR_TraceRay(bombPositiondirectionMASK_PLAYERSOLID_BRUSHONLYRayType_Infinite);

                    if (
TR_DidHit(trace))
                    {
                        
TR_GetEndPosition(floortrace);
                        
TeleportEntity(bombEntityfloorNULL_VECTORNULL_VECTOR);
                    }
                }
            }
        }
    } 
    else
    {
        
CS_TerminateRound(1.0CSRoundEnd_Draw);
    }
}

public 
void SendBombPlanted(int client)
{
    
Event event CreateEvent("bomb_planted");

    if (
event != null)
    {
        
event.SetInt("userid"GetClientUserId(client));
        
event.SetInt("site"bombsite);
        
event.Fire();
    }
}

stock bool SafeRemoveWeapon(int clientint weapon)
{
    if (!
IsValidEntity(weapon) || !IsValidEdict(weapon) || !HasEntProp(weaponProp_Send"m_hOwnerEntity"))
    {
        return 
false;
    }

    
int ownerEntity GetEntPropEnt(weaponProp_Send"m_hOwnerEntity");

    if (
ownerEntity != client)
    {
        
SetEntPropEnt(weaponProp_Send"m_hOwnerEntity"client);
    }

    
CS_DropWeapon(clientweaponfalse);

    if (
HasEntProp(weaponProp_Send"m_hWeaponWorldModel"))
    {
        
int worldModel GetEntPropEnt(weaponProp_Send"m_hWeaponWorldModel");

        if (
IsValidEdict(worldModel) && IsValidEntity(worldModel))
        {
            if (!
AcceptEntityInput(worldModel"Kill"))
            {
                return 
false;
            }
        }
    }

    return 
AcceptEntityInput(weapon"Kill");
}

stock int GetBomber()
{
    for (
int i 1<= MaxClientsi++)
    {
        if (
IsValidClient(i) && HasBomb(i))
        {
            return 
i;
        }
    }
    
    return -
1;
}

stock bool HasBomb(int client)
{
    return 
GetPlayerWeaponSlot(client4) != -1;
}

stock int GetNearestBombsite(int client)
{
    
float pos[3];
    
GetClientAbsOrigin(clientpos);
    
    
int playerResource GetPlayerResourceEntity();
    if (
playerResource == -1)
    {
        return 
BOMBSITE_INVALID;
    }
    
    
float aCenter[3], bCenter[3];
    
GetEntPropVector(playerResourceProp_Send"m_bombsiteCenterA"aCenter);
    
GetEntPropVector(playerResourceProp_Send"m_bombsiteCenterB"bCenter);
    
    
float aDist GetVectorDistance(aCenterpostrue);
    
float bDist GetVectorDistance(bCenterpostrue);
    
    if (
aDist bDist)
    {
        return 
BOMBSITE_A;
    }
    
    return 
BOMBSITE_B;
}

stock bool IsValidClient(int client)
{
    return 
client && client <= MaxClients && IsClientInGame(client);

r3v is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 02-13-2022 , 08:23   Re: [CS:S] C4 Autoplanter
Reply With Quote #3

After CreateEntityByName
PHP Code:
            SetEntityModel(bombEntity"models/weapons/w_c4_planted.mdl"); 
__________________
Do not Private Message @me
Bacardi is offline
r3v
Senior Member
Join Date: Feb 2016
Location: Lithuania, Vilnius
Old 02-13-2022 , 09:45   Re: [CS:S] C4 Autoplanter
Reply With Quote #4

Okey, i see c4 model now, but the bug still appears. Planted bomb blinks and beep's very fast, but no explosion. If CT defusing the c4 bomb, he will stuck. I want this for my retake server, and it doesn't matter if planted bomb is in a T spawn spawn or A,B bombsite. No need retake include for this plugin, so someone can test it own server check this.
r3v is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 02-13-2022 , 10:08   Re: [CS:S] C4 Autoplanter
Reply With Quote #5

so that is your problem. Why you did not mention ?
Bacardi is offline
r3v
Senior Member
Join Date: Feb 2016
Location: Lithuania, Vilnius
Old 02-13-2022 , 10:19   Re: [CS:S] C4 Autoplanter
Reply With Quote #6

Sorry, for explanation more about the problem. My bad.
I trying to fix this problem for a few days but it doesn't work. I was looking for a solution, but nothing, tryed other plugins, but same bug appears. And my coding knowledge is poor.

Last edited by r3v; 02-13-2022 at 10:21.
r3v is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 02-14-2022 , 13:35   Re: [CS:S] C4 Autoplanter
Reply With Quote #7

CS:S have some difference with planting bomb, comparing to cs:go.

I found "ShootSatchelCharge" signature, but I'm not 100% sure how it works but it created normal planted c4 on 0,0,0 coordinates.

I have to go work.
__________________
Do not Private Message @me
Bacardi is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 02-15-2022 , 19:45   Re: [CS:S] C4 Autoplanter
Reply With Quote #8

Preview


I will post sample plugin in this post.
- It is not coded exactly same as those plugins you have posted.
Or not work like those plugins.
- I have only tested on OS Windows. I can't test on OS linux, so much hassle with that.

*edit
ShootSatchelCharge.txt goes to gamedata folder.
Attached Files
File Type: sp Get Plugin or Get Source (test.sp - 125 views - 6.3 KB)
File Type: txt ShootSatchelCharge.txt (529 Bytes, 76 views)
__________________
Do not Private Message @me

Last edited by Bacardi; 02-15-2022 at 20:37.
Bacardi is offline
r3v
Senior Member
Join Date: Feb 2016
Location: Lithuania, Vilnius
Old 02-16-2022 , 01:47   Re: [CS:S] C4 Autoplanter
Reply With Quote #9

I tested on linux server and it works! Thank you for your work!
r3v is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 02-16-2022 , 04:25   Re: [CS:S] C4 Autoplanter
Reply With Quote #10

Hehehe, nice. Good to hear.
__________________
Do not Private Message @me
Bacardi 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 05:23.


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