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

[L4D2] AutoHelp


Post New Thread Reply   
 
Thread Tools Display Modes
AK978
Senior Member
Join Date: Jun 2018
Old 01-07-2022 , 07:08   Re: [L4D2] AutoHelp
Reply With Quote #61

https://forums.alliedmods.net/showthread.php?t=321089#9

GetClientUserId to store a clients userid (each new client connecting has a userid + 1 to the last person who joined).
GetClientOfUserId to retrieve a clients index from userid, if they have disconnected the value will be 0. Must use with IsClientInGame too.

EntIndexToEntRef to store an entity index by converting it into a unique serial reference.
EntRefToEntIndex to retrieve an entity index from a reference, if the entity no longer exists the value will be -1 (INVALID_ENT_REFERENCE).


CreateTimer(10.0, XXX, GetClientUserId(client));

public Action XXX(Handle timer, any client)
{
client = GetClientOfUserId(client);
if( client != 0 && IsClientInGame(client) )
{
......
}
}

Last edited by AK978; 01-07-2022 at 19:21.
AK978 is offline
Psyk0tik
Veteran Member
Join Date: May 2012
Location: Homeless
Old 01-07-2022 , 08:19   Re: [L4D2] AutoHelp
Reply With Quote #62

Quote:
Originally Posted by Shadowysn View Post
Thanks.
I read your old comment before it was deleted.
I keep being unsure about GetClientOfUserId, GetClientUserId and such when passing them into timers so I just default to not using them at all.
The reason we pass user IDs and entity refs to timers is because there's no guarantee that another client or entity won't take over the client/entity index that we are working with. User IDs and entity refs make sure we get the right clients/entities. Here are some examples to help you understand:
PHP Code:
// entities
CreateTimer(0.1tTimerDeleteEntityEntIndexToEntRef(entity));

Action tTimerDeleteEntity(Handle timerint ref)
{
    
int entity EntRefToEntIndex(ref);
    if (
entity == INVALID_ENT_REFERENCE || !IsValidEntity(entity))
    {
        return 
Plugin_Stop;
    }

    
// ...
    
return Plugin_Continue;
}

// clients
CreateTimer(0.1tTimerKickClientGetClientUserId(client));

Action tTimerKickClient(Handle timerint userid)
{
    
int client GetClientOfUserId(userid);
    if (
client <= || client MaxClients || !IsClientInGame(client))
    {
        return 
Plugin_Stop;
    }

    
// ...
    
return Plugin_Continue;

__________________
Psyk0tik is offline
AK978
Senior Member
Join Date: Jun 2018
Old 01-07-2022 , 19:21   Re: [L4D2] AutoHelp
Reply With Quote #63

if client timer use TIMER_REPEAT:
if (!IsValidClient(client)) return Plugin_Stop(Plugin_Stop will auto kill timer);
stop invalid client timer.
https://wiki.alliedmods.net/Timers_(SourceMod_Scripting)

test.
only ledge(my server use version).
Attached Files
File Type: sp Get Plugin or Get Source (cge_l4d2_autohelp_test.sp - 206 views - 31.6 KB)
File Type: sp Get Plugin or Get Source (cge_l4d2_autohelp_ledge.sp - 137 views - 13.9 KB)

Last edited by AK978; 01-16-2022 at 01:33.
AK978 is offline
ZzZombo
Member
Join Date: May 2012
Location: Ravenholm
Old 05-04-2022 , 01:32   Re: [L4D2] AutoHelp
Reply With Quote #64

Doesn't appear to work anymore? I set it to recover players from incapacitation and ledge hanging, but not from SI pinning attacks, and even after half a minute nobody would get back up.
ZzZombo is offline
wakwaw300
Junior Member
Join Date: Oct 2022
Old 05-22-2023 , 00:54   Re: [L4D2] AutoHelp
Reply With Quote #65

L 05/22/2023 - 11:29:26: [SM] Blaming: cge_l4d2_autohelp.smx
L 05/22/2023 - 11:29:26: [SM] Call stack trace:
L 05/22/2023 - 11:29:26: [SM] [0] SlapPlayer
L 05/22/2023 - 11:29:26: [SM] [1] Line 667, /home/forums/content/files/6/6/3/4/6/109650.attach::Timer_SlapPlayer
wakwaw300 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 12:54.


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