AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Formatex Dimensional Array (https://forums.alliedmods.net/showthread.php?t=215045)

Strick3n 05-03-2013 06:54

Formatex Dimensional Array
 
Hello, i'm trying to print "Hello world!" to server console but it prints "Hello Hello"

here my code:
Code:

#include < amxmodx >

enum _:m_String
{
        szHello[32],
        szWorld[32]
}

new g_szString[ ][ m_String ];

public plugin_init()
{
        set_task( 5.0, "loadWorld" );
}

public loadWorld( )
{
        formatex( g_szString[ 0 ][ szHello ], charsmax( g_szString[ ][ szHello ] ), "Hello" );
       
        formatex( g_szString[ 0 ][ szWorld ], charsmax( g_szString[ ][ szWorld ] ), "World" );
       
        new szString[ 128 ];
       
        formatex( szString, charsmax( szString ), "%s %s!", g_szString[ 0 ][ szHello ], g_szString[ 0 ][ szWorld ] );

        server_print( szString );
}

anyone know what's wrong here?

claudiuhks 05-03-2013 07:37

Re: Formatex Dimensional Array
 
What exactly do you want to reach?
This expression is wrong:

PHP Code:

formatexszStringcharsmaxszString ), "%s %s!"g_szString][ szHello ], g_szString][ szWorld ] ); 


Strick3n 05-03-2013 08:18

Re: Formatex Dimensional Array
 
Quote:

Originally Posted by claudiuhks (Post 1944923)
What exactly do you want to reach?
This expression is wrong:

PHP Code:

formatexszStringcharsmaxszString ), "%s %s!"g_szString][ szHello ], g_szString][ szWorld ] ); 


i want to format string into multi dimensional array and parse the multi dimensional array into another variable.
you told me that this expression is wrong, so can you tell me what is wrong?

claudiuhks 05-03-2013 08:25

Re: Formatex Dimensional Array
 
You can't use g_szString as: g_szString[ (numeric) 0 ][ (string) szHello ].
Do you understand?

Strick3n 05-03-2013 09:07

Re: Formatex Dimensional Array
 
Quote:

Originally Posted by claudiuhks (Post 1944953)
You can't use g_szString as: g_szString[ (numeric) 0 ][ (string) szHello ].
Do you understand?

i changed this line:
Code:

new g_szString[ ][ m_String ];
to this one:
Code:

new g_szString[ 128 ][ m_String ];
and now all works perfectly.


All times are GMT -4. The time now is 10:50.

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