MatiMTA Posted April 25, 2019 Share Posted April 25, 2019 (edited) In this code I try to make it possible to add new data to the user, depending on certain conditions of "getElementData (source," KD "), but it says" Attempt to concatenate a boleean value. "And the data is not a boolean, it is a I do not understand the error.. It's server side. The data( getElementData(source, "KD") ) its a number type. I do not want to do something difficult, I just want that when I log in I set a text in a data, where I can use it in a gui on client side. Can you help me? Thank you function SetearDatas() if((getElementData(source, "KD")) < 1) then setElementData(source, "ranking", "Bronze") --Bronce else if(getElementData(source, "KD") >= 1 and getElementData(source, "KD") < 2.5) then setElementData(source, "ranking", "Silver") --Plata else if(getElementData(source, "KD") >= 2.5 and getElementData(source, "KD") < 4) then setElementData(source, "ranking", "Gold") --Oro else if(getElementData(source, "KD") >= 4 and getElementData(source, "KD") < 7) then setElementData(source, "ranking", "Platinum") --Platino else if(getElementData(source, "KD") >= 7 and getElementData(source, "KD") < 10) then setElementData(source, "ranking", "Diamond") --Diamante else if(getElementData(source, "KD") >= 10) then setElementData(source, "ranking", "Master") --Challenger end end end end end end end addEventHandler ("onPlayerLogin", getRootElement(), SetearDatas) function statsss () outputChatBox("Your rank is: "..getElementData (source, "ranking"), source,0,255,0) end addCommandHandler ( "statinfo", statsss ) Edited April 25, 2019 by MatiMTA Link to comment
Enargy, Posted April 25, 2019 Share Posted April 25, 2019 function SetearDatas() local KD = getElementData(source, "KD") or 0 if (KD < 1) then setElementData(source, "ranking", "Bronze") --Bronce elseif (KD >= 1 and KD < 2.5) then setElementData(source, "ranking", "Silver") --Plata elseif (KD >= 2.5 and KD < 4) then setElementData(source, "ranking", "Gold") --Oro elseif (KD >= 4 and KD < 7) then setElementData(source, "ranking", "Platinum") --Platino elseif (KD >= 7 and KD < 10) then setElementData(source, "ranking", "Diamond") --Diamante elseif (KD >= 10) then setElementData(source, "ranking", "Master") --Challenger end end addEventHandler ("onPlayerLogin", getRootElement(), SetearDatas) function statsss () outputChatBox("Your rank is: ".. (getElementData (source, "ranking") or "None"), source,0,255,0) end addCommandHandler ( "statinfo", statsss ) 1 Link to comment
MatiMTA Posted April 26, 2019 Author Share Posted April 26, 2019 4 minutes ago, Enargy, said: function SetearDatas() local KD = getElementData(source, "KD") or 0 if (KD < 1) then setElementData(source, "ranking", "Bronze") --Bronce elseif (KD >= 1 and KD < 2.5) then setElementData(source, "ranking", "Silver") --Plata elseif (KD >= 2.5 and KD < 4) then setElementData(source, "ranking", "Gold") --Oro elseif (KD >= 4 and KD < 7) then setElementData(source, "ranking", "Platinum") --Platino elseif (KD >= 7 and KD < 10) then setElementData(source, "ranking", "Diamond") --Diamante elseif (KD >= 10) then setElementData(source, "ranking", "Master") --Challenger end end addEventHandler ("onPlayerLogin", getRootElement(), SetearDatas) function statsss () outputChatBox("Your rank is: ".. (getElementData (source, "ranking") or "None"), source,0,255,0) end addCommandHandler ( "statinfo", statsss ) Basically the (getElementData (source, "KD")) results in the case of my account = 0.5 And in line 3 of the code should take effect, but it does not. Why could it be? Link to comment
Enargy, Posted April 26, 2019 Share Posted April 26, 2019 3 minutes ago, MatiMTA said: Basically the (getElementData (source, "KD")) results in the case of my account = 0.5 And in line 3 of the code should take effect, but it does not. Why could it be? That's weird... the code is right. Are you typing the command after you get logged in? 1 Link to comment
MatiMTA Posted April 26, 2019 Author Share Posted April 26, 2019 14 minutes ago, Enargy, said: That's weird... the code is right. Are you typing the command after you get logged in? I have discovered that it is not (getElementData (source, "KD")). Actually it's "getElementData (player," DayZAsesinatos ") / getElementData (player," DayZMuerte ")". But try to change the (local KD) in line 2 with that information, but it did not work. 20 minutes ago, Enargy, said: That's weird... the code is right. Are you typing the command after you get logged in? I just fixed. Thank you very much for the help. It was a problem to change "player" to "source". Link to comment
Enargy, Posted April 26, 2019 Share Posted April 26, 2019 14 hours ago, MatiMTA said: I just fixed. Thank you very much for the help. It was a problem to change "player" to "source". I did not see that lol. Anyways you're welcome. 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