• This is a read only backup of the old Emudevs forum. If you want to have anything removed, please message me on Discord: KittyKaev

[SOLVED] attempt to perform arithmetic on field '? ' (a nil value)

Status
Not open for further replies.

mjafko

Epic Member
Hellou guy's.

I know its probably some eazyfix misstake, but anyway I would like to get your help.

I got
Code:
local T_x = {
0.0,5.0,-5.0,0.0,0.0,5.0,-5.0,5.0,-5.0,10.0,
};

local x,y,z,o = creature:GetLocation()
creature:SpawnCreature(QueryRow1:GetString(Count), (x + T_x[Table_Index]), (y + T_y[Table_Index]), z+5, o, 1, 5000)

What Am I doing wrong at "x + T_x[Table_Index]" I getting error " attempt to perform arithmetic on field '? ' (a nil value) " ?

Thank you guy's for your help.

Greeting's,

Marko
 

mjafko

Epic Member
Code:
local NpcId = 75000

local Count = 0;
local Count_Wave = 1;
local DELAY = 1000;

local messages = {
	'Ready?',
	'5',
	'4',
	'3',
	'2',
	'1',
};

local T_x = {
0.0,5.0,-5.0,0.0,0.0,5.0,-5.0,5.0,-5.0,10.0,
};

local T_y = {
0.0,0.0,0.0,-5.0,5.0,-5.0,-5.0,5.0,5.0,0.0,
};

local function OnSummon(event, creature, summon)
    local data = creature:GetData()
    data.counter = data.counter and data.counter > 0 and data.counter + 1 or 1
end

local function OnSummonEnd(event, creature, summon)
    local data = creature:GetData()
		data.counter = data.counter and data.counter > 1 and data.counter-1 or nil
			if data.counter == nil then
					local QueryRow1 = CharDBQuery( string.format("Select EnemyID1, EnemyID2, EnemyID3, EnemyID4, EnemyID5, EnemyID6, EnemyID7, EnemyID8, EnemyID9, EnemyID10 from noones_arena_Enemys where Wave = %s", Count_Wave))
					local QueryRow2 = CharDBQuery( string.format("select EnemyCount from Noones_arena_enemys where Wave = %s", Count_Wave))
					local Count_EntryIDs  = tonumber( QueryRow2:GetString(0) )
					Count_Wave = Count_Wave + 1;
						for index, message in ipairs(messages) do
							creature:RegisterEvent(function(_, _, _, creature)
							creature:SendUnitYell( message , 0 )
							end, DELAY * index, 1);
						end
						
						local x,y,z,o = creature:GetLocation()
						Count = 0;
							creature:RegisterEvent(function(_, _, _, creature)
								creature:SendUnitYell( string.format('WAVE num. : %s', Count_Wave), 0 )
								while ( Count_EntryIDs > 0 ) do
									creature:SpawnCreature(QueryRow1:GetString(Count), (x + T_x[Count]), (y + T_y[Count]), z+5, o, 1, 5000)
									Count = Count + 1;
									Count_EntryIDs = Count_EntryIDs - 1;
								end
							end, DELAY * #messages, 1);
			end
end

Made change from Table_Index To Count
 

Rochet2

Moderator / Eluna Dev
Count = 0
The table indexes in lua start from 1, so doing T_x[Count] returns nil since there is no element for index 0 in T_x.
 
Status
Not open for further replies.
Top