Raised This Month: $ Target: $400
 0% 

CVARS?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Liverwiz
Veteran Member
Join Date: Feb 2010
Location: Maryland
Old 05-18-2012 , 10:37   Re: CVARS?
Reply With Quote #1

Quote:
Originally Posted by hornet View Post
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.
THAT i was not aware of. Thanks!! But if i recall from testing....it worked just fine. Then again....it was a server where you were set automatically to 16000 and, thus, it didn't run anyway.
Just another reason to keep up good practice.....
__________________
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 , 06:10   Re: CVARS?
Reply With Quote #2

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 #3

@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 #4

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 #5

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


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