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

Constant string return only first letter...


Post New Thread Reply   
 
Thread Tools Display Modes
Flick3rR
Veteran Member
Join Date: Feb 2014
Location: Bulgaria, Stara Zagora
Old 08-07-2014 , 13:00   Re: Constant string return only first letter...
Reply With Quote #11

The code:
PHP Code:
/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <amxmisc>

#define PLUGIN "X"
#define VERSION "1.0"
#define AUTHOR "Flicker"

enum _:eData
{
    
string[64],
    
integer
}

new const 
g_szAdminPrefixes[][eData] =
{
    {
""0},
    {
"Head Admin",     ADMIN_LEVEL_A},
    {
"Help Admin",     ADMIN_LEVEL_B},
    {
"Test Admin",     ADMIN_LEVEL_C},
    {
"Admin",     ADMIN_LEVEL_D},
    {
"VIP Level 1",    ADMIN_LEVEL_E},
    {
"VIP Level 2",    ADMIN_LEVEL_F},
    {
"VIP Level 3",    ADMIN_LEVEL_G}
}

public 
plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
register_clcmd("say /info""cmdTest")
    
register_clcmd("say /prefixi""cmdPrefix")
}

public 
cmdTest(id)
{
    for(new 
i16i++)
        
log_amx("g_szAdminPrefixes[3][string][%i] = %i"ig_szAdminPrefixes[3][string][i])
}

public 
cmdPrefix(id)
{
    new 
iRand random_num(1charsmax(g_szAdminPrefixes))
    
    
client_print(idprint_chat"Prefix: %s"g_szAdminPrefixes[iRand][string])

The output:
Log:
Code:
L 08/07/2014 - 18:38:49: [PrefixTest.amxx] g_szAdminPrefixes[3][string][0] = 84
L 08/07/2014 - 18:38:49: [PrefixTest.amxx] g_szAdminPrefixes[3][string][1] = 101
L 08/07/2014 - 18:38:49: [PrefixTest.amxx] g_szAdminPrefixes[3][string][2] = 115
L 08/07/2014 - 18:38:49: [PrefixTest.amxx] g_szAdminPrefixes[3][string][3] = 116
L 08/07/2014 - 18:38:49: [PrefixTest.amxx] g_szAdminPrefixes[3][string][4] = 32
L 08/07/2014 - 18:38:49: [PrefixTest.amxx] g_szAdminPrefixes[3][string][5] = 65
L 08/07/2014 - 18:38:49: [PrefixTest.amxx] g_szAdminPrefixes[3][string][6] = 100
L 08/07/2014 - 18:38:49: [PrefixTest.amxx] g_szAdminPrefixes[3][string][7] = 109
L 08/07/2014 - 18:38:49: [PrefixTest.amxx] g_szAdminPrefixes[3][string][8] = 105
L 08/07/2014 - 18:38:49: [PrefixTest.amxx] g_szAdminPrefixes[3][string][9] = 110
L 08/07/2014 - 18:38:49: [PrefixTest.amxx] g_szAdminPrefixes[3][string][10] = 0
L 08/07/2014 - 18:38:49: [PrefixTest.amxx] g_szAdminPrefixes[3][string][11] = 0
L 08/07/2014 - 18:38:49: [PrefixTest.amxx] g_szAdminPrefixes[3][string][12] = 0
L 08/07/2014 - 18:38:49: [PrefixTest.amxx] g_szAdminPrefixes[3][string][13] = 0
L 08/07/2014 - 18:38:49: [PrefixTest.amxx] g_szAdminPrefixes[3][string][14] = 0
L 08/07/2014 - 18:38:49: [PrefixTest.amxx] g_szAdminPrefixes[3][string][15] = 0
Chat prefix:
__________________
Flick3rR is offline
Send a message via Skype™ to Flick3rR
Backstabnoob
Veteran Member
Join Date: Feb 2009
Location: Iwotadai Dorm
Old 08-07-2014 , 13:09   Re: Constant string return only first letter...
Reply With Quote #12

I didn't read the thread but use %c if you want to print a character.
__________________
Currently busy working on a very large scale anime database project.
Backstabnoob is offline
Flick3rR
Veteran Member
Join Date: Feb 2014
Location: Bulgaria, Stara Zagora
Old 08-07-2014 , 13:21   Re: Constant string return only first letter...
Reply With Quote #13

The idea is that I don't want to, but it does. I'm using %s when formatex-ing, but it only returns the first character. And I guess you are talking about the output, will make it so and will post the output here.
EDIT: Replaced %i with %c in the code above and here is the output. It all seems to be allright.
Code:
L 08/07/2014 - 20:22:30: [PrefixTest.amxx] g_szAdminPrefixes[3][string][0] = T
L 08/07/2014 - 20:22:30: [PrefixTest.amxx] g_szAdminPrefixes[3][string][1] = e
L 08/07/2014 - 20:22:30: [PrefixTest.amxx] g_szAdminPrefixes[3][string][2] = s
L 08/07/2014 - 20:22:30: [PrefixTest.amxx] g_szAdminPrefixes[3][string][3] = t
L 08/07/2014 - 20:22:30: [PrefixTest.amxx] g_szAdminPrefixes[3][string][4] =  
L 08/07/2014 - 20:22:30: [PrefixTest.amxx] g_szAdminPrefixes[3][string][5] = A
L 08/07/2014 - 20:22:30: [PrefixTest.amxx] g_szAdminPrefixes[3][string][6] = d
L 08/07/2014 - 20:22:30: [PrefixTest.amxx] g_szAdminPrefixes[3][string][7] = m
L 08/07/2014 - 20:22:30: [PrefixTest.amxx] g_szAdminPrefixes[3][string][8] = i
L 08/07/2014 - 20:22:30: [PrefixTest.amxx] g_szAdminPrefixes[3][string][9] = n
L 08/07/2014 - 20:22:30: [PrefixTest.amxx] g_szAdminPrefixes[3][string][10] = 
L 08/07/2014 - 20:22:30: [PrefixTest.amxx] g_szAdminPrefixes[3][string][11] = 
L 08/07/2014 - 20:22:30: [PrefixTest.amxx] g_szAdminPrefixes[3][string][12] = 
L 08/07/2014 - 20:22:30: [PrefixTest.amxx] g_szAdminPrefixes[3][string][13] = 
L 08/07/2014 - 20:22:30: [PrefixTest.amxx] g_szAdminPrefixes[3][string][14] = 
L 08/07/2014 - 20:22:30: [PrefixTest.amxx] g_szAdminPrefixes[3][string][15] =
But why the hell the const returns only the first character in the main code.
__________________

Last edited by Flick3rR; 08-07-2014 at 13:23.
Flick3rR is offline
Send a message via Skype™ to Flick3rR
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 08-07-2014 , 18:55   Re: Constant string return only first letter...
Reply With Quote #14

Quote:
Originally Posted by Flick3rR View Post
The idea is that I don't want to, but it does. I'm using %s when formatex-ing, but it only returns the first character. And I guess you are talking about the output, will make it so and will post the output here.
EDIT: Replaced %i with %c in the code above and here is the output. It all seems to be allright.
Code:
L 08/07/2014 - 20:22:30: [PrefixTest.amxx] g_szAdminPrefixes[3][string][0] = T
L 08/07/2014 - 20:22:30: [PrefixTest.amxx] g_szAdminPrefixes[3][string][1] = e
L 08/07/2014 - 20:22:30: [PrefixTest.amxx] g_szAdminPrefixes[3][string][2] = s
L 08/07/2014 - 20:22:30: [PrefixTest.amxx] g_szAdminPrefixes[3][string][3] = t
L 08/07/2014 - 20:22:30: [PrefixTest.amxx] g_szAdminPrefixes[3][string][4] =  
L 08/07/2014 - 20:22:30: [PrefixTest.amxx] g_szAdminPrefixes[3][string][5] = A
L 08/07/2014 - 20:22:30: [PrefixTest.amxx] g_szAdminPrefixes[3][string][6] = d
L 08/07/2014 - 20:22:30: [PrefixTest.amxx] g_szAdminPrefixes[3][string][7] = m
L 08/07/2014 - 20:22:30: [PrefixTest.amxx] g_szAdminPrefixes[3][string][8] = i
L 08/07/2014 - 20:22:30: [PrefixTest.amxx] g_szAdminPrefixes[3][string][9] = n
L 08/07/2014 - 20:22:30: [PrefixTest.amxx] g_szAdminPrefixes[3][string][10] = 
L 08/07/2014 - 20:22:30: [PrefixTest.amxx] g_szAdminPrefixes[3][string][11] = 
L 08/07/2014 - 20:22:30: [PrefixTest.amxx] g_szAdminPrefixes[3][string][12] = 
L 08/07/2014 - 20:22:30: [PrefixTest.amxx] g_szAdminPrefixes[3][string][13] = 
L 08/07/2014 - 20:22:30: [PrefixTest.amxx] g_szAdminPrefixes[3][string][14] = 
L 08/07/2014 - 20:22:30: [PrefixTest.amxx] g_szAdminPrefixes[3][string][15] =
But why the hell the const returns only the first character in the main code.
All of your test codes work perfectly fine. You should look for the difference between your working code and your non-working code (NOTE: There is a difference).

Another thing that would help you out is to learn to use the zero index. Also, using "charsmax" for arrays that are not strings is confusing.
__________________
fysiks is offline
Flick3rR
Veteran Member
Join Date: Feb 2014
Location: Bulgaria, Stara Zagora
Old 08-07-2014 , 19:55   Re: Constant string return only first letter...
Reply With Quote #15

Аllright, I've just replaced the short else-if statements (? with the long ones and formated the string separately if the user is admin and if he is not. It worked, with the same indexes of the constants... Strange.
__________________
Flick3rR is offline
Send a message via Skype™ to Flick3rR
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 08-07-2014 , 20:16   Re: Constant string return only first letter...
Reply With Quote #16

The difference to which I was referring was that you did not properly initialize your constant (in the code in post #1).
__________________
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 19:49.


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