rusztamas Posted March 30, 2017 Share Posted March 30, 2017 function halhatatlansag() if getElementData(source, "halhatatlan", true) then cancelEvent() end end addEventHandler("onClientPlayerDamage", getRootElement(), halhatatlansag) If you join the server, it sets your elementData(halhatatlansag) to true, but i still get damages, and my hp is going down... i'd like to do it like setElementData (source, "invincible", true) and setElementData (source, "invincible", false) so it would be like "toggleable" but i have no idea how to do that. Could you please help me? Link to comment
NeXuS™ Posted March 30, 2017 Share Posted March 30, 2017 Replace line nr 2. with if getElementData(source, "halhatatlan") then 1 Link to comment
LoPollo Posted March 30, 2017 Share Posted March 30, 2017 1 minute ago, NeXuS™ said: Replace line nr 2. with if getElementData(source, "halhatatlan") then Changed "true" with the default (true)? mmm i would suggest posting the code where you set the data (on connect) Also, you may add an outputchatbox that tells you the data value when the player gets damaged Another advice, it could be better not binding the event to root but to localPlayer (so every player won't use it on other players, since they will have their own clientside script doing it) 1 Link to comment
NeXuS™ Posted March 30, 2017 Share Posted March 30, 2017 (edited) @LoPollo, he doesn't need to register inherit at all in this script, could leave it blank. Working on finding the problem right now, so I can post a full code here, with explanation. Edited March 30, 2017 by NeXuS™ Link to comment
LoPollo Posted March 30, 2017 Share Posted March 30, 2017 @NeXuS™ the default inherit is true, so if you don't want it you must NOT leave blank, you MUST pass false. Link to comment
NeXuS™ Posted March 30, 2017 Share Posted March 30, 2017 So why would he just write in true, and not leave it blank? If you would know this person, you would know what he was thinking when he wrote that "true" in there. Link to comment
LoPollo Posted March 30, 2017 Share Posted March 30, 2017 (edited) var getElementData ( element theElement, string key [, inherit = true] ) You probably want to do this: getElementData(someElement,someKey,false) since getElementData(someElement,someKey,true) === getElementData(someElement,someKey) hope i've been clear Edited March 30, 2017 by LoPollo 1 Link to comment
NeXuS™ Posted March 30, 2017 Share Posted March 30, 2017 (edited) Buddy, you don't understand my post above at all. He thought he wrote if getElementData(...) == true then with if getElementData(..., ..., true) then So if he wanted to write if getElementData(...) == false then he would just write if getElementData(..., ..., false) then So before he thought that this is the way he would do it, I corrected his code, so he doesn't think that he is checking the elementdata with that true as the last argument. Edited March 30, 2017 by NeXuS™ 1 Link to comment
rusztamas Posted March 30, 2017 Author Share Posted March 30, 2017 Still getting damage. Script: addEventHandler ("onPlayerJoin", getRootElement(), function() setElementData (source, "halhatatlan", true) end ) addCommandHandler ("am_i_halhatatlan", function() if setElementData (source, "halhatatlan", true) then outputChatBox ("#A1D490[King of the Kill]#FFFFFF Aha.", admin, 255, 255, 255, true) else outputChatBox ("#A1D490[King of the Kill]#FFFFFF Nem.", admin, 255, 255, 255, true) end end ) addCommandHandler ("disable_halhatatlan", function() if setElementData (source, "halhatatlan", false) then outputChatBox ("#A1D490[King of the Kill]#FFFFFF Kikapcsolva: halhatatlan.", admin, 255, 255, 255, true) end end ) function halhatatlansag() if getElementData(source, "halhatatlan") then cancelEvent() end end addEventHandler("onClientPlayerDamage", getRootElement(), halhatatlansag) Link to comment
NeXuS™ Posted March 30, 2017 Share Posted March 30, 2017 (edited) Server side addEventHandler("onPlayerJoin", getRootElement(), function() setElementData(source, "halhatatlan", true) end) addEventHandler("onResourceStart", getResourceRootElement(), function() for i, k in ipairs(getElementsByType("player")) do setElementData(k, "halhatatlan", true) end end) Client side function halhatatlansag() if getElementData(source, "halhatatlan") then cancelEvent() end end addEventHandler("onClientPlayerDamage", localPlayer, halhatatlansag) addCommandHandler("godmode", function() setElementData(localPlayer, "halhatatlan", not getElementData(localPlayer, "halhatatlan")) outputChatBox("#FF0000[INFO]#FFFFFF Halhatalanság " .. (getElementData(localPlayer, "halhatatlan") and "bekapcsolva" or "kikapcsolva") .. ".", 0, 0, 0, true) end) Works just totally fine for me. Edited March 30, 2017 by NeXuS™ 1 Link to comment
rusztamas Posted March 30, 2017 Author Share Posted March 30, 2017 39 minutes ago, NeXuS™ said: Server side addEventHandler("onPlayerJoin", getRootElement(), function() setElementData(source, "halhatatlan", true) end) addEventHandler("onResourceStart", getResourceRootElement(), function() for i, k in ipairs(getElementsByType("player")) do setElementData(k, "halhatatlan", true) end end) Client side function halhatatlansag() if getElementData(source, "halhatatlan") then cancelEvent() end end addEventHandler("onClientPlayerDamage", getRootElement(), halhatatlansag) addCommandHandler("godmode", function() setElementData(localPlayer, "halhatatlan", not getElementData(localPlayer, "halhatatlan")) outputChatBox("#FF0000[INFO]#FFFFFF Halhatalanság " .. (getElementData(localPlayer, "halhatatlan") and "bekapcsolva" or "kikapcsolva") .. ".", 0, 0, 0, true) end) Works just totally fine for me. it works thanks 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