View Full Version : Cvars
blobby
08-22-2007, 02:18 PM
Would anyone be kind enough to show me here how to make a cvar and how to register it
Regards
blobby
FeuerSturm
08-22-2007, 04:18 PM
cvars have to be registered in "plugin_init", you will have to do the
following to use the "new" pcvar system:
first create a global variable:
new g_dod_mycvar
then in "plugin_init" register it like that:
g_dod_mycvar = register_cvar("dod_mycvar","1")
while "dod_mycvar" is your new cvar and "1" is the default value.
within your plugin you can set and retrieve cvar values with the following:
retrieve cvar value and store it in variable "mycvar_value":
new mycvar_value = get_pcvar_num(g_dod_mycvar)
set cvar value:
set_pcvar_num(g_dod_mycvar,"0")
hope that helps a bit! you can look at almost any plugin posted here,
almost all are using cvars, i'm sure you can learn more when reading them!
blobby
08-25-2007, 07:49 PM
Can you check over this for me when you get the time i did get stuck on this part while "dod_mycvar" is your new cvar and "1" is the default value.
within your plugin you can set and retrieve cvar values with the following:
retrieve cvar value and store it in variable "mycvar_value":
Code:
new mycvar_value = get_pcvar_num(g_dod_mycvar)
set cvar value:
Code:
set_pcvar_num(g_dod_mycvar,"0")
blobby
08-25-2007, 07:52 PM
So here is my plugin up to now if you could just look over it and see if every thing is a ok for me and if there is something wrong just point it out to me that would be ace...
/////////////////////////////////////////////////////////////////////////////////////////////
//* Plugin generated by AMXX-Studio *///////////////////////////////////////////////////////
//*Edit changed console command to client command*/////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////
//*commands are (console = mespec) (chat = /mespec)*/////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////
//*22/08/07 Added Cvar quickspec 1/0 (1 = on) (0 = off)*///////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////
//*make sure you difine your admin level where ADMIN_LEVEL_H is to your settings/////
////////////////////////////////////////////////////////////////////////////////////
#include <amxmodx>
#include <amxmisc>
#include <dodfun>
#define PLUGIN "Shadow Panthers Secret Spectate"
#define VERSION "3.0"
#define AUTHOR "Blobby"
// Define your admin level it is required below ADMIN_LEVEL_H is a custom level//
#define INVISIBILE_ADMIN ADMIN_LEVEL_H
new p_me_spec
new p_me_spec = get_pcvar_num(p_me_spec)
public plugin_init()
{
p_me_spec = register_cvar("dod_quickspec","1")
register_plugin(PLUGIN, VERSION, AUTHOR);
register_clcmd("mespec", "me_spec", INVISIBILE_ADMIN);
register_clcmd("say /mespec","me_spec", INVISIBILE_ADMIN)
register_clcmd("say_team /mespec" , "me_spec", INVISIBILE_ADMIN)
}
public me_spec(id,level,cid);
{
if(!cmd_access(id,level,cid,1);
{
return PLUGIN_HANDLED;
}
dod_set_user_team(id, 3, 0)
client_print(id, print_chat, "[DOD SECRET SPEC] you are now in spectator mode no one knows you are there :p");
return PLUGIN_HANDLED;
Thanks and Regards
Blobby
vBulletin® v3.8.6, Copyright ©2000-2012, Jelsoft Enterprises Ltd.