AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   cvar prefix (https://forums.alliedmods.net/showthread.php?t=182994)

bazhenov93 04-16-2012 01:02

cvar prefix
 
I have this
PHP Code:

new g_cPrefix

public plugin_init() { 
g_cPrefix register_cvar("server_prefix""Server Name")

public 
func() { 
new 
szPrefix[10]
get_pcvar_string(g_cPrefixszPrefixcharsmax(szPrefix))
client_print(0print_chat"[ %s ] test"szPrefix)


And this:
PHP Code:

#define SERVER_PREFIX

#if defined SERVER_PREFIX
new const Prefix[] = "Server Name" // with prefix
#else
new const Prefix[] = "" // without prefix
#endif

new etc_Prefix

public plugin_init() {
register_clcmd("say /test""test")
etc_Prefix register_cvar("use_prefix""1")
}
public 
test(id) {
if(
get_pcvar_num(cvar_prefijo))
client_print(idprint_chat"[ %s ] Prefix is enabled"Prefix)
else
client_print(idprint_chat"Prefix not enabled")


I need a better way, for example:

PHP Code:

// bad coded I know, but i'm giving an example of what I want
new g_cPrefix

public plugin_init() { 
g_cPrefix register_cvar("server_prefix""Server Name" 1"" 0)

public 
enabled() { 
get_pcvar_string(g_cPrefixszPrefixcharsmax(szPrefix))
if 
1
client_print
(0print_chat"[ %s ] test"szPrefix)
}
public 
not_enabled() { 
get_pcvar_string(g_cPrefixszPrefixcharsmax(szPrefix))
if 
0
client_print
(0print_chat"test")



rak 04-16-2012 01:52

Re: cvar prefix
 
after ask, please.. read tutorials

PHP Code:

#include <amxmodx>

#define PLUGIN "New Plug-In"
#define VERSION "1.0"
#define AUTHOR "[R]ak"

new cvar_prefix

new const Prefix[][] = {
    
"",
    
"[Arg] "
}

public 
plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
cvar_prefix register_cvar("server_prefix""1"ADMIN_CVAR)
    
register_clcmd("say /test""cmdTest")
}


public 
cmdTest(id) {
    new 
cvar_value get_pcvar_num(cvar_prefix)
    
    if(
cvar_value 1)
        
cvar_value 1
    
    client_print
(idprint_chat"%sRemove Argentina Ban!"Prefix[cvar_value])



bazhenov93 04-16-2012 02:02

Re: cvar prefix
 
What about .cfg? prefix_name [ text ]

cvar_prefix
= register_cvar("prefix", "1")
cvar_prefix = register_cvar("prefix_name", "[ Server Name ]")

?

rak 04-16-2012 02:05

Re: cvar prefix
 
Quote:

Originally Posted by bazhenov93 (Post 1690176)
What about .cfg? prefix_name [ text ]

cvar_prefix
= register_cvar("prefix", "1")
cvar_prefix = register_cvar("prefix_name", "[ Server Name ]")

?

PHP Code:

#include <amxmodx>

#define PLUGIN "New Plug-In"
#define VERSION "1.0"
#define AUTHOR "[R]ak"

new cvar_prefix

public plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
cvar_prefix register_cvar("server_prefix""[Arg]"ADMIN_CVAR)
    
register_clcmd("say /test""cmdTest")
}


public 
cmdTest(id) {
    new 
Buffer[15]
    
get_pcvar_string(cvar_prefixBuffercharsmax(Buffer))
    
    
client_print(idprint_chat"%s Remove Argentina Ban!"Buffer)


or

PHP Code:

#include <amxmodx>

#define PLUGIN "New Plug-In"
#define VERSION "1.0"
#define AUTHOR "[R]ak"

new cvar_prefixcvar_prefix_on

public plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
cvar_prefix_on register_cvar("server_prefix_on""1"ADMIN_CVAR)
    
cvar_prefix register_cvar("server_prefix""[Arg]"ADMIN_CVAR)
    
register_clcmd("say /test""cmdTest")
}


public 
cmdTest(id) {
    
    if(!
get_pcvar_num(cvar_prefix_on))
        return
    new 
Buffer[15]
    
get_pcvar_string(cvar_prefixBuffercharsmax(Buffer))
    
    
client_print(idprint_chat"%s Remove Argentina Ban!"Buffer)



bazhenov93 04-16-2012 02:08

Re: cvar prefix
 
new Buffer[15] what's that?

If
[Arg] is "0" that does not disable the prefix

rak 04-16-2012 02:09

Re: cvar prefix
 
look now

EDIT:
PHP Code:

#include <amxmodx>

#define PLUGIN "New Plug-In"
#define VERSION "1.0"
#define AUTHOR "[R]ak"

new cvar_prefix

public plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
cvar_prefix register_cvar("server_prefix""[Arg]"ADMIN_CVAR)
    
register_clcmd("say /test""cmdTest")
}


public 
cmdTest(id) {
    
    new 
Buffer[15]
    
get_pcvar_string(cvar_prefixBuffercharsmax(Buffer))
    
    if(
equal(Buffer"0"))
        return
    
    
client_print(idprint_chat"%s Remove Argentina Ban!"Buffer)



bazhenov93 04-16-2012 02:13

Re: cvar prefix
 
If prefix is disabled, the /test does not show nothing

rak 04-16-2012 02:16

Re: cvar prefix
 
-.- if you need more.. do it..

bazhenov93 04-16-2012 02:19

Re: cvar prefix
 
I just need a good code! Because I know that I can use "else"

if cvar etc etc 1
client print, "%s blabla, cvaretcetc"

else
client print blabla

But i want a small code,
// check if cvar is enabled, check cvar name
client print, "%s blabla, cvar"

rak 04-16-2012 02:22

Re: cvar prefix
 
god damn it
PHP Code:

public cmdTest(id) {
    
    new 
Buffer[15]
    
get_pcvar_string(cvar_prefixBuffercharsmax(Buffer))
    
client_print(idprint_chat"%s Remove Argentina Ban!"equal(Buffer"0") ? "" Buffer)




All times are GMT -4. The time now is 07:40.

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