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

New API and Syntax


Post New Thread Reply   
 
Thread Tools Display Modes
kot4404
Senior Member
Join Date: Mar 2013
Old 01-17-2018 , 15:07   Re: New API and Syntax
Reply With Quote #901

Quote:
Originally Posted by Crasher_3637 View Post
I use this check to exclude idle players from seeing vote menus:

PHP Code:
bool bIsPlayerIdle(int client)
{
    if (
GetClientTeam(client) != 1)
    {
        return 
false;
    }

    for (
int iPlayer 1iPlayer <= MaxClientsiPlayer++)
    {
        if (
bIsSurvivor(iPlayer) && IsFakeClient(iPlayer))
        {
            if (
GetClientOfUserId(GetEntProp(iPlayerProp_Send"m_humanSpectatorUserID")) == client)
            return 
true;
        }
    }

    return 
false;

Seems to work for me.
Do you think it is possible to use this method in https://forums.alliedmods.net/showthread.php?p=2521418 plugin?

Quote:
Originally Posted by kot4404 View Post
This thing actually fully works with L4D2, the admins aren't visible in status commands

Edit*
Or not that fully 100% because being idle renames you to unconnected but the other things work
Not sure if i'm adding it wrong or the game just doesn't allow that but my nickname is completly removed from the game setting my nick to unconnected when i'm idle or just stays completly visible
kot4404 is offline
Visual77
Veteran Member
Join Date: Jan 2009
Old 01-20-2018 , 13:00   Re: New API and Syntax
Reply With Quote #902

Hi. Can anyone explain the difference between using a timer and RequestFrame.
Which one is better? I assume that RequestFrame fires during mapchange aswell. Anyway to prevent that?

1. CreateTimer(0.1, doSomething, client, TIMER_FLAG_NO_MAPCHANGE);
2. RequestFrame(doSomething, client);
Visual77 is offline
headline
SourceMod Moderator
Join Date: Mar 2015
Old 01-20-2018 , 13:02   Re: New API and Syntax
Reply With Quote #903

Quote:
Originally Posted by Visual77 View Post
Hi. Can anyone explain the difference between using a timer and RequestFrame.
Which one is better? I assume that RequestFrame fires during mapchange aswell. Anyway to prevent that?

1. CreateTimer(0.1, doSomething, client, TIMER_FLAG_NO_MAPCHANGE);
2. RequestFrame(doSomething, client);
A timer can wait any amount of time and then fire, while RequestFrame will wait only a single frame. This difference should be enough for you to know which one to use in a given scenario.

Last edited by headline; 01-20-2018 at 13:02.
headline is offline
Visual77
Veteran Member
Join Date: Jan 2009
Old 01-20-2018 , 13:11   Re: New API and Syntax
Reply With Quote #904

Quote:
Originally Posted by Headline View Post
A timer can wait any amount of time and then fire, while RequestFrame will wait only a single frame.
So RequestFrame is basically faster? I'm pretty sure I read somewhere that a timer of 0.1 seconds also fires during the next frame (1 frame?)

So say I want to use RequestFrame but I don't want the callback to run on the client during a mapchange. Is that possible? Would a !IsClientInGame check suffice maybe?

Last edited by Visual77; 01-20-2018 at 13:15.
Visual77 is offline
headline
SourceMod Moderator
Join Date: Mar 2015
Old 01-20-2018 , 13:14   Re: New API and Syntax
Reply With Quote #905

Quote:
Originally Posted by Visual77 View Post
So RequestFrame is basically faster? I'm pretty sure I read somewhere that a timer of 0.1 seconds also fires during the next frame (1 frame?)

So say I want to use RequestFrame but I don't want the callback to run on the client during a mapchange. Is that possible?
I believe a 0.0 second timer will fire on the next frame, then you can just use the timer flag for no map changes

PS: this is a better question for its own thread. Make a new thread next time :p

Last edited by headline; 01-20-2018 at 13:15.
headline is offline
Lux
Veteran Member
Join Date: Jan 2015
Location: Cat
Old 01-20-2018 , 13:16   Re: New API and Syntax
Reply With Quote #906

Quote:
Originally Posted by Visual77 View Post
So RequestFrame is basically faster? I'm pretty sure I read somewhere that a timer of 0.1 seconds also fires during the next frame (1 frame?)

So say I want to use RequestFrame but I don't want the callback to run on the client during a mapchange. Is that possible?
If your that worried about mapchanges check the map string to the current
__________________
Connect
My Plugins: KlickME
[My GitHub]

Commission me for L4D
Lux is offline
Visual77
Veteran Member
Join Date: Jan 2009
Old 01-20-2018 , 13:21   Re: New API and Syntax
Reply With Quote #907

Quote:
Originally Posted by Headline View Post
I believe a 0.0 second timer will fire on the next frame, then you can just use the timer flag for no map changes

PS: this is a better question for its own thread. Make a new thread next time :p
Alright. I'll try with a 0.0 timer. I thought RequestFrame was sourcemod 1.8 API so that's why I posted here. Apperently RequestFrame has existed since sourcemod 1.6.0
Visual77 is offline
Visual77
Veteran Member
Join Date: Jan 2009
Old 01-20-2018 , 13:24   Re: New API and Syntax
Reply With Quote #908

Quote:
Originally Posted by Lux View Post
If your that worried about mapchanges check the map string to the current
Show me with code please if you can.
Visual77 is offline
Lux
Veteran Member
Join Date: Jan 2015
Location: Cat
Old 01-20-2018 , 15:16   Re: New API and Syntax
Reply With Quote #909

Quote:
Originally Posted by Visual77 View Post
Show me with code please if you can.
I did not see Headline's post, does the samething and is muchmore simple

Quote:
Originally Posted by Headline View Post
I believe a 0.0 second timer will fire on the next frame, then you can just use the timer flag for no map changes

PS: this is a better question for its own thread. Make a new thread next time :p
__________________
Connect
My Plugins: KlickME
[My GitHub]

Commission me for L4D
Lux is offline
Psyk0tik
Veteran Member
Join Date: May 2012
Location: Homeless
Old 01-20-2018 , 20:13   Re: New API and Syntax
Reply With Quote #910

Quote:
Originally Posted by kot4404 View Post
Do you think it is possible to use this method in https://forums.alliedmods.net/showthread.php?p=2521418 plugin?



Not sure if i'm adding it wrong or the game just doesn't allow that but my nickname is completly removed from the game setting my nick to unconnected when i'm idle or just stays completly visible
I forgot to post this extra check that I use. It checks first if the client is a bot controlled by an idle player before bIsPlayerIdle is even checked. Feel free to mess around with it to get it working for you.

PHP Code:
bool bHasIdlePlayer(int client)
{
    if (
bIsSurvivor(client) && IsFakeClient(client))
    {
        
int iIdler GetClientOfUserId(GetEntProp(clientProp_Send"m_humanSpectatorUserID"));
        if (
iIdler)
        {
            if(!
IsFakeClient(iIdler) && (GetClientTeam(iIdler) == 1))
            {
                return 
true;
            }
        }
    }

    return 
false;

This is how I applied both of them.

PHP Code:
bool bIsHumanSurvivor(int client)
{
    return (
client && client <= MaxClients && IsClientConnected(client) && IsClientInGame(client) && GetClientTeam(client) == && IsPlayerAlive(client) && !IsClientInKickQueue(client) && !IsFakeClient(client) && IsValidEntity(client) && !bHasIdlePlayer(client) && !bIsPlayerIdle(client));

PHP Code:
void vMenuViewers()
{
    for (
int iVoter 1iVoter <= MaxClientsiVoter++)
    {
        if (!
bIsHumanSurvivor(iVoter))
        {
            continue;
        }

        
iHumanSurvivors[iTotalHumans++] = iVoter;
    }

If you need further help, please make a new thread.
__________________

Last edited by Psyk0tik; 01-22-2018 at 18:24.
Psyk0tik 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 00:48.


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