Give array value for an array
#1

Hi.

I would like to give an array value for an array.
Its work with integer, but with float, not.

E.g:
Код:
#include <a_samp>

new test[20][20][2];

public OnGameModeInit()
{
	test[0][0] = {12, 51};
	return 1;
}
But with Float no, why?
Код:
\debug.pwn(7) : warning 213: tag mismatch
Код:
#include <a_samp>

new Float:test[20][20][2];

public OnGameModeInit()
{
	test[0][0] = {12.25, 51.69};
	return 1;
}
Thanx for the help
Reply
#2

You might have to use an enum to assign float values in this way to this kind of array, although I think you can only set the values like this under the variable definition. Also, for a multi dimensional array of this size, it may be difficult to get the format right.

here is an example of a smaller array.
pawn Код:
enum array_dat { Float:fielda,Float:fieldb };
new test[2][2][array_dat] =
{
    {
        { 12.5,16.3 },
        { 12.5,16.3 }
    },
    {
        { 12.5,16.3 },
        { 12.5,16.3 }
    }
};
hope this helps

I am pretty sure there is an easier way to do this, it really depends on how and why you are using these variables.
Reply
#3

Thanx, but i could solv it
Код:
test[0][0] = Float:{12.25, 51.69};
Reply
#4

yes that is much easier. I learn something new every day.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)