Raised This Month: $ Target: $400
 0% 

[L4D2] Why did it trigger twice? What happened in between


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Solar1234
Junior Member
Join Date: Nov 2021
Old 04-28-2024 , 08:51   [L4D2] Why did it trigger twice? What happened in between
Reply With Quote #1

PHP Code:
public void OnEntityCreated(int entity, const char[] classname)
{
    if(
classname[0] != 's' || strcmp(classname"survivor_bot"false) != 0)
        return;

    
SDKHook(entitySDKHook_SpawnPostSpawnPost_Bot);
}

void SpawnPost_Bot(int entity)
{
    if(!
IsValidEntity(entity))
        return;

    if(
GetClientTeam(entity) == 4)
    {
        
RemoveEntity(entity);
        return;
    }
    
    
PrintToChatAll("\nDEBUG(%f): NextFrame SpawnPost_Bot entity(%d) entityowner(%d)"GetEngineTime(), botGetEntPropEnt(botProp_Data"m_hOwnerEntity"));
}

DEBUG(1214.675781): NextFrame SpawnPost_Bot entity(2entityowner(-1)
DEBUG(1214.675903): NextFrame SpawnPost_Bot entity(2entityowner(-1)
DEBUG(1214.675903): NextFrame SpawnPost_Bot entity(3entityowner(-1)
DEBUG(1214.675903): NextFrame SpawnPost_Bot entity(3entityowner(-1)
DEBUG(1214.675903): NextFrame SpawnPost_Bot entity(3entityowner(-1)
DEBUG(1214.676025): NextFrame SpawnPost_Bot entity(4entityowner(-1)
DEBUG(1214.676025): NextFrame SpawnPost_Bot entity(4entityowner(-1
I don't know what survivor_bot spawn, can anyone explain that to me
Solar1234 is offline
Marttt
Veteran Member
Join Date: Jan 2019
Location: Brazil
Old 04-28-2024 , 20:18   Re: [L4D2] Why did it trigger twice? What happened in between
Reply With Quote #2

this snippet is wrong (what is this bot variable) so is hard to help
try sharing the full .sp file
__________________
Marttt is offline
Solar1234
Junior Member
Join Date: Nov 2021
Old 04-29-2024 , 09:03   Re: [L4D2] Why did it trigger twice? What happened in between
Reply With Quote #3

Quote:
Originally Posted by Marttt View Post
this snippet is wrong (what is this bot variable) so is hard to help
try sharing the full .sp file
Copy error, the following is the correct content:

PHP Code:
public void OnEntityCreated(int entity, const char[] classname)
{
    if(
classname[0] != 's' || strcmp(classname"survivor_bot"false) != 0)
        return;

    
SDKHook(entitySDKHook_SpawnPostSpawnPost_Bot);
}

void SpawnPost_Bot(int entity)
{
    if(!
IsValidEntity(entity))
        return;

    if(
GetClientTeam(entity) == 4)
    {
        
RemoveEntity(entity);
        return;
    }
    
    
PrintToChatAll("\nDEBUG(%f): SpawnPost_Bot entity(%d) entityowner(%d)"GetEngineTime(), entityGetEntPropEnt(entityProp_Data"m_hOwnerEntity"));
}

DEBUG(1214.675781): SpawnPost_Bot entity(2entityowner(-1)
DEBUG(1214.675903): SpawnPost_Bot entity(2entityowner(-1)
DEBUG(1214.675903): SpawnPost_Bot entity(3entityowner(-1)
DEBUG(1214.675903): SpawnPost_Bot entity(3entityowner(-1)
DEBUG(1214.675903): SpawnPost_Bot entity(3entityowner(-1)
DEBUG(1214.676025): SpawnPost_Bot entity(4entityowner(-1)
DEBUG(1214.676025): SpawnPost_Bot entity(4entityowner(-1
Solar1234 is offline
Solar1234
Junior Member
Join Date: Nov 2021
Old 04-29-2024 , 09:12   Re: [L4D2] Why did it trigger twice? What happened in between
Reply With Quote #4

Quote:
Originally Posted by Marttt View Post
this snippet is wrong (what is this bot variable) so is hard to help
try sharing the full .sp file
Dear Matt, hello.
Thank you for your reply

An entity named survivor_bot triggers twice in the process of changing the map, for example, when survivor_bot's entity index was 3, you can see that it triggers PrintToChatAll twice at the same time (1214.675903).
I think at the same time created two "survivor_bot", these two entities "survivor_bot" index is 3, it's strange.. I don't understand this process. What happened
Solar1234 is offline
Marttt
Veteran Member
Join Date: Jan 2019
Location: Brazil
Old 04-29-2024 , 21:29   Re: [L4D2] Why did it trigger twice? What happened in between
Reply With Quote #5

Dunno, may be related to the bot takeover event (bot being replaced by player). but is just a guess

What I do in these cases is having a global var that check if the hook event was already applied, and then ignore
Maybe this can help if you are having any bugs
__________________
Marttt is offline
Solar1234
Junior Member
Join Date: Nov 2021
Old 04-30-2024 , 00:56   Re: [L4D2] Why did it trigger twice? What happened in between
Reply With Quote #6

Quote:
Originally Posted by Marttt View Post
Dunno, may be related to the bot takeover event (bot being replaced by player). but is just a guess

What I do in these cases is having a global var that check if the hook event was already applied, and then ignore
Maybe this can help if you are having any bugs


I'll try to do that thanks for your advice
Solar1234 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 07:04.


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