AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Not printing text (https://forums.alliedmods.net/showthread.php?t=172691)

KamiN 11-24-2011 16:09

Not printing text
 
Code:

...

public plugin_init() {
.....
    register_clcmd("say /snowon", "snowon")
    register_clcmd("say /snowoff", "snowoff")
.....
}

....

public snowon(index)
{
    query_client_cvar ( index, "cl_weather", "check_cvar_valueon" )
}

public check_cvar_valueon ( index, cvar, value )
{
    if ((value == 1) || (value == 2) || (value == 3))
    {
        client_print ( index, print_chat, "You have already started snowing :))" )
        return PLUGIN_HANDLED;
    }
    else {
        client_cmd(index, "cl_weather 3");
        client_print ( index, print_chat, "You have started snowing :))" )
    }

    return PLUGIN_HANDLED;



public snowoff(index)
{
    query_client_cvar ( index, "cl_weather", "check_cvar_valueoff" )
}

public check_cvar_valueoff ( index, cvar, value )
{

    if (value == 0)
    {
        client_print ( index, print_chat, "You have already stopped snowing =/" )
        return PLUGIN_HANDLED;
    }
    else {
        client_cmd(index, "cl_weather 0");
        client_print ( index, print_chat, "You have stopped snowing =/" )
    }

    return PLUGIN_HANDLED;

}

It doesnt prints
Code:

client_print ( index, print_chat, "You have already started snowing :))" )
and
Code:

client_print ( index, print_chat, "You have already stopped snowing =/" )
Why?

No matters how many times i write /snowon or /snowoff these two lines never shows

Xellath 11-24-2011 16:42

Re: Not printing text
 
The result function parameters are: index, cvar[ ], value[ ]; and you're passing integers.

Change
Code:
public check_cvar_valueon ( index, cvar, value ) {     if ((value == 1) || (value == 2) || (value == 3))     {         } }
to
Code:
public check_cvar_valueon ( index, cvar[ ], value[ ] ) {     if (value[0] == '1')     {         } }

ConnorMcLeod 11-25-2011 01:13

Re: Not printing text
 
Also you may want to use the same callback, you can use extra arg params for that.

query_client_cvar

PHP Code:

public plugin_init() 
{
    
register_clcmd("say /snowon""ClCmd_SnowOn")
    
register_clcmd("say /snowoff""ClCmd_SnowOff")
}

public 
ClCmd_SnowOnid 
{
    new 
parms[1]
    
parms[0] = true
    query_client_cvar
(id"cl_weather""ClWeather_Result"1parms)
}

public 
ClCmd_SnowOffid 

    new 
parms[1]
    
parms[0] = false
    query_client_cvar
(id"cl_weather""ClWeather_Result"1parms)
}

public 
ClWeather_Result(id, const cvar[], const value[], const parms[])
{
    if( 
str_to_float(value) ) // has snow
    
{
        if( 
parms[0] ) // wants snow
        
{
            
client_print(idprint_chat"You have already started snowing :))" )
        }
        else 
// doesn't want snow
        
{
            
client_cmd(id"cl_weather 0")
            
client_print(idprint_chat"You have stopped snowing =/")
        }
    }
    else 
// has NO snow
    
{
        if( 
parms[0] ) // wants snow
        
{
            
client_print(idprint_chat"You have already stopped snowing =/")
            
client_cmd(id"cl_weather 3")
        }
        else 
// doesn't want snow
        
{
            
client_print(idprint_chat"You have already stopped snowing =/")
        }
    }




All times are GMT -4. The time now is 08:32.

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