Raised This Month: $ Target: $400
 0% 

Not printing text


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
KamiN
Senior Member
Join Date: Jun 2011
Old 11-24-2011 , 16:09   Not printing text
Reply With Quote #1

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

Last edited by KamiN; 11-24-2011 at 16:10.
KamiN is offline
Xellath
Veteran Member
Join Date: Dec 2007
Location: Sweden
Old 11-24-2011 , 16:42   Re: Not printing text
Reply With Quote #2

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')     {         } }
__________________
Achievements API - a simple way for you to create your OWN custom achievements!
Xellath is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 11-25-2011 , 01:13   Re: Not printing text
Reply With Quote #3

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 =/")
        }
    }

__________________
- tired and retired -

- my plugins -

Last edited by ConnorMcLeod; 11-25-2011 at 01:17.
ConnorMcLeod 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 08:31.


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