Raised This Month: $ Target: $400
 0% 

Constant string return only first letter...


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
Flick3rR
Veteran Member
Join Date: Feb 2014
Location: Bulgaria, Stara Zagora
Old 08-05-2014 , 19:54   Constant string return only first letter...
Reply With Quote #1

Hey! I want to ask something, that I was wondering on for a long time... When I use the constant g_szAdminPrefixes with second subscripting of [string], it always returns the first letter of the line...
Is it the problem from formatex() or from the indexing, or what? I can't find out (probably something pretty simple).
PHP Code:
/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <nvault>
#include <colorchat>

#define PLUGIN "Player Ranks Admin Prefix"
#define VERSION "1.0"
#define AUTHOR "Flicker"

new player_points[33]
new 
player_rank[33]
new 
player_flags[33]

new 
g_nVault

new g_iMaxPlayers

//new const g_szPrefix[] = "[SJ Ranks]"

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

new const 
g_szAdminPrefixes[][eData] =
{
    
"",
    {
"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}
}

new const 
g_szPlayerRanks[][eData] =
{
    {
"Slabak"20},
    {
"Napredvam"30},
    {
"Pochvam da shvashtam",  40},
    {
"Novacite sled men"50},
    {
"Edin ot nai-dobrite"60},
    {
"Pro"70},
    {
"Proto na otbora"80},
    {
"Proto na botovete"100},
    {
"Pro master"130},
    {
"Shef na igrachite"160},
    {
"Shefa tuk"200},
    {
"Shefa v servera"300},
    {
"Player VIP"500},
    {
"Player Admin"800},
    {
"Budesht Admin"999999999999}
}

new const 
g_szTeamNames[][]=
{
    
"^1(Unassigned)",
    
"^1(Terrorist)",
    
"^1(Counter-Terrorist)",
    
"^1(Spectator)"
}

public 
plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
register_clcmd("say""cmdSay")
    
register_clcmd("say_team""cmdSayTeam")
    
    
g_nVault nvault_open("RandomVault")
    
    
g_iMaxPlayers get_maxplayers()
}

public 
cmdSay(id)
    
MainActionPrefixes(idfalse)
public 
cmdSayTeam(id)
    
MainActionPrefixes(idtrue)
    
stock MainActionPrefixes(const id, const bool:IsTeamMsg)
{
    new 
szMessage[192], szText[192]
    
read_args(szTextcharsmax(szText))
    
remove_quotes(szText)
    
    if(
szText[0] == '/' || szText[0] == '#' || szText[0] == '.' || szText[0] == '!')
        return 
PLUGIN_CONTINUE
        
    
new szName[32]
    
get_user_name(idszNamecharsmax(szName))
    
    new 
alive[11], isAlive is_user_alive(id)
    
copy(alivecharsmax(alive), isAlive "" "^1*DEAD*")
    
    
    
formatex(szMessagecharsmax(szMessage), "^1%s%s^3[^4%s^3] %s^1 :%s %s"aliveIsTeamMsg g_szTeamNames[get_user_team(id)] : ""player_flags[id] ? g_szAdminPrefixes[player_flags[id]][string] : g_szPlayerRanks[player_rank[id]][string], szNameplayer_flags[id] ? "^4" "^1"szText)

    new 
icolor
    
switch(get_user_team(id))
    {
        case 
0icolor GREY
        
case 1icolor RED
        
case 2icolor BLUE
        
case 3icolor GREY
    
}
    
    for(new 
player 1player g_iMaxPlayersplayer++)
        if(
is_user_connected(player))
            if(
isAlive && is_user_alive(player) || !isAlive && !is_user_alive(player))
                if(
IsTeamMsg && get_user_team(id) == get_user_team(player) || !IsTeamMsg)
                    
ColorChat(playericolorszMessage)
                    
    return 
PLUGIN_CONTINUE
}

public 
client_putinserver(id)
{
    new 
iFlags get_user_flags(id)
    for(new 
1sizeof g_szAdminPrefixesi++)
    {
        if(
iFlags g_szAdminPrefixes[i][integer])
        {
            
player_flags[id] = i
            
break
        }
        else continue
    }
    
    
LoadPoints(id)
}

public 
client_disconnect(id)
    
SavePoints(id)







public 
SavePoints(id)
{
    new 
szName[32], szKey[32], szData[256]
    
get_user_name(idszNamecharsmax(szName))
    
    
formatex(szKeycharsmax(szKey), "%s-XP"szName)
    
    
formatex(szDatacharsmax(szData), "%i#%i#"player_points[id], player_rank[id])
    
    
nvault_set(g_nVaultszKeyszData)
    
    return 
PLUGIN_CONTINUE
}
    
public 
LoadPoints(id)
{
    new 
szName[32], szKey[32], szData[256]
    
get_user_name(idszNamecharsmax(szName))
    
    
formatex(szKeycharsmax(szKey), "%s-XP"szName)
    
    
formatex(szDatacharsmax(szData), "%i#%i#"player_points[id], player_rank[id])
    
    
nvault_get(g_nVaultszKeyszDatacharsmax(szData))
    
    
replace_all(szDatacharsmax(szData), "#"" ")
    
    new 
szPoints[32], szRank[32]
    
parse(szDataszPointscharsmax(szPoints), szRankcharsmax(szRank))
    
    
player_points[id] = str_to_num(szPoints)
    
player_rank[id] = str_to_num(szRank)
    
    return 
PLUGIN_CONTINUE
}

public 
plugin_end()
    
nvault_close(g_nVault
The problem actually occurs here:
PHP Code:
formatex(szMessagecharsmax(szMessage), "^1%s%s^3[^4%s^3] %s^1 :%s %s"aliveIsTeamMsg g_szTeamNames[get_user_team(id)] : ""player_flags[id] ? g_szAdminPrefixes[player_flags[id]][string] : g_szPlayerRanks[player_rank[id]][string], szNameplayer_flags[id] ? "^4" "^1"szText
when formatexing the chat message. The prefix is got from this const:[php]g_szAdminPrefixes[player_flags[id]][string][php] As you will see below, this way of use usually works, but here there is some problem and it returns only the first letter. Same happens with the const for player ranks here:
PHP Code:
g_szPlayerRanks[player_rank[id]][string
Is the problem from the indexing, or something with the enum...?

Tested the same method here:
PHP Code:
/* Plugin generated by AMXX-Studio */

#include <amxmodx>

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

new const 
g_szMyTestConst[][eData] =
{
    {
"My First String"1},
    {
"My Second String"2},
    {
"My Third String"3}
}


public 
plugin_init() {
    
    
register_clcmd("say /test""cmdTest")
}
public 
cmdTest(id)
{
    new 
iRand random(sizeof g_szMyTestConst)
    
client_print(idprint_chat"String: %s | Integer: %d"g_szMyTestConst[iRand][string], g_szMyTestConst[iRand][integer])

And it works pretty accurate:


Thanks for any help and sorry fro the undescriptive problem.
__________________

Last edited by Flick3rR; 08-06-2014 at 07:01.
Flick3rR is offline
Send a message via Skype™ to Flick3rR
 



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 13:16.


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