Jump to content

Unknown cause of error (Index global)


Rettox

Recommended Posts

Hello people, I need your help. I was getting "Attempting to index global (nil value)" a lot in past, but i have solved them, somehow. I really don't know why those errors appear.

I even separated each event to single files, doesn't help anyway.

Code:

function loadWeaponsOnSpawn()
	local ped = source
	local account = getPlayerAccount(source)
	local weapon0 = getAccountData(account,"weapon0")
	local weapon1 = getAccountData(account,"weapon1")
	local weapon2 = getAccountData(account,"weapon2")
	local weapon3 = getAccountData(account,"weapon3")
	local weapon4 = getAccountData(account,"weapon4")
	local weapon5 = getAccountData(account,"weapon5")
	local weapon6 = getAccountData(account,"weapon6")
	local weapon7 = getAccountData(account,"weapon7")
	local weapon8 = getAccountData(account,"weapon8")
	local weapon9 = getAccountData(account,"weapon9")
	local weapon10 = getAccountData(account,"weapon10")
	local weapon11 = getAccountData(account,"weapon11")
	local weapon12 = getAccountData(account,"weapon12")
	local ammo0 = getAccountData(account,"ammo0")
	local ammo1 = getAccountData(account,"ammo1")
	local ammo2 = getAccountData(account,"ammo2")
	local ammo3 = getAccountData(account,"ammo3")
	local ammo4 = getAccountData(account,"ammo4")
	local ammo5 = getAccountData(account,"ammo5")
	local ammo6 = getAccountData(account,"ammo6")
	local ammo7 = getAccountData(account,"ammo7")
	local ammo8 = getAccountData(account,"ammo8")
	local ammo9 = getAccountData(account,"ammo9")
	local ammo10 = getAccountData(account,"ammo10")
	local ammo11 = getAccountData(account,"ammo11")
	local ammo12 = getAccountData(account,"ammo12")
	local cloth1 = getAccountData(account,"cloth1")
	local cloth2 = getAccountData(account,"cloth2")
	local cloth3 = getAccountData(account,"cloth3")
	local cloth4 = getAccountData(account,"cloth4")
	local cloth5 = getAccountData(account,"cloth5")
	local cloth6 = getAccountData(account,"cloth6")
	local cloth7 = getAccountData(account,"cloth7")
	local cloth8 = getAccountData(account,"cloth8")
	local cloth9 = getAccountData(account,"cloth9")
	local cloth10 = getAccountData(account,"cloth10")
	local cloth11 = getAccountData(account,"cloth11")
	local cloth12 = getAccountData(account,"cloth12")
	local cloth13 = getAccountData(account,"cloth13")
	local cloth14 = getAccountData(account,"cloth14")
	local cloth15 = getAccountData(account,"cloth15")
	local cloth16 = getAccountData(account,"cloth16")
	local cloth17 = getAccountData(account,"cloth17")
	if (weapon0) and (weapon1) and (weapon2) and (weapon3) and (weapon4) and (weapon5) and (weapon6) and (weapon7) and (weapon8) and (weapon9) and (weapon10) and (weapon11) and (weapon12) and (ammo0) and (ammo1) and (ammo2) and (ammo3) and (ammo4) and (ammo5) and (ammo6) and (ammo7) and (ammo8) and (ammo9) and (ammo10) and (ammo11) and (ammo12) then
		giveWeapon(source,weapon0,ammo0)
		giveWeapon(source,weapon1,ammo1)
		giveWeapon(source,weapon2,ammo2)
		giveWeapon(source,weapon3,ammo3)
		giveWeapon(source,weapon4,ammo4)
		giveWeapon(source,weapon5,ammo5)
		giveWeapon(source,weapon6,ammo6)
		giveWeapon(source,weapon7,ammo7)
		giveWeapon(source,weapon8,ammo8)
		giveWeapon(source,weapon9,ammo9)
		giveWeapon(source,weapon10,ammo10)
		giveWeapon(source,weapon11,ammo11)
		giveWeapon(source,weapon12,ammo12)
		setPedClothes(ped, 4, cloth4)
		setPedClothes(ped, 5, cloth5)
		setPedClothes(ped, 6, cloth6)
		setPedClothes(ped, 7, cloth7)
		setPedClothes(ped, 8, cloth8)
		setPedClothes(ped, 9, cloth9)
		setPedClothes(ped, 10, cloth10)
		setPedClothes(ped, 11, cloth11)
		setPedClothes(ped, 12, cloth12)
		setPedClothes(ped, 13, cloth13)
		setPedClothes(ped, 14, cloth14)
		setPedClothes(ped, 15, cloth15)
		setPedClothes(ped, 16, cloth16)
		setPedClothes(ped, 17, cloth17)
	end
end
addEventHandler("onPlayerSpawn",root,loadWeaponsOnSpawn)

Any help appreciated. Thanks :) I have more scripts like that, nothing helped and I'm not sure what's :Oing cause of this :Oing bull:~ error. ):-( :(

error:

[17:24:16] ERROR: [gamemodes]/[play]/play/save2.lua:29: attempt to call global 'getPedClothesID' (a nil value)
[17:24:21] ERROR: [gamemodes]/[play]/play/save1.lua:61: attempt to call global 'setPedClothes' (a nil value)

Note: It works on death, even after error message, that's what's even more weird

Edited by Rettox
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...