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

[CSGO] Alternative for onentitycreated


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
pride95
Senior Member
Join Date: Aug 2015
Old 02-23-2018 , 07:57   [CSGO] Alternative for onentitycreated
Reply With Quote #1

PHP Code:

public void OnEntityCreated(int entity, const char[] classname)
{
    if(!
strcmp(classname"game_player_equip"))
    {
        
SDKHook(entitySDKHook_SpawnHook_OnEntitySpawn);
    }
}
public 
Action Hook_OnEntitySpawn(int entity)
{
    
char weapon[33];
    
GetEntPropString(entityProp_Data"m_weaponNames"weaponsizeof(weapon), 0);

    if(
StrContains(weapon"knife") != -1)
    {
        
AcceptEntityInput(entity"Kill");
    }

this works fine, but i dont like hooking with spawn and then killing the entity.

PHP Code:

    int target 
= -1;
    while((
target FindEntityByClassname(target"game_player_equip")) != -1)
    {
        
char weapon[33];
        
GetEntPropString(entityProp_Data"m_weaponNames"weaponsizeof(weapon), 0);

        if(
StrContains(weapon"knife") != -1)
        {
            
AcceptEntityInput(entity"Kill");
        }
    } 
if i try like this in round_start, its too late. it works only after the first respawn.
if i try in round_prestart it doesnt works. any ideas? maybe with EventHookMode_Pre in round start?
pride95 is offline
cravenge
Veteran Member
Join Date: Nov 2015
Location: Chocolate Factory
Old 02-23-2018 , 08:20   Re: [CSGO] Alternative for onentitycreated
Reply With Quote #2

Sometimes, when we're out of other choices, sticking to the first fully working code would be the best instead.
cravenge is offline
Mitchell
~lick~
Join Date: Mar 2010
Old 02-23-2018 , 15:30   Re: [CSGO] Alternative for onentitycreated
Reply With Quote #3

Don't kill it just return Plugin_Stop within the spawn hook and it will prevent it from being spawned..
Mitchell is offline
MasterMind420
BANNED
Join Date: Nov 2010
Old 02-25-2018 , 13:12   Re: [CSGO] Alternative for onentitycreated
Reply With Quote #4

why not just use sdkhook weapon equip and prevent equipping it to begin with? just check the string of the weapon, and return Plugin_Handled; Done...I mean thats if i understand correctly and your trying to prevent equipping a specific weapon? But if your trying to prevent something from spawning to begin with do what mitchell said.

Last edited by MasterMind420; 02-25-2018 at 13:20.
MasterMind420 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 15:05.


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