Mikhail Posted October 15, 2018 Share Posted October 15, 2018 (edited) Spoiler barreratbl = {} function consoleCreateObject ( player, commandName ) if exports.factions:isPlayerInFaction(player, 1) then local x, y, z = getElementPosition ( player ) -- get the player's position -- create a Object next to the player: obb = createObject ( 1228, x + 2, y , z, 0, 0, 0 ) table.insert (barreratbl, obb) if (obb) then outputChatBox("Barrier created",player,0,255,0) else outputChatBox("Barrier not created",player,255,0,0) end else outputChatBox("You aren't FCPD!!",player,255,0,0) end end addCommandHandler ( "barrera", consoleCreateObject ) function consoleCreateObject ( player, commandName ) if exports.factions:isPlayerInFaction(player, 1) then for i, v in pairs (barreratbl) do destroyElement ( v )-- check if the Obeject was created successfully end outputChatBox("The object was removed!!",player,0,255,0) else outputConsole ( "you aren't FCPD!!", player ) end end when i put the comand many times and created more than 1 barrier.. and put "/sacarbarrera" they are removed but with 1 problems.. 1- WARNING: com\com.lua:138: Bad argument @ 'destroyElement' [Expected element at argument 1] [DUP x4] please help! im new in scripting.. Edited October 15, 2018 by Mikhail Link to comment
LyricalMM Posted October 15, 2018 Share Posted October 15, 2018 d destroyElement(i) i don't know if it works, but u can try Link to comment
Z4Zy Posted October 15, 2018 Share Posted October 15, 2018 Or you can check that are there any element exist before destroy it. barreratbl = {} function consoleCreateObject ( player, commandName ) if exports.factions:isPlayerInFaction(player, 1) then local x, y, z = getElementPosition ( player ) -- get the player's position -- create a Object next to the player: obb = createObject ( 1228, x + 2, y , z, 0, 0, 0 ) table.insert (barreratbl, obb) if (obb) then outputChatBox("Barrier created",player,0,255,0) else outputChatBox("Barrier not created",player,255,0,0) end else outputChatBox("You aren't FCPD!!",player,255,0,0) end end addCommandHandler ( "barrera", consoleCreateObject ) function consoleCreateObject ( player, commandName ) if exports.factions:isPlayerInFaction(player, 1) then for i, v in pairs (barreratbl) do if isElement( v ) then destroyElement ( v )-- check if the Obeject was created successfully outputChatBox("The object was removed!!",player,0,255,0) end end else outputConsole ( "you aren't FCPD!!", player ) end end Link to comment
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