Hi,
I recently began to script in LUA, and I have some experience with PAWN.
Now, I'm trying to convert some parts of my pawn scripts to lua.
Then problem is that somehow I got stucked.
I'm trying to make an array structure.
something like this in pawn:
#define MAX_PLAYERS 100
enum pInfo
{
pSQLID,
pAdmin,
pLevel,
}
new PlayerInfo[MAX_PLAYERS][pInfo];
I've translated into this:
-- structura
pInfo = { pSQLID, pAdmin, pLevel,}
gPlayerInfo = {}
for i=1,100 do
gPlayerInfo[i] = pInfo
end
Then, I'm trying to assign a value when a player joins.
function joinHandler()
gPlayerInfo[source][pLevel] =1;
end
-- eventuri
addEventHandler("onPlayerJoin", getRootElement(), joinHandler)
After this, I've tried to make an command to see if anything changed..
function DebugFunction()
outputChatBox ( "Variabila are " .. gPlayerInfo[source][pLevel] .. " valoarea ",thePlayer )
end
-- comenzi
addCommandHandler("debugf", DebugFunction)
When I type /debugf in the game, nothing happens, but when I look into the server's console I get this:
[02:00:46] ERROR: ...server/mods/deathmatch/resources/eGaming/egaming.lua:36: at
tempt to index field '?' (a nil value)
[02:00:49] ERROR: ...server/mods/deathmatch/resources/eGaming/egaming.lua:68: at
tempt to index field '?' (a nil value)
Line 36 is:
gPlayerInfo[source][pLevel] = 1;
Line 68 is:
outputChatBox ( "Variabila are " .. gPlayerInfo[source][pLevel] .. " valoarea ",thePlayer )
How can I index those arrays ? What am I doing wrong ?
Any help is apreciated.
Thank you in advance.
Mike.