Robis Posted December 25, 2016 Share Posted December 25, 2016 Hello! Im newbie, so can anyone help me with these warnings? Bad argument @ 'destroyElement' [Expected element at argument 1, got boolean] and Bad argument @ 'getPlayerName' [Expected element at argument 1, got boolean] script: triggerClientEvent ( "onRollMessageStart", getRootElement(),"#FFFFFF"..getPlayerName(source).." #FFFFFFwas killed by "..(getPlayerName(killer) or "unknown")..".",0,22,255, "died") destroyElement(getElementData(source, "playerCol")) Dayz Gamemode! Thanks! Link to comment
koragg Posted December 25, 2016 Share Posted December 25, 2016 (edited) Hey, the "destroyElement" destroys elements, and you're trying to destroy ElementData. Check this example taken from the wiki: for i,v in ipairs(vehicles) do -- if the vehicle's ID is the one provided, destroy it if (getElementModel(v) == modelID) then destroyElement(v) end end In the above case the function "destroyElement" destroys the vehicle. It can also be used to destroy other elements but "ElementData" is not an element. If you want to remove it, you can use something like: if getElementData(source, "playerCol") then setElementData(source, "playerCol", nil) end And about the getPlayerName, please post the full script so I can see what's wrong (killer can be undefined) Edited December 25, 2016 by koragg Link to comment
pa3ck Posted December 25, 2016 Share Posted December 25, 2016 I don't think he is trying to destroy element data, I guess "playerCol" is some sort of a marker that's been stored in the element data. See the problem is, that we can't see where the "source" is coming from, can you also include the function that calls these 2 lines? Link to comment
Rataj Posted December 25, 2016 Share Posted December 25, 2016 (edited) It's obvious that he's trying to destroy an element saved in the element data, also it's probably inside onPlayerWasted function (source, killer). Problem is, getElementData(source, "playerCol") is not set. You can get rid of these warnings using this (replace second line of your shown code with those lines): local playerCol = getElementData(source, "playerCol") if playerCol and isElement(playerCol) then destroyElement(playerCol) end But that doesn't change anything on fact, that you have to save your element to the element data first (using setElementData(thePlayer, "playerCol", YOUR_ELEMENT) on spawn or wherever you are creating "YOUR_ELEMENT"). EDIT: By the way koragg, easier way to remove element data is function named removeElementData. Edited December 25, 2016 by Rataj 1 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