Death Posted April 21, 2015 Posted April 21, 2015 I am not able to use the trigger -------------- server resourceRoot = getResourceRootElement() function createNew() for _, areia in pairs ( radar_table ) do pesq = executeSQLQuery("SELECT * FROM `area` WHERE `nome`=?", area.nome ) for k, a in ipairs (pesq) do triggerClientEvent( "onSetOwner", root, areia.nome, a.owner, areia.preco, areia.x, areia.y, areia.z, a.corR, a.corG, a.corB) end end end addEventHandler("onResourceStart", resourceRoot, createNew) client addEvent("onSetOwner", true) function lol(name, owner, preco, x, y, z, red, green, blue) outputChatBox(name) outputChatBox(owner) outputChatBox(preco) outputChatBox(x) outputChatBox(y) outputChatBox(z) outputChatBox(red) outputChatBox(green) outputChatBox(blue) end addEventHandler ( "onSetOwner", root, lol )
Death Posted April 21, 2015 Author Posted April 21, 2015 Bad argument @ 'triggerClientEvent' [Expected element at argument 2, got nil]
Walid Posted April 21, 2015 Posted April 21, 2015 Bad argument @ 'triggerClientEvent' [Expected element at argument 2, got nil] try this resourceRoot = getResourceRootElement() function createNew() for _, areia in pairs ( radar_table ) do pesq = executeSQLQuery("SELECT * FROM `area` WHERE `nome`=?", area.nome ) for k, a in ipairs (pesq) do triggerClientEvent( root,"onSetOwner", root, areia.nome, a.owner, areia.preco, areia.x, areia.y, areia.z, a.corR, a.corG, a.corB) end end end addEventHandler("onResourceStart", resourceRoot, createNew)
Death Posted April 21, 2015 Author Posted April 21, 2015 ERROR : Server triggered clientside event onSetOwner, but event is not added clientside
Walid Posted April 21, 2015 Posted April 21, 2015 ERROR : Server triggered clientside event onSetOwner, but event is not added clientside ok all what you need to do is -- Client side addEventHandler("onClientResourceStart",resourceRoot, function() triggerServerEvent( "clientReady", resourceRoot ) end ) -- Server side readyPlayerList = {} addEvent("clientReady", true ) addEventHandler("clientReady",resourceRoot, function() table.insert( readyPlayerList, client ) createNew() end ) addEventHandler("onPlayerQuit",root, function() table.removevalue( readyPlayerList, source ) end ) -- Your function function createNew() for _, areia in pairs ( radar_table ) do pesq = executeSQLQuery("SELECT * FROM `area` WHERE `nome`=?", areia.nome ) for k, a in ipairs (pesq) do triggerClientEvent(readyPlayerList,"onSetOwner",readyPlayerList, areia.nome, a.owner, areia.preco, areia.x, areia.y, areia.z, a.corR, a.corG, a.corB) end end end -- table.removevalue function, in case you don't already have it function table.removevalue(t, val) for i,v in ipairs(t) do if v == val then table.remove(t, i) return i end end return false end
Death Posted April 21, 2015 Author Posted April 21, 2015 not work [2015-04-21 14:43:11] Warning Bad usage @ 'triggerClientEvent' [ section in the meta.xml is incorrect or missing (expected at least server 1.3.0-9.04570 because a send list is being used)]
Walid Posted April 21, 2015 Posted April 21, 2015 use upgrade all type upgrade all in your console then click enter
Death Posted April 21, 2015 Author Posted April 21, 2015 other error [2015-04-21 14:52:03] WARNING: Sistema_BASES\script.lua:35: Bad argument @ 'triggerClientEvent' [Expected element at argument 3, got table]
Walid Posted April 21, 2015 Posted April 21, 2015 other error [2015-04-21 14:52:03] WARNING: Sistema_BASES\script.lua:35: Bad argument @ 'triggerClientEvent' [Expected element at argument 3, got table] try this triggerClientEvent(readyPlayerList,"onSetOwner",root, areia.nome, a.owner, areia.preco, areia.x, areia.y, areia.z, a.corR, a.corG, a.corB)
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now