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

Is it possible to use a pcvar in an array?


Post New Thread Reply   
 
Thread Tools Display Modes
rak
Veteran Member
Join Date: Oct 2011
Location: banned country
Old 03-17-2012 , 04:59   Re: Is it possible to use a pcvar in an array?
Reply With Quote #11

PHP Code:
#include <amxmodx>

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

new const g_szOptions[][] = 
{  
    
"Big Bang"
    
"Blind Bomb"
    
"Freeze Dem Hoes"
    
"155 Extra Life Force"
    
"255 Armor"
    
"Speed Racist (%d Seconds)",     //pcvar_speed 
    
"Invis Cloak (%d Seconds)",        //pcvar_invis 
    
"Invincibility (%d Seconds)",       //pcvar_invinc 
    
"Awp (%d Bullet)"
    
"Deagle (%d Bullet)"
    
"Spy Disguise (%d Seconds)",     //pcvar_disguise 
    
"Iron Legs"
    
"Flash Protection"
    
"Chilly Skin"
    
"Cat Paws (Silent Walk)"
    
"I Live Forever (%d Per Map)" 
}  

new 
pcvar_1pcvar_2pcvar_3pcvar_4pcvar_5pcvar_6pcvar_7

public plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
pcvar_1 register_cvar("test1""1")
    
pcvar_2 register_cvar("test2""2")
    
pcvar_3 register_cvar("test3""3")
    
pcvar_4 register_cvar("test4""4")
    
pcvar_5 register_cvar("test5""5")
    
pcvar_6 register_cvar("test6""6")
    
pcvar_7 register_cvar("test7""7")
    
    
register_clcmd("say test""test")
}

public 
test(id) {
    new 
szText[32]
    
formatex(szTextcharsmax(szText), g_szOptions[5], get_pcvar_num(pcvar_1))
    
client_print(id3szText)
    
formatex(szTextcharsmax(szText), g_szOptions[6], get_pcvar_num(pcvar_2))
    
client_print(id3szText)
    
formatex(szTextcharsmax(szText), g_szOptions[7], get_pcvar_num(pcvar_3))
    
client_print(id3szText)
    
formatex(szTextcharsmax(szText), g_szOptions[8], get_pcvar_num(pcvar_4))
    
client_print(id3szText)
    
formatex(szTextcharsmax(szText), g_szOptions[9], get_pcvar_num(pcvar_5))
    
client_print(id3szText)
    
formatex(szTextcharsmax(szText), g_szOptions[10], get_pcvar_num(pcvar_6))
    
client_print(id3szText)
    
formatex(szTextcharsmax(szText), g_szOptions[15], get_pcvar_num(pcvar_7))
    
client_print(id3szText)
    return 
PLUGIN_HANDLED

correct way

========

client_print(id, 3, szText)
change this for print_chat... it's the same...

===========================

this I like more e.e

PHP Code:
#include <amxmodx>

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

const MAXCVARS 7

new const g_szOptions[][] = 
{  
    
"Big Bang"
    
"Blind Bomb"
    
"Freeze Dem Hoes"
    
"155 Extra Life Force"
    
"255 Armor"
    
"Speed Racist (%d Seconds)",     //pcvar_speed 
    
"Invis Cloak (%d Seconds)",        //pcvar_invis 
    
"Invincibility (%d Seconds)",       //pcvar_invinc 
    
"Awp (%d Bullet)"
    
"Deagle (%d Bullet)"
    
"Spy Disguise (%d Seconds)",     //pcvar_disguise 
    
"Iron Legs"
    
"Flash Protection"
    
"Chilly Skin"
    
"Cat Paws (Silent Walk)"
    
"I Live Forever (%d Per Map)" 
}

enum {
    
NAME,
    
NUM
}

new const 
Reg_Cvars[MAXCVARS][][] = {
    { 
"test1""1" },
    { 
"test2""2" },
    { 
"test3""3" },
    { 
"test4""4" },
    { 
"test5""5" },
    { 
"test6""6" },
    { 
"test7""7" }
}    

new const 
CvarLoop[MAXCVARS] = {
    
5,
    
6,
    
7,
    
8,
    
9,
    
10,
    
15
}

new 
pcvar[MAXCVARS]

public 
plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    for(new 
iMAXCVARSi++)
        
pcvar[i] = register_cvar(Reg_Cvars[i][NAME], Reg_Cvars[i][NUM])
    
    
register_clcmd("say test""test")
}

public 
test(id) {
    new 
szText[32]    
    for(new 
iMAXCVARSi++) {
        
        
format(szTextcharsmax(szText), g_szOptions[CvarLoop[i]], get_pcvar_num(pcvar[i]))
        
client_print(idprint_chatszText)
    }
    
    return 
PLUGIN_HANDLED

__________________

www.amxmodx-es.com

Steam: Luchokoldo

Last edited by rak; 03-17-2012 at 05:37.
rak is offline
Send a message via MSN to rak Send a message via Skype™ to rak
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 03-17-2012 , 14:06   Re: Is it possible to use a pcvar in an array?
Reply With Quote #12

Quote:
Originally Posted by rak View Post
PHP Code:
#include <amxmodx>

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

new const g_szOptions[][] = 
{  
    
"Big Bang"
    
"Blind Bomb"
    
"Freeze Dem Hoes"
    
"155 Extra Life Force"
    
"255 Armor"
    
"Speed Racist (%d Seconds)",     //pcvar_speed 
    
"Invis Cloak (%d Seconds)",        //pcvar_invis 
    
"Invincibility (%d Seconds)",       //pcvar_invinc 
    
"Awp (%d Bullet)"
    
"Deagle (%d Bullet)"
    
"Spy Disguise (%d Seconds)",     //pcvar_disguise 
    
"Iron Legs"
    
"Flash Protection"
    
"Chilly Skin"
    
"Cat Paws (Silent Walk)"
    
"I Live Forever (%d Per Map)" 
}  

new 
pcvar_1pcvar_2pcvar_3pcvar_4pcvar_5pcvar_6pcvar_7

public plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
pcvar_1 register_cvar("test1""1")
    
pcvar_2 register_cvar("test2""2")
    
pcvar_3 register_cvar("test3""3")
    
pcvar_4 register_cvar("test4""4")
    
pcvar_5 register_cvar("test5""5")
    
pcvar_6 register_cvar("test6""6")
    
pcvar_7 register_cvar("test7""7")
    
    
register_clcmd("say test""test")
}

public 
test(id) {
    new 
szText[32]
    
formatex(szTextcharsmax(szText), g_szOptions[5], get_pcvar_num(pcvar_1))
    
client_print(id3szText)
    
formatex(szTextcharsmax(szText), g_szOptions[6], get_pcvar_num(pcvar_2))
    
client_print(id3szText)
    
formatex(szTextcharsmax(szText), g_szOptions[7], get_pcvar_num(pcvar_3))
    
client_print(id3szText)
    
formatex(szTextcharsmax(szText), g_szOptions[8], get_pcvar_num(pcvar_4))
    
client_print(id3szText)
    
formatex(szTextcharsmax(szText), g_szOptions[9], get_pcvar_num(pcvar_5))
    
client_print(id3szText)
    
formatex(szTextcharsmax(szText), g_szOptions[10], get_pcvar_num(pcvar_6))
    
client_print(id3szText)
    
formatex(szTextcharsmax(szText), g_szOptions[15], get_pcvar_num(pcvar_7))
    
client_print(id3szText)
    return 
PLUGIN_HANDLED

correct way
No.
__________________

Last edited by fysiks; 03-17-2012 at 14:06.
fysiks is offline
rak
Veteran Member
Join Date: Oct 2011
Location: banned country
Old 03-17-2012 , 16:10   Re: Is it possible to use a pcvar in an array?
Reply With Quote #13

Quote:
Originally Posted by fysiks View Post
No.
why?
__________________

www.amxmodx-es.com

Steam: Luchokoldo
rak is offline
Send a message via MSN to rak Send a message via Skype™ to rak
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 03-17-2012 , 19:09   Re: Is it possible to use a pcvar in an array?
Reply With Quote #14

Quote:
Originally Posted by rak View Post
why?
Because it seems you did not look at the code and determine how the strings are actually being used. After I figured out how it was actually being used in the code, I found the solution to his problem. It's in post #10 in bold.
__________________
fysiks 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 16:36.


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