Raised This Month: $ Target: $400
 0% 

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
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 05-18-2012 , 05:21   Re: CVARS?
Reply With Quote #4

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
<VeCo>
Veteran Member
Join Date: Jul 2009
Location: Bulgaria
Old 05-18-2012 , 04:42   Re: CVARS?
Reply With Quote #5

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
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
Liverwiz
Veteran Member
Join Date: Feb 2010
Location: Maryland
Old 05-18-2012 , 08:55   Re: CVARS?
Reply With Quote #7

Quote:
Originally Posted by Bilal Pro View Post
Lol, when you are changing the cvar you are changing the array so what is wrong on this -.-
almost everything. How the hell does ANY of your code work?
__________________
What an elegant solution to a problem that doesn't need solving....
Liverwiz is offline
hornet
AMX Mod X Plugin Approver
Join Date: Mar 2010
Location: Australia
Old 05-18-2012 , 09:16   Re: CVARS?
Reply With Quote #8

Quote:
Originally Posted by Bilal Pro View Post
Lol, when you are changing the cvar you are changing the array so what is wrong on this -.-
Why are you "lol-ing" at something when your the one who's wrong?

1) It is not an array - it is a variable / pointer holding the index of the CVar.
2) And no, when you change the CVar your changing the value that corresponds to the CVar index.


@Liverwiz you may want to put add an alive check to your spawn hook.
__________________
Quote:
vBulletin Tip #42: Not much would be accomplished by merging this item with itself.
hornet is offline
Liverwiz
Veteran Member
Join Date: Feb 2010
Location: Maryland
Old 05-18-2012 , 09:25   Re: CVARS?
Reply With Quote #9

Quote:
Originally Posted by hornet View Post
@Liverwiz you may want to put add an alive check to your spawn hook.
Isn't spawning dead against the laws of.....life? O.o
Though you are correct.....I need to get better at making sure people are alive before i do things to them.




necrophilia
__________________
What an elegant solution to a problem that doesn't need solving....
Liverwiz is offline
hornet
AMX Mod X Plugin Approver
Join Date: Mar 2010
Location: Australia
Old 05-18-2012 , 09:36   Re: CVARS?
Reply With Quote #10

Quote:
Originally Posted by Liverwiz View Post
Isn't spawning dead against the laws of.....life? O.o
Though you are correct.....I need to get better at making sure people are alive before i do things to them.




necrophilia
Well physically, yes, but from what I've learnt, Ham_Spawn will be called when a player is connecting so will give you an error if you use that player's index.
__________________
Quote:
vBulletin Tip #42: Not much would be accomplished by merging this item with itself.

Last edited by hornet; 05-18-2012 at 09:36.
hornet is offline
Reply


Thread Tools
Display Modes

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 00:29.


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