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

Solved using native in formatex


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
lexzor
Veteran Member
Join Date: Nov 2020
Old 10-02-2021 , 08:02   using native in formatex
Reply With Quote #1

hello.

why can t i format a string like this

PHP Code:
    formatex(szItem[0], charsmax(szItem[]), "\r%L \y%s"id"CREATE_CLAN_NAME_FIELD"equali(g_UserData[id][ClanName], "NONE") ? "" g_UserData[id][ClanName]; 
error:
Code:
ERROR [324]: array must be indexed (variable "-unknown-")

Last edited by lexzor; 10-03-2021 at 21:53.
lexzor is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 10-02-2021 , 11:22   Re: using native in formatex
Reply With Quote #2

Show how szItem and g_UserData are defined.
__________________
Bugsy is offline
lexzor
Veteran Member
Join Date: Nov 2020
Old 10-02-2021 , 11:57   Re: using native in formatex
Reply With Quote #3

PHP Code:
enum _:USER_INFO
{
    
szName[MAX_NAME_LENGTH],
    
szAuthid[MAX_AUTHID_LENGTH],
    
iIsUserClanLeader,
    
iIsUserClanSecondLeader,
    
iIsUserClanMember,
    
ClanName[36],
    
ClanTag[10]
}

new 
g_UserData[MAX_PLAYERS 1][USER_INFO];

new 
szItem[2][64]; 
lexzor is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 10-02-2021 , 12:22   Re: using native in formatex
Reply With Quote #4

I do not see any issues, it may just be a compiler issue. May need to instead do an if-else to handle this.
__________________
Bugsy is offline
DJEarthQuake
Veteran Member
Join Date: Jan 2014
Location: Astral planes
Old 10-02-2021 , 20:52   Re: using native in formatex
Reply With Quote #5

PHP Code:
#include amxmodx

#define MAX_PLAYERS 32
#define MAX_NAME_LENGTH 32
#define MAX_AUTHID_LENGTH 64

enum _:USER_INFO
{
    
szName[MAX_NAME_LENGTH],
    
szAuthid[MAX_AUTHID_LENGTH],
    
iIsUserClanLeader,
    
iIsUserClanSecondLeader,
    
iIsUserClanMember,
    
ClanName[MAX_NAME_LENGTH 4],
    
ClanTag[10]
}

new 
g_UserData[MAX_PLAYERS 1][USER_INFO]; new szItem[2][MAX_AUTHID_LENGTH];

public 
client_disconnect(id)g_UserData[id][ClanName][0] = EOS

public whatever(id)
if(
is_user_connected(id))
    
formatex(szItem[0], charsmax(szItem[]), "\r%L \y%s"id"CREATE_CLAN_NAME_FIELD"g_UserData[id][ClanName]) 
__________________

Last edited by DJEarthQuake; 10-05-2021 at 09:41.
DJEarthQuake is offline
lexzor
Veteran Member
Join Date: Nov 2020
Old 10-02-2021 , 21:16   Re: using native in formatex
Reply With Quote #6

sorry but your resolve dosen t corespond to my error, that was just an type error.

Last edited by lexzor; 10-02-2021 at 21:28.
lexzor is offline
lexzor
Veteran Member
Join Date: Nov 2020
Old 10-02-2021 , 21:30   Re: using native in formatex
Reply With Quote #7

Quote:
Originally Posted by Bugsy View Post
Show how szItem and g_UserData are defined.
actually the problem is at g_userdata[id][clanname]. my compiler version is 1.9.

maybe would work if i update it at 1.10 ? i will try tomorrow
lexzor is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 10-02-2021 , 21:35   Re: using native in formatex
Reply With Quote #8

Worth a try, but the code appears to be written correctly. If all else fails, just use an if-statement. Or instead of copying "NONE" if there is no clan name, leave the string empty, eliminating the need for the condition all together.
__________________
Bugsy is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 10-03-2021 , 02:46   Re: using native in formatex
Reply With Quote #9

Why don't you post the full code or atleast the function body of the error code?
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !


Last edited by Natsheh; 10-03-2021 at 02:47.
Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 10-03-2021 , 19:43   Re: using native in formatex
Reply With Quote #10

Quote:
Originally Posted by Natsheh View Post
Why don't you post the full code or atleast the function body of the error code?
What? Everything that was needed to reproduce the error was provided.

Despite what DJEarthQuake says, I'm unable to compile it on 1.8.2 or 1.9.0 so I'm not sure what compiler he is using.

Regardless, the workaround is simple as Bugsy stated.
__________________

Last edited by fysiks; 10-03-2021 at 19:46.
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 14:04.


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