Resto Posted September 4, 2017 Share Posted September 4, 2017 SERVER-SIDE: local Area = createColRectangle(-2374.2119140625, -1694.4833984375, 130, 150) addEventHandler("onColShapeHit", Area, function(source) if getElementType(source) == "player" then nemesishealth = exports.extra_health:getElementExtraHealth(nemesis) triggerClientEvent(source, "addRenderHP", getRootElement(), nemesishealth) end end) addEventHandler("onColShapeLeave", Area, function(source) if getElementType(source) == "player" then triggerClientEvent(source, "RemoveRenderHP", getRootElement()) end end) CLIENT-SIDE: local screenW, screenH = guiGetScreenSize() function renderHP(nemesis) dxDrawText("Nemesis Health: "..exports.extra_health:getElementExtraHealth(nemesis).."", (screenW * 0.0000) + 1, (screenH * 0.1283) + 1, (screenW * 0.9988) + 1, (screenH * 0.1700) + 1, tocolor(0, 0, 0, 255), 2.00, "default-bold", "center", "center", false, false, false, false, false) dxDrawText("Nemesis Health: "..exports.extra_health:getElementExtraHealth(nemesis).."", screenW * 0.0000, screenH * 0.1283, screenW * 0.9988, screenH * 0.1700, tocolor(12, 254, 0, 255), 2.00, "default-bold", "center", "center", false, false, false, false, false) end function addRenderHP () addEventHandler("onClientRender", getRootElement(), renderHP) end addEvent("addRenderHP", true) addEventHandler("addRenderHP", getRootElement(), addRenderHP) function RemoveRenderHP() removeEventHandler("onClientRender", getRootElement(), renderHP) end addEvent("RemoveRenderHP", true) addEventHandler("RemoveRenderHP", getRootElement(), RemoveRenderHP) Can anyone help me with this? i don't know how to export nemesis health in client-side. Link to comment
Resto Posted September 5, 2017 Author Share Posted September 5, 2017 nothing. error or warning its not problem.. my question how i can export extra_health from server-side to client-side Link to comment
Jayceon Posted September 5, 2017 Share Posted September 5, 2017 In the server side code, change the source argument to another. (The source of this event is the colshape that got hit by a player or vehicle.) Link to comment
Resto Posted September 5, 2017 Author Share Posted September 5, 2017 Now its working only for one sec and i need always render when i join col. CLIENT-SIDE: local screenW, screenH = guiGetScreenSize() function addRenderHP(nemesis) if exports.extra_health:isElementWithExtraHealth(nemesis) then addEventHandler("onClientRender", getRootElement(), addRenderHP) dxDrawText("Nemesis Health: "..exports.extra_health:getElementExtraHealth(nemesis) .."", (screenW * 0.0000) + 1, (screenH * 0.1283) + 1, (screenW * 0.9988) + 1, (screenH * 0.1700) + 1, tocolor(0, 0, 0, 255), 2.00, "default-bold", "center", "center", false, false, false, false, false) dxDrawText("Nemesis Health: "..exports.extra_health:getElementExtraHealth(nemesis) .."", screenW * 0.0000, screenH * 0.1283, screenW * 0.9988, screenH * 0.1700, tocolor(12, 254, 0, 255), 2.00, "default-bold", "center", "center", false, false, false, false, false) end end addEvent("addRenderHP", true) addEventHandler("addRenderHP", getRootElement(), addRenderHP) function RemoveRenderHP() removeEventHandler("onClientRender", getRootElement(), addRenderHP) end addEvent("RemoveRenderHP", true) addEventHandler("RemoveRenderHP", getRootElement(), RemoveRenderHP) SERVER-SIDE: nemesis = exports["slothbot"]:spawnBot(-2337.544921875, -1618.7431640625, 483.71304321289, 0, 12, 0, 0, nil, 0, "hunting", true) exports.extra_health:setElementExtraHealth(nemesis, 10000) addEventHandler("onColShapeHit", Area, function(source) if getElementType(source) == "player" then triggerClientEvent(source, "addRenderHP", getRootElement(), nemesis) end end) Link to comment
Resto Posted September 5, 2017 Author Share Posted September 5, 2017 i fixed. so thx all for help. 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