Jump to content

How to Create Double-Arrays Like Array[1][2]?


manuelhimmler

Recommended Posts

Hi Community?

I tried to create double arrays for more than a hour and i failed, I hope you can help me. I wanted to write this PAWN-Code in LUA:

new Float:Hospitals[8][4] =
{
{1634.4591,1768.1781,10.8203,270.0},
{1225.4983,308.7397,19.7472,157.0},
{-2655.7307,636.2322,14.4531,188.0},
{1174.2993,-1323.4747,14.7891,270.0},
{2027.4967,-1406.1840,17.2150,191.0},
{-2119.7444,-2388.7043,30.6250,55.0},
{-316.1642,1054.7610,19.7422,354.0},
{-1514.6053,2523.7820,55.8071,0.0}
};

Link to comment

Hospitals =
{
{1634.4591,1768.1781,10.8203,270.0},
{1225.4983,308.7397,19.7472,157.0},
{-2655.7307,636.2322,14.4531,188.0},
{1174.2993,-1323.4747,14.7891,270.0},
{2027.4967,-1406.1840,17.2150,191.0},
{-2119.7444,-2388.7043,30.6250,55.0},
{-316.1642,1054.7610,19.7422,354.0},
{-1514.6053,2523.7820,55.8071,0.0}
};

This should do it I think.

Link to comment
function testaray()
testarays ={
{1634.4591,1768.1781,10.8203,270.0},
{1225.4983,308.7397,19.7472,157.0},
{-2655.7307,636.2322,14.4531,188.0},
{1174.2993,-1323.4747,14.7891,270.0},
{2027.4967,-1406.1840,17.2150,191.0},
{-2119.7444,-2388.7043,30.6250,55.0},
{-316.1642,1054.7610,19.7422,354.0},
{-1514.6053,2523.7820,55.8071,0.0}
};
outputDebugString("test aray: " ..testarays[1][1].."," ..testarays[1][2].."," ..testarays[1][3].."," ..testarays[1][4])
end
addCommandHandler("arays", testaray)

this maybe will help you

Link to comment
function testaray()
testarays ={
{1634.4591,1768.1781,10.8203,270.0},
{1225.4983,308.7397,19.7472,157.0},
{-2655.7307,636.2322,14.4531,188.0},
{1174.2993,-1323.4747,14.7891,270.0},
{2027.4967,-1406.1840,17.2150,191.0},
{-2119.7444,-2388.7043,30.6250,55.0},
{-316.1642,1054.7610,19.7422,354.0},
{-1514.6053,2523.7820,55.8071,0.0}
};
outputDebugString("test aray: " ..testarays[1][1].."," ..testarays[1][2].."," ..testarays[1][3].."," ..testarays[1][4])
end
addCommandHandler("arays", testaray)

this maybe will help you

DO NOT name variables the same as functions!

Gamesnert example should work. I think you're doing something wrong if it doesn't work, manuelhimmler.

Link to comment
  • 2 weeks later...

Hi Community!

I am here again with my problem!

I wanted to write something in a variable:

CarInfo[idx]["cModel"] = mysql_result(query,1,1)

in the header of the script there is CarInfo={}

and the error in the console is "attempt to index field '?' (a nil value)

The problem is that I have to define every CarInfo like CarInfo[1]={}, CarInfo[2]={}, isn't there a better and easier solution

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...