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

Solved alltalk with timer


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Langejannik
Junior Member
Join Date: Jul 2023
Old 07-18-2023 , 13:18   alltalk with timer
Reply With Quote #1

Hi there
I'm looking for a plugin where admin can enable all talk, I've looked at almost all the plugins out there at the moment.
It is precisely what the admin must be able to activate / deactivate all talk, but if an admin forgets to deactivate, it automatically deactivates after a desired time. it is for DOD/CS 1.6

Last edited by Langejannik; 08-04-2023 at 15:49.
Langejannik is offline
bigdaddy424
Senior Member
Join Date: Oct 2021
Location: Jupiter
Old 07-18-2023 , 17:20   Re: alltalk with timer
Reply With Quote #2

are you talking about sv_alltalk?
__________________
bigdaddy424 is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 07-18-2023 , 22:51   Re: alltalk with timer
Reply With Quote #3

Here is a quick one that I created (the admin command I pulled from a private plugin so I know it works; I just added the automatic disabling of alltalk):

PHP Code:
#include <amxmodx>
#include <amxmisc>

new g_pAlltalk
new g_pAlltalkDelayedDisable

public plugin_init()
{
    
register_plugin("amx_alltalk""1.1""Fysiks")
    
register_concmd("amx_alltalk""cmdAlltalk"ADMIN_CHAT"[value] - Sets sv_alltalk cvar.  Shows current value if no argument.")
    
    
g_pAlltalkDelayedDisable register_cvar("amx_alltalk_delayed_disable""60.0")
}

public 
plugin_cfg()
{
    
g_pAlltalk get_cvar_pointer("sv_alltalk")
    
set_task(get_pcvar_float(g_pAlltalkDelayedDisable), "delayedDisableAlltalk")
}

public 
cmdAlltalk(idlevelcid)
{
    if( !
cmd_access(idlevelcid1) )
    {
        return 
PLUGIN_HANDLED
    
}
    
    if( 
read_argc() > )
    {
        
// Set sv_alltalk value
        
new szArg[3], iArg
        read_argv
(1szArgcharsmax(szArg))
        
iArg str_to_num(szArg)
        
set_pcvar_num(g_pAlltalkiArg)
        
        
set_hudmessage(random(256), random(256), random(256), 0.050.4)
        
show_hudmessage(0"Alltalk is %s", ((iArg == 0) ? "Disabled" "Enabled"))
        
console_print(id"Alltalk is %s"iArg != "On" "Off")
    }
    else
    {
        
console_print(id"Alltalk is %s"get_pcvar_num(g_pAlltalk) != "On" "Off")
    }

    return 
PLUGIN_HANDLED
}

public 
delayedDisableAlltalk()
{
    
set_pcvar_num(g_pAlltalk0)

__________________

Last edited by fysiks; 07-19-2023 at 22:59.
fysiks is offline
Langejannik
Junior Member
Join Date: Jul 2023
Old 07-19-2023 , 14:18   Re: alltalk with timer
Reply With Quote #4

I just can't get it to work, it doesn't turn off alltalk.
If I understand correctly. then activate alltalk with amx_alltalk 1
and disable with amx_alltalk 0
but I have not experienced that it does it by itself, how long have you set it to ?
And what admin lever ?

Last edited by Langejannik; 07-19-2023 at 16:37.
Langejannik is offline
bigdaddy424
Senior Member
Join Date: Oct 2021
Location: Jupiter
Old 07-19-2023 , 18:36   Re: alltalk with timer
Reply With Quote #5

assuming this works it should behave as you explained
added: changing sv_alltalk value to 1, seconds before map change will automatically switch back to shut value
PHP Code:
#include <amxmodx>
#define TASK 512
#define SHUT_AFTER 5*60 // minutes

new pointer
// refer: https://github.com/s1lentq/ReGameDLL_CS/wiki/sv_alltalk
new const shut_value 2

public plugin_init(){
    
pointer get_cvar_pointer("sv_alltalk")
    
hook_cvar_change(pointer"CVAR_alltalk")
}

public 
plugin_cfg(){
    if (
get_pcvar_num(pointer) == 1)
        
shut_alltalk()
}

public 
CVAR_alltalk(pcvar, const old_value[], const new_value[]){
    if (
task_exists(TASK))
        
remove_task(TASK)

    if (
str_to_num(new_value) == 1)
        
set_task(float(SHUT_AFTER), "shut_alltalk"TASK)
}

public 
shut_alltalk()
    
set_pcvar_num(pointershut_value
__________________

Last edited by bigdaddy424; 07-19-2023 at 18:37.
bigdaddy424 is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 07-19-2023 , 23:01   Re: alltalk with timer
Reply With Quote #6

Quote:
Originally Posted by Langejannik View Post
I just can't get it to work, it doesn't turn off alltalk.
If I understand correctly. then activate alltalk with amx_alltalk 1
and disable with amx_alltalk 0
but I have not experienced that it does it by itself, how long have you set it to ?
And what admin lever ?
I made a small typo that prevented the auto-disable from working. I fixed the code in my original post so it will work this time.

As you said "amx_alltalk 1" will enable alltalk and "amx_alltalk 0" will disable it. If 60 seconds has passed since the beginning of the map, alltalk is disabled. This 60 seconds can be changed with a cvar "amx_alltalk_delayed_disable".

I think you're meaning to ask about "admin flags". You can see (and change) what flag is required for nearly all commands in cmdaccess.ini in the AMX Mod X configs folder.

It seems I interpreted your request differently than bigdaddy424 so his code can be added to mine. I'm not sure why he thinks that turning off alltalk is setting it to a value of 2 though (from what I can tell, that's not a supported thing in the original game). I've created a version of mine with the way he interpreted it:

PHP Code:
#include <amxmodx>
#include <amxmisc>

new g_pAlltalk
new g_pAlltalkAutoDisableTime
new const ALLTALK_TASK 16546557

public plugin_init()
{
    
register_plugin("amx_alltalk""1.0b""Forum Members")
    
register_concmd("amx_alltalk""cmdAlltalk"ADMIN_CHAT"[value] - Sets sv_alltalk cvar.  Shows current value if no argument.")
    
    
g_pAlltalkAutoDisableTime register_cvar("amx_alltalk_auto_disable_time""60.0")
}

public 
plugin_cfg()
{
    
g_pAlltalk get_cvar_pointer("sv_alltalk")
    
set_pcvar_num(g_pAlltalk0)
    
hook_cvar_change(g_pAlltalk"fwCvarSvAlltalkChanged")
}

public 
cmdAlltalk(idlevelcid)
{
    if( !
cmd_access(idlevelcid1) )
    {
        return 
PLUGIN_HANDLED
    
}
    
    if( 
read_argc() > )
    {
        
// Set sv_alltalk value
        
new szArg[3], iArg
        read_argv
(1szArgcharsmax(szArg))
        
iArg str_to_num(szArg)
        
setAlltalkState(iArg)
        
console_print(id"Alltalk is %s"iArg != "On" "Off")
    }
    else
    {
        
console_print(id"Alltalk is %s"get_pcvar_num(g_pAlltalk) != "On" "Off")
    }

    return 
PLUGIN_HANDLED
}

stock setAlltalkState(desiredState)
{
    
set_pcvar_num(g_pAlltalkdesiredState)
    
    
set_hudmessage(random(256), random(256), random(256), 0.050.4)
    
show_hudmessage(0"Alltalk is %s", ((desiredState == 0) ? "Disabled" "Enabled"))
}

public 
fwCvarSvAlltalkChanged(pcvar, const old_value[], const new_value[])
{
    
remove_task(ALLTALK_TASK)

    if( 
str_to_num(new_value) == )
        
set_task(get_pcvar_float(g_pAlltalkAutoDisableTime), "autoDisableAlltalk"ALLTALK_TASK)
}

public 
autoDisableAlltalk()
{
    
setAlltalkState(0)

__________________

Last edited by fysiks; 07-19-2023 at 23:37.
fysiks is offline
Langejannik
Junior Member
Join Date: Jul 2023
Old 07-29-2023 , 09:30   Re: alltalk with timer
Reply With Quote #7

Heey Fysiks

Thank you very much for your solution
Langejannik 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 06:41.


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