Raised This Month: $32 Target: $400
 8% 

SDKHooks SetTransmit error?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Lux
Veteran Member
Join Date: Jan 2015
Location: Cat
Old 02-24-2017 , 11:52   SDKHooks SetTransmit error?
Reply With Quote #1

Hi, i can hook anyother entity and use SetTransmit but not env_instructor_hint...

i'm not sure what to do, wether it's a bug or not

i'm running SM version
SourceMod 1.9.0.6049.

i forgot to say this is for Left 4 Dead 2

Code:
#include <sourcemod>
#include <sdktools>
#include <sdkhooks>

public OnPluginStart()
{
    RegConsoleCmd("sm_test", iTest);
}
public Action:iTest(iClient, iArgs)
{
    static iEntity;
    iEntity = CreateEntityByName("env_instructor_hint");
    SDKHook(iEntity, SDKHook_SetTransmit, block);
}

public Action:block(iEntity, iClient)
{
    PrintToChatAll("iEntity = %i");
    return Plugin_Continue;
}
Any help would be appreciated

Orignal code:
Code:
static DirectorHint(iClient)
{
    static iEntity;
    iEntity = CreateEntityByName("env_instructor_hint");
    if(iEntity == -1)
        return;
    PrintToChatAll("iEntity = %i", iEntity);
    
    iHintRef[iClient] = EntIndexToEntRef(iEntity);
    SDKHook(iEntity, SDKHook_SetTransmit, hBlockTransmit);
    
    static String:sValues[51];
    Format(sValues, sizeof(sValues), "hint%d", iClient);
    DispatchKeyValue(iClient, "targetname", sValues);
    DispatchKeyValue(iEntity, "hint_target", sValues);
    
    Format(sValues, sizeof(sValues), "%i", iHintRange);
    DispatchKeyValue(iEntity, "hint_range", sValues);
    DispatchKeyValue(iEntity, "hint_icon_onscreen", "icon_alert");
    
    //Format(sValues, sizeof(sValues), "%f", fHintTime);
    Format(sValues, sizeof(sValues), "%f", fHintTime);
    DispatchKeyValue(iEntity, "hint_timeout", sValues);
    
    Format(sValues, sizeof(sValues), "%N(%s) is Black&White", iClient, sCharName);
    DispatchKeyValue(iEntity, "hint_caption", sValues);
    DispatchKeyValue(iEntity, "hint_color", sHintColour);
    DispatchSpawn(iEntity);
    AcceptEntityInput(iEntity, "ShowHint");
    
    Format(sValues, sizeof(sValues), "OnUser1 !self:Kill::%f:1", fHintTime);
    SetVariantString(sValues);
    AcceptEntityInput(iEntity, "AddOutput");
    AcceptEntityInput(iEntity, "FireUser1");
}

static bool:IsValidEntRef(iEntRef)
{
    static iEntity;
    iEntity = EntRefToEntIndex(iEntRef);
    return (iEntRef && iEntity != INVALID_ENT_REFERENCE && IsValidEntity(iEntity));
}

public Action:hBlockTransmit(iEntity, iClient)
{
    PrintToChatAll("%N entity %i", iClient, iEntity);
    if(IsValidEntRef(iHintRef[iClient]))
    {
        PrintToChatAll("blocking from %N entity %i", iClient, iEntity);
        return Plugin_Handled;
    }
        
    if(iTeamNoticeType == 2)
        return Plugin_Continue;
    
    if(iTeamNoticeType == 0)
        if(GetClientTeam(iClient) != 2)
            return Plugin_Handled;
    
    if(iTeamNoticeType == 1)
        if(GetClientTeam(iClient) != 3)
            return Plugin_Handled;
    
    return Plugin_Continue;
}
that is my orignal code
__________________
Connect
My Plugins: KlickME
[My GitHub]

Commission me for L4D

Last edited by Lux; 02-24-2017 at 14:05.
Lux is offline
Mitchell
~lick~
Join Date: Mar 2010
Old 02-24-2017 , 13:07   Re: SDKHooks SetTransmit error?
Reply With Quote #2

Why do you need to do SetTransmit on it?
Why not just do the input ShowHint to the specefic client you want to show it to?
Also you're not even using DispatchSpawn(iEntity); so it's not even spawning.
Mitchell is offline
Lux
Veteran Member
Join Date: Jan 2015
Location: Cat
Old 02-24-2017 , 13:57   Re: SDKHooks SetTransmit error?
Reply With Quote #3

Quote:
Originally Posted by Mitchell View Post
Why do you need to do SetTransmit on it?
Why not just do the input ShowHint to the specefic client you want to show it to?
Also you're not even using DispatchSpawn(iEntity); so it's not even spawning.
Yea in the main plugin i did everything you do to the entity, i see the hint but if you use ShowHint without the activator it will show it to everyone regardless, that is why i needed to use SetTransmit.

The hint is bugged
Bug: In , hints triggered by the ShowHint input are only visible to the player who activated the I/O chain.

Posted the orignal code that i had the issue with that should work yes?
__________________
Connect
My Plugins: KlickME
[My GitHub]

Commission me for L4D

Last edited by Lux; 02-24-2017 at 14:07.
Lux is offline
psychonic

BAFFLED
Join Date: May 2008
Old 02-24-2017 , 15:33   Re: SDKHooks SetTransmit error?
Reply With Quote #4

SetTransmit isn't called for edicts whose edict flags say to always transmit them. You can ditch that and set FL_EDICT_FULLCHECK to get it to be called.
psychonic is offline
friagram
Veteran Member
Join Date: Sep 2012
Location: Silicon Valley
Old 02-24-2017 , 21:14   Re: SDKHooks SetTransmit error?
Reply With Quote #5

Send the hint manually using a usermessage and set what clients it is sent to?
__________________
Profile - Plugins
Add me on steam if you are seeking sp/map/model commissions.
friagram is offline
Lux
Veteran Member
Join Date: Jan 2015
Location: Cat
Old 02-24-2017 , 21:27   Re: SDKHooks SetTransmit error?
Reply With Quote #6

Quote:
Originally Posted by psychonic View Post
SetTransmit isn't called for edicts whose edict flags say to always transmit them. You can ditch that and set FL_EDICT_FULLCHECK to get it to be called.
Code:
public Action:TestCmd(iClient, iArgs)
{
    //new iEntity = CreateEntityByName("env_instructor_hint");
    new iEntity = CreateEntityByName("env_instructor_hint");
    DispatchSpawn(iEntity);
    //SetEntityFlags(iEntity, FL_EDICT_FULLCHECK);
    SetEdictFlags(iEntity, FL_EDICT_FULLCHECK);
    SDKHook(iEntity, SDKHook_SetTransmit, block);
    PrintToChatAll("iEntity = %i", iEntity);
}

public Action:block(iEntity, iClient)
{
    PrintToChatAll("iEntity = %i, iClient = %N", iEntity, iClient);
}
setting the flags did not work either, however timocop showed me another way using valve's bug, but it requires 1entity per hint shown to clients



Code:

for(new i = 1; i <= MaxClients;i++)///This is just an example instead of using sdkhook and it requites more entitys tho
    {
        if(!IsClientInGame(i) || IsFakeClient(i))
            continue;
        
        if(iNoticeType == 3)
            DirectorHintAll(iClient, iHealer, i);
    }
///calling
static DirectorHint(iClient, i)
{
    static iEntity;
    iEntity = CreateEntityByName("env_instructor_hint");
    if(iEntity == -1)
        return;
    
    static String:sValues[51];
    FormatEx(sValues, sizeof(sValues), "hint%d", iClient);
    DispatchKeyValue(iClient, "targetname", sValues);
    DispatchKeyValue(iEntity, "hint_target", sValues);
    
    FormatEx(sValues, sizeof(sValues), "%i", iHintRange);
    DispatchKeyValue(iEntity, "hint_range", sValues);
    DispatchKeyValue(iEntity, "hint_icon_onscreen", "icon_alert");
    
    FormatEx(sValues, sizeof(sValues), "%f", fHintTime);
    DispatchKeyValue(iEntity, "hint_timeout", sValues);
    
    FormatEx(sValues, sizeof(sValues), "%N(%s) is Black&White", iClient, sCharName);
    DispatchKeyValue(iEntity, "hint_caption", sValues);
    DispatchKeyValue(iEntity, "hint_color", sHintColour);
    DispatchSpawn(iEntity);
    AcceptEntityInput(iEntity, "ShowHint", i);
    
    FormatEx(sValues, sizeof(sValues), "OnUser1 !self:Kill::%f:1", fHintTime);
    SetVariantString(sValues);
    AcceptEntityInput(iEntity, "AddOutput");
    AcceptEntityInput(iEntity, "FireUser1");
}
__________________
Connect
My Plugins: KlickME
[My GitHub]

Commission me for L4D
Lux is offline
friagram
Veteran Member
Join Date: Sep 2012
Location: Silicon Valley
Old 02-25-2017 , 10:02   Re: SDKHooks SetTransmit error?
Reply With Quote #7

Quote:
Originally Posted by friagram View Post
Send the hint manually using a usermessage and set what clients it is sent to?
__________________
Profile - Plugins
Add me on steam if you are seeking sp/map/model commissions.
friagram is offline
Lux
Veteran Member
Join Date: Jan 2015
Location: Cat
Old 02-25-2017 , 13:19   Re: SDKHooks SetTransmit error?
Reply With Quote #8

Not sure what you mean, but i want the hint to follow another entity with an arrow


DispatchKeyValue(iClient, "targetname", sValues); // you want hint to follow DispatchKeyValue(iEntity, "hint_target", sValues); // you want hint to follow
AcceptEntityInput(iEntity, "ShowHint", i); i = client to how hit to
__________________
Connect
My Plugins: KlickME
[My GitHub]

Commission me for L4D
Lux is offline
sdz
Senior Member
Join Date: Feb 2012
Old 02-26-2017 , 03:03   Re: SDKHooks SetTransmit error?
Reply With Quote #9

Quote:
Originally Posted by Ludastar View Post
Not sure what you mean, but i want the hint to follow another entity with an arrow


DispatchKeyValue(iClient, "targetname", sValues); // you want hint to follow DispatchKeyValue(iEntity, "hint_target", sValues); // you want hint to follow
AcceptEntityInput(iEntity, "ShowHint", i); i = client to how hit to

https://wiki.alliedmods.net/User_messages#Left_4_Dead_2_User_Messages
https://forums.alliedmods.net/showthread.php?t=80256

Last edited by sdz; 02-26-2017 at 03:04.
sdz is offline
Lux
Veteran Member
Join Date: Jan 2015
Location: Cat
Old 02-26-2017 , 13:31   Re: SDKHooks SetTransmit error?
Reply With Quote #10

Thankyou i did not know they exist, i will try and make heads or tails of them and use them if i can.
__________________
Connect
My Plugins: KlickME
[My GitHub]

Commission me for L4D
Lux is offline
Reply


Thread Tools
Display Modes

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 13:38.


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