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

CVARS?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Waleed
Senior Member
Join Date: May 2012
Location: Pakistan
Old 05-17-2012 , 17:25   CVARS?
Reply With Quote #1

Hey,There.


How to make CVARS for our own plugin like "csdm_active 1/0"

If it is register_cvar( , , , ,) //explain the 4 arguments please,How to set it to 1/0 condition: 1 - on/ 0 - off

Also what are flags like ADMIN_KICK
where can I get info about all flags?
__________________
Working On:
  1. Gameplay 1 - 0% [PAUSED]
Waleed is offline
Send a message via Skype™ to Waleed
Bilal Pro
Senior Member
Join Date: Mar 2012
Location: Holland
Old 05-17-2012 , 17:34   Re: CVARS?
Reply With Quote #2

Example.

PHP Code:
/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <amxmisc>

#define PLUGIN "New Plug-In"
#define VERSION "1.0"
#define AUTHOR "author"

new cvar // new array

public plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
cvar register_cvar("cvar_on""1"// were registering the cvar

and then at your function.

PHP Code:
public function(id)
{
    if (!(
cvar == 1)) // if it isnt 1 ! = not
    
{
        return 
PLUGIN_HANDLED
    
}
    
    
// continue code

EDIT: u can get the flags info at. addons/amxmodx/configs/users.ini
__________________
  • Point System with rank titles for sale [X] [100% private]
  • VIP Menu for sale [X] [100% private]
  • HnS shop more features for sale [X] [100% private]
Contact: Bilalzaandam1234, on steam if you are interested.

Last edited by Bilal Pro; 05-17-2012 at 17:43.
Bilal Pro is offline
Liverwiz
Veteran Member
Join Date: Feb 2010
Location: Maryland
Old 05-17-2012 , 17:46   Re: CVARS?
Reply With Quote #3

Quote:
Originally Posted by Bilal Pro View Post
new cvar // new array
Correction: it is a POINTER (pcvar) pointer to cvar
you retrieve the data with get_pcvar_num/float/flags etc
__________________
What an elegant solution to a problem that doesn't need solving....
Liverwiz is offline
<VeCo>
Veteran Member
Join Date: Jul 2009
Location: Bulgaria
Old 05-18-2012 , 04:42   Re: CVARS?
Reply With Quote #4

PHP Code:
 if (!(cvar == 1)) 
This should be:

PHP Code:
if(get_pcvar_num(cvar) != 1
That means if the value of the CVAR is not equal to 1. If you want to specify it only for 0 you can make it like this:

PHP Code:
if(get_pcvar_num(cvar) == 0
Or:

PHP Code:
if(!get_pcvar_num(cvar)) 
__________________
<VeCo> is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 05-18-2012 , 05:21   Re: CVARS?
Reply With Quote #5

Quote:
Originally Posted by Bilal Pro View Post
Example.

PHP Code:
/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <amxmisc>

#define PLUGIN "New Plug-In"
#define VERSION "1.0"
#define AUTHOR "author"

new cvar // new array

public plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
cvar register_cvar("cvar_on""1"// were registering the cvar

and then at your function.

PHP Code:
public function(id)
{
    if (!(
cvar == 1)) // if it isnt 1 ! = not
    
{
        return 
PLUGIN_HANDLED
    
}
    
    
// continue code

EDIT: u can get the flags info at. addons/amxmodx/configs/users.ini
Seriously, stop trying to help. You don't know what you are doing.
__________________
fysiks is offline
Bilal Pro
Senior Member
Join Date: Mar 2012
Location: Holland
Old 05-18-2012 , 05:38   Re: CVARS?
Reply With Quote #6

Lol, when you are changing the cvar you are changing the array so what is wrong on this -.-
__________________
  • Point System with rank titles for sale [X] [100% private]
  • VIP Menu for sale [X] [100% private]
  • HnS shop more features for sale [X] [100% private]
Contact: Bilalzaandam1234, on steam if you are interested.
Bilal Pro is offline
<VeCo>
Veteran Member
Join Date: Jul 2009
Location: Bulgaria
Old 05-18-2012 , 06:10   Re: CVARS?
Reply With Quote #7

The "cvar" variable is just an id, not the CVAR value itself. You need to use that id with get_pcvar_* to retrieve the value.
__________________
<VeCo> is offline
akcaliberg
Senior Member
Join Date: Nov 2011
Location: Istanbul
Old 05-18-2012 , 07:13   Re: CVARS?
Reply With Quote #8

@Bilal Pro

seriously, do you know scripting ? I don't know pawn scripting exactly. But I even know how to use a cvar.

Last edited by akcaliberg; 05-18-2012 at 07:17.
akcaliberg is offline
mottzi
Veteran Member
Join Date: May 2010
Location: Switzerland
Old 05-18-2012 , 07:18   Re: CVARS?
Reply With Quote #9

BTW: Bilal Pro, the variable you created isn't an array.
__________________
Quote:
#define true ((rand() % 2)? true: false) //Happy debugging suckers
mottzi is offline
Send a message via MSN to mottzi
Liverwiz
Veteran Member
Join Date: Feb 2010
Location: Maryland
Old 05-18-2012 , 08:54   Re: CVARS?
Reply With Quote #10

If all that confused you, without getting any real answers....here is a CORRECT example of how to define, initialize, and use a CVAR

This is pretty much a Copypasta of an old plugin of mine

PHP Code:
#include <amxmodx>
#include <cstrike>
#include <hamsandwich>        // WITH CHEESE!

#define PLUGIN    "CVAR Example"
#define AUTHOR    "LIverwiz"
#define VERSION    "0.1"
      
new g_16k_pcvar  // define your global cvar pointer (where your code stores the server's CVAR)

public plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR)
    
g_16k_pcvar register_cvar("amxx_16k""2")  // Making that CVAR in the server (amxx_16k) and then storing the pointer to your global
                               // As you can see i chose 2 to be the default value (in case the OP doesn't give it one, the server just uses these defined default values
    
    
RegisterHam(Ham_Spawn"player""ham_startMoney"1// you get to learn some hamsandwich too!
}


public 
ham_startMoney(id)
{            
    new 
i_cvarFlag get_pcvar_num(g_16k_pcvar)  // This gets your CVAR and stores its actual value to a variable (i chose i_cvarFlag)
    
if( (i_cvarFlag == || i_cvarFlag == 3) && !is_user_bot(id))  //This uses that variable and tests how the program is going to function, depending on what the OP defines it as
        
give_money(id)

Now i'm sure i got some of the lingo wrong for some of the PAWN purists. But This is a working example of how to give players money at spawn.

NOTE: give_money() function is NOT shown. It is defined later in the code. I just cut the code down for ease of reading. Good luck!
__________________
What an elegant solution to a problem that doesn't need solving....
Liverwiz 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 01:40.


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