AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting (https://forums.alliedmods.net/forumdisplay.php?f=107)
-   -   [CS:S] C4 Autoplanter (https://forums.alliedmods.net/showthread.php?t=336344)

r3v 02-13-2022 05:59

[CS:S] C4 Autoplanter
 
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?

r3v 02-13-2022 06:02

Re: [CS:S] C4 Autoplanter
 
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);



Bacardi 02-13-2022 08:23

Re: [CS:S] C4 Autoplanter
 
After CreateEntityByName
PHP Code:

            SetEntityModel(bombEntity"models/weapons/w_c4_planted.mdl"); 


r3v 02-13-2022 09:45

Re: [CS:S] C4 Autoplanter
 
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.

Bacardi 02-13-2022 10:08

Re: [CS:S] C4 Autoplanter
 
so that is your problem. Why you did not mention ?

r3v 02-13-2022 10:19

Re: [CS:S] C4 Autoplanter
 
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.

Bacardi 02-14-2022 13:35

Re: [CS:S] C4 Autoplanter
 
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.

Bacardi 02-15-2022 19:45

Re: [CS:S] C4 Autoplanter
 
2 Attachment(s)
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.

r3v 02-16-2022 01:47

Re: [CS:S] C4 Autoplanter
 
I tested on linux server and it works! Thank you for your work!

Bacardi 02-16-2022 04:25

Re: [CS:S] C4 Autoplanter
 
Hehehe, nice. Good to hear.


All times are GMT -4. The time now is 05:47.

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