AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Server lot for hltv (https://forums.alliedmods.net/showthread.php?t=95667)

usabrad86 06-25-2009 23:12

Server lot for hltv
 
ok I am seriously trying to learn how to code just need some help to get me to understand on how to do it

what i need is to grab sv_visiblemaxplayers value and +1 when a the HLTV enters and -1 for exit and i need this to override any other plugin that changes that cvar

the code i made Crashes and i tossed it out..now im askin for help :(

fysiks 06-25-2009 23:36

Re: Server lot for hltv
 
Try this maybe:

PHP Code:

#include <amxmodx>

new g_pVisMaxPlayers
new g_iVisMaxPlayers

public plugin_init()
{
    
g_pVisMaxPlayers get_cvar_pointer("sv_visiblemaxplayers")
}

public 
client_connect(id)
{
    if( 
is_user_hltv(id) )
    {
        
g_iVisMaxPlayers get_pcvar_num(g_pVisMaxPlayers)
        
g_iVisMaxPlayers++
        
set_pcvar_num(g_pVisMaxPlayersg_iVisMaxPlayers)
    }
}

public 
client_disconnect(id)
{
    if( 
is_user_hltv(id) )
    {
        
g_iVisMaxPlayers get_pcvar_num(g_pVisMaxPlayers)
        
g_iVisMaxPlayers--
        
set_pcvar_num(g_pVisMaxPlayersg_iVisMaxPlayers)
    }



usabrad86 06-26-2009 00:30

Re: Server lot for hltv
 
OK Tested it 1/2 way works


before HLTV enters = 0/10
when hltv enters = 1/11
when hltv left = 0/9

ConnorMcLeod 06-26-2009 00:42

Re: Server lot for hltv
 
Try this:
PHP Code:

#include <amxmodx>

new sv_visiblemaxplayers

new g_bIsHLTV[33]

public 
plugin_init()
{
    
sv_visiblemaxplayers get_cvar_pointer("sv_visiblemaxplayers")
}

public 
client_putinserver(id)
{
    if( (
g_bIsHLTV[id] = is_user_hltv(id)) )
    {
        
set_pcvar_num(sv_visiblemaxplayersget_pcvar_num(sv_visiblemaxplayers)+1)
    }
}

public 
client_disconnect(id)
{
    if( 
g_bIsHLTV[id] )
    {
        
set_pcvar_num(sv_visiblemaxplayersget_pcvar_num(sv_visiblemaxplayers)-1)
    }


If doesn't work, try this :
PHP Code:

#include <amxmodx>

new sv_visiblemaxplayers
new g_bMaxPlayers
new g_bIsHLTV[33]

public 
plugin_init()
{
    
sv_visiblemaxplayers get_cvar_pointer("sv_visiblemaxplayers")
    
g_bMaxPlayers get_maxplayers()
}

public 
client_putinserver(id)
{
    if( (
g_bIsHLTV[id] = is_user_hltv(id)) )
    {
        
set_pcvar_num(sv_visiblemaxplayersg_bMaxPlayers CoundHltvs())
    }
}

public 
client_disconnect(id)
{
    if( 
g_bIsHLTV[id] )
    {
        
g_bIsHLTV[id] = false
        set_pcvar_num
(sv_visiblemaxplayersg_bMaxPlayers CoundHltvs())
    }
}

CoundHltvs()
{
    new 
iCount
    
for(new i=1i<=g_iMaxPlayersi++)
    {
        if( 
g_bIsHLTV[i] )
        {
            
iCount++
        }
    }
    return 
iCount



usabrad86 06-26-2009 01:05

Re: Server lot for hltv
 
this does the same thing as the other guys script

before HLTV enters = 0/10
when hltv enters = 1/11
when hltv left = 0/9

Quote:

Originally Posted by ConnorMcLeod (Post 857258)
PHP Code:

#include <amxmodx>

new sv_visiblemaxplayers

new g_bIsHLTV[33]

public 
plugin_init()
{
    
sv_visiblemaxplayers get_cvar_pointer("sv_visiblemaxplayers")
}

public 
client_putinserver(id)
{
    if( (
g_bIsHLTV[id] = is_user_hltv(id)) )
    {
        
set_pcvar_num(sv_visiblemaxplayersget_pcvar_num(sv_visiblemaxplayers)+1)
    }
}

public 
client_disconnect(id)
{
    if( 
g_bIsHLTV[id] )
    {
        
set_pcvar_num(sv_visiblemaxplayersget_pcvar_num(sv_visiblemaxplayers)-1)
    }



-----------------------------------------------------------------------
and this one fails to compile on

g_bIsHLTV[i] = false
Error: Undefined symbol "i"

and

for(new i=1; i<=g_iMaxPlayers; i++)
Error Undefined symbol "g_iMaxPlayers"


Quote:

Originally Posted by ConnorMcLeod (Post 857258)
If doesn't work, try this :
PHP Code:

#include <amxmodx>

new sv_visiblemaxplayers
new g_bMaxPlayers
new g_bIsHLTV[33]

public 
plugin_init()
{
    
sv_visiblemaxplayers get_cvar_pointer("sv_visiblemaxplayers")
    
g_bMaxPlayers get_maxplayers()
}

public 
client_putinserver(id)
{
    if( (
g_bIsHLTV[id] = is_user_hltv(id)) )
    {
        
set_pcvar_num(sv_visiblemaxplayersg_bMaxPlayers CoundHltvs())
    }
}

public 
client_disconnect(id)
{
    if( 
g_bIsHLTV[id] )
    {
        
g_bIsHLTV[id] = false
        set_pcvar_num
(sv_visiblemaxplayersg_bMaxPlayers CoundHltvs())
    }
}

CoundHltvs()
{
    new 
iCount
    
for(new i=1i<=g_iMaxPlayersi++)
    {
        if( 
g_bIsHLTV[i] )
        {
            
iCount++
        }
    }
    return 
iCount



And I am more then willing to test more code so Other People can use it

also Thank you so much Everybody for the Help

usabrad86 06-26-2009 01:23

Re: Server lot for hltv
 
THIS CODE DOES WORK
i just had a another plugin causeing it to go to 0/9

i commented out the "public client_disconnect" area
and it worked fine

Quote:

Originally Posted by fysiks (Post 857239)
Try this maybe:

PHP Code:

#include <amxmodx>

new g_pVisMaxPlayers
new g_iVisMaxPlayers

public plugin_init()
{
    
g_pVisMaxPlayers get_cvar_pointer("sv_visiblemaxplayers")
}

public 
client_connect(id)
{
    if( 
is_user_hltv(id) )
    {
        
g_iVisMaxPlayers get_pcvar_num(g_pVisMaxPlayers)
        
g_iVisMaxPlayers++
        
set_pcvar_num(g_pVisMaxPlayersg_iVisMaxPlayers)
    }
}

public 
client_disconnect(id)
{
    if( 
is_user_hltv(id) )
    {
        
g_iVisMaxPlayers get_pcvar_num(g_pVisMaxPlayers)
        
g_iVisMaxPlayers--
        
set_pcvar_num(g_pVisMaxPlayersg_iVisMaxPlayers)
    }




fysiks 06-26-2009 18:43

Re: Server lot for hltv
 
Yeah, I just realized my code has a flaw, oops :).


All times are GMT -4. The time now is 15:33.

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