ice_brasil Posted May 5, 2013 Share Posted May 5, 2013 I want that when my god-mode is activated A message appears on top of my head for members to know that I'm using god. My Cliente.lua: addEventHandler ( "onClientPlayerDamage",root, function () if getElementData(source,"invincible") then cancelEvent() end end) addEventHandler("onClientPlayerStealthKill",localPlayer, function (targetPlayer) if getElementData(targetPlayer,"invincible") then cancelEvent() end end) local screenWidth, screenHeight = guiGetScreenSize ( ) -- Get the screen resolution (width and height) I know I have to use more dxdrawtext already tested and failed. What do I add could please! Link to comment
tosfera Posted May 5, 2013 Share Posted May 5, 2013 My way of thinking would be; create a colshape and attach it to your head, if any user enters the colshape, use the dxdraw above your head. You can see a similar thing in the house system from DaKilla at the community. Sec I'll search the source. edit; source can be found here: https://community.multitheftauto.com/index.php?p= ... ils&id=727 Link to comment
50p Posted May 5, 2013 Share Posted May 5, 2013 If you're storing data in element in "invincible" key then check it in onClientRender then draw the text (dxDrawText is what you asked about and what you should use in onClientRender event). addEventHandler( "onClientRender", root, function( ) for _, plr in pairs( getElementsByType( "player" ) ) do -- iterate through all players if isElementOnScreen( plr ) and getElementData( plr, "invincible" ) then -- check if player is on screen, then draw the text or an image -- dxDrawText or dxDrawImage -- you'll need to use getScreenFromWorldPosition to get the screen position (X and Y coords) of the player (getElementPosition or getPedBonePosition) end end end, ) Link to comment
ice_brasil Posted May 5, 2013 Author Share Posted May 5, 2013 I could not please help well tried and it did not: addEventHandler ( "onClientPlayerDamage",root, function () if getElementData(source,"invincible") then cancelEvent() end end) addEventHandler("onClientPlayerStealthKill",localPlayer, function (targetPlayer) if getElementData(targetPlayer,"invincible") then cancelEvent() end end) addEventHandler( "onClientRender", root, function( ) for _, plr in pairs( getElementsByType( "player" ) ) do -- iterate through all players if isElementOnScreen( plr ) and getElementData( plr, "invincible" ) then -- check if player is on screen, then draw the text or an image dxDrawText( 'GODMODE On '..invincible, px, py + scY/38, px, py, tocolor( 255, 255, 255, 255 ), 1, 'default-bold', 'center', 'center', false, false ); end end end, HEEEEELP add me, I'm still newbie Link to comment
Blaawee Posted May 5, 2013 Share Posted May 5, 2013 try this : addEventHandler ( "onClientPlayerDamage",root, function () if getElementData(source,"invincible") then cancelEvent() end end ) addEventHandler("onClientPlayerStealthKill",localPlayer, function (targetPlayer) if getElementData(targetPlayer,"invincible") then cancelEvent() end end ) addEventHandler( 'onClientRender', root, function( ) for _, player in ipairs( getElementsByType( 'player') ) do if isElementOnScreen( player ) and getElementData( player, 'invincible' ) then local x, y, z = getElementPosition( player ); local cx, cy, cz = getCameraMatrix( ); if getDistanceBetweenPoints3D( cx, cy, cz, x, y, z ) <= 15 then local px, py = getScreenFromWorldPosition( x, y, z + 1.3, 0.06 ); if px then dxDrawText( 'GodMode : ' .. tostring( getElementData( player, "invincible" ) ), px, py, px, py, tocolor( 255, 255, 255, 255 ), 1, "arial-bold", "center", "center", false, false, false , true ); end end end end end ); Link to comment
ice_brasil Posted May 5, 2013 Author Share Posted May 5, 2013 Thank you all, you are the best. 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