AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   cmd check (https://forums.alliedmods.net/showthread.php?t=172669)

KamiN 11-24-2011 10:26

cmd check
 
How to check if cl_weather is already 3?

Code:

public snowon(id)
{
    client_cmd(id, "cl_weather 3");
    client_print(id, print_chat, "You'v turned on the snow.")
    return PLUGIN_HANDLED;
}

If theres already cl_weather 3 i'd like to type a diffrenet text, like "Its already snowing".

Korxu 11-24-2011 10:54

Re: cmd check
 
query_client_cvar ( ) ?

KamiN 11-24-2011 12:56

Re: cmd check
 
could u give me an example with cl_weather?

Korxu 11-24-2011 13:12

Re: cmd check
 
PHP Code:

// Your function.
public snowon index )
{
     
query_client_cvar index"cl_weather""check_cvar_value" )
}

public 
check_cvar_value indexcvar [ ], value [ ] )
{
     
// If the value is different of '3', change it to '3'.
     
if ( value ] != '3' )
     {
          
client_cmd index"cl_weather 3" )
     }

     
// And show the message.
     
client_print indexprint_chat"You have turned on the snow." )



KamiN 11-24-2011 15:49

Re: cmd check
 
Code:

index
is the same as
Code:

id
? ^_^

Erox902 11-24-2011 16:15

Re: cmd check
 
Quote:

Originally Posted by KamiN (Post 1602079)
Code:

index
is the same as
Code:

id
? ^_^

Well yes but you cannot simply put client_print( id ... or something like that in those functions,
cuz' index is the created parameter for your function. If you were to replace:
PHP Code:

public snowon index 

with this:
PHP Code:

public snowon id 

id would be the created parameter then you'd be able to do client_print(id...
but not client_print( index...

drekes 11-24-2011 19:19

Re: cmd check
 
Quote:

Originally Posted by KamiN (Post 1602079)
Code:

index
is the same as
Code:

id
? ^_^

Index or id are just variable names. You can name them whatever you want.
id is most used to hold a player index.


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

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