AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting (https://forums.alliedmods.net/forumdisplay.php?f=107)
-   -   [L4D2] Why did it trigger twice? What happened in between (https://forums.alliedmods.net/showthread.php?t=347469)

Solar1234 04-28-2024 08:51

[L4D2] Why did it trigger twice? What happened in between
 
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

Marttt 04-28-2024 20:18

Re: [L4D2] Why did it trigger twice? What happened in between
 
this snippet is wrong (what is this bot variable) so is hard to help
try sharing the full .sp file

Solar1234 04-29-2024 09:03

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

Originally Posted by Marttt (Post 2821761)
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 04-29-2024 09:12

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

Originally Posted by Marttt (Post 2821761)
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

Marttt 04-29-2024 21:29

Re: [L4D2] Why did it trigger twice? What happened in between
 
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

Solar1234 04-30-2024 00:56

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

Originally Posted by Marttt (Post 2821819)
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:)


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

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