Lucario Posted May 15, 2013 Share Posted May 15, 2013 Hello, i need a help, when i created a new function for the godmode, with dxdrawtext in client side, it give me a error, addeventhandler expected argument and argument 3 got nil, line 27, the code with the problem. addEventHandler( 'onClientRender', root, function (targetPlayer) for _, player in ipairs( getElementsByType( 'player')) do 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( 'Dont attack me again, or i will punish you', px, py, px, py, tocolor( 255, 255, 255, 255 ), 1, "arial-bold", "center", "center", false, false, false , true ) getElementHealth (player, -8) addEventHandler("onClientPlayerStealthKill", player, targetPlayer) end end end end) Link to comment
denny199 Posted May 15, 2013 Share Posted May 15, 2013 can you show me the "targetPlayer" function? And why are you using getElementHealth ( player, -8 ) ? Link to comment
Lucario Posted May 15, 2013 Author Share Posted May 15, 2013 Sure, here is the full code of the server side. 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 (targetPlayer) for _, player in ipairs( getElementsByType( 'player')) do 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( 'Pegame Otra Vez y Te Pateare el Culo', px, py, px, py, tocolor( 255, 255, 255, 255 ), 1, "arial-bold", "center", "center", false, false, false , true ) getElementHealth (player, -8) addEventHandler("onClientPlayerStealthKill", player, targetPlayer) end end end end) I think i was wrong in the targetPlayer, i use setelementhealth -8 for if the attacker attack me with a weapon or without, he rest -8 of health, and show him the message up of the staff head Link to comment
iPrestege Posted May 15, 2013 Share Posted May 15, 2013 I Don't see any function with 'targetPlayer' Handler function ? Link to comment
PaiN^ Posted May 15, 2013 Share Posted May 15, 2013 onClientPlayerDamage in server side ?? Link to comment
Lucario Posted May 15, 2013 Author Share Posted May 15, 2013 D: can you fix it please, i just leorn lua, but pro in other programation, i say after the targetPlayer i mistaked, but i dont know what put there, and on onclientplayerdamage is client side bro Link to comment
50p Posted May 15, 2013 Share Posted May 15, 2013 Sure, here is the full code of the server side. 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 (targetPlayer) for _, player in ipairs( getElementsByType( 'player')) do 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( 'Pegame Otra Vez y Te Pateare el Culo', px, py, px, py, tocolor( 255, 255, 255, 255 ), 1, "arial-bold", "center", "center", false, false, false , true ) getElementHealth (player, -8) addEventHandler("onClientPlayerStealthKill", player, targetPlayer) end end end end) I think i was wrong in the targetPlayer, i use setelementhealth -8 for if the attacker attack me with a weapon or without, he rest -8 of health, and show him the message up of the staff head It's client-side code then why do you use it server-side? What does the line with getElementHealth do? You don't even assign its return value to a variable and you pass another argument even though that function only need the element whose health you want to get. What is targetPlayer at line 25? Link to comment
Lucario Posted May 15, 2013 Author Share Posted May 15, 2013 I alredy said, i dont know why i put targetPlayer, and what event handler i must use and replace the onClientPlayerDamage? Link to comment
50p Posted May 16, 2013 Share Posted May 16, 2013 What line and what error are you getting? addeventhandler expected argument and argument 3 got nil, line 27 There is nothing at line 27 that would make any sense. You're not helping us to help you. You just make it difficult for us to find the problem. The code looks fine to me except for that targetPlayer. onClientRender does not pass any arguments to the handled function so targetPlayer will always be nil. Link to comment
denny199 Posted May 16, 2013 Share Posted May 16, 2013 You only need to set the data of the player "invincible" to "true". addEventHandler ( "onClientPlayerDamage",root,function () if (getElementData(getLocalPlayer(),"invincible") == "true") then cancelEvent() end end) addEventHandler("onClientPlayerStealthKill", getLocalPlayer(), function () if (getElementData(getLocalPlayer(),"invincible") == "true") then cancelEvent() end end) addEventHandler( 'onClientRender', root, function () for _, player in ipairs( getElementsByType( 'player')) do if (getElementData(player,"invincible") == "true") 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( "I have godmode....", px, py, px, py, tocolor( 255, 255, 255, 255 ), 1, "arial-bold", "center", "center", false, false, false , true ) end end end end end) Not tested. Link to comment
Lucario Posted May 16, 2013 Author Share Posted May 16, 2013 addEventHandler ( "onClientPlayerDamage",root,function () if (getElementData(getLocalPlayer(),"invincible") == "true") then cancelEvent() end end) addEventHandler("onClientPlayerStealthKill", getLocalPlayer(), function () if (getElementData(getLocalPlayer(),"invincible") == "true") then cancelEvent() end end) addEventHandler( 'onClientRender', root, function () for _, player in ipairs( getElementsByType( 'player')) do if getElementData(source,"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( 'Pegame Otra Vez y Te Pateare el Culo', px, py, px, py, tocolor( 255, 255, 255, 255 ), 1, "arial-bold", "center", "center", false, false, false , true ) setElementHealth (player, -8) end end end end end) Now it not give errors, but the message dont shows in the head of the staff and not display when a player shoot me, and i changed getelementhealth to setelementhealth (my error ) but the health not be get Link to comment
denny199 Posted May 16, 2013 Share Posted May 16, 2013 ... if getElementData(source,"invincible") then Source is nothing, please try my code. Link to comment
Lucario Posted May 16, 2013 Author Share Posted May 16, 2013 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 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( 'Pegame Otra Vez y Te Pateare el Culo', px, py, px, py, tocolor( 255, 255, 255, 255 ), 1, "arial-bold", "center", "center", false, false, false , true ) setElementHealth (player, -8) end end end end end) I changed source to player? now? Link to comment
Lucario Posted May 16, 2013 Author Share Posted May 16, 2013 Im trying to draw a text upside my head when the godmode is enabled, and when a player hit me or shoot me, and slap him 8 hp Link to comment
Castillo Posted May 16, 2013 Share Posted May 16, 2013 Try this one: local playerToDraw local lastTick addEventHandler ( "onClientPlayerDamage", root, function ( attacker ) if getElementData ( source, "invincible" ) then if isElement ( attacker ) then removeEventHandler ( "onClientRender", root, renderText ) setElementHealth ( attacker, getElementHealth ( attacker ) - 8 ) playerToDraw = source lastTick = getTickCount ( ) addEventHandler ( "onClientRender", root, renderText ) end cancelEvent ( ) end end ) addEventHandler ( "onClientPlayerStealthKill", localPlayer, function ( targetPlayer ) if getElementData ( targetPlayer, "invincible" ) then removeEventHandler ( "onClientRender", root, renderText ) setElementHealth ( localPlayer, getElementHealth ( localPlayer ) - 8 ) playerToDraw = targetPlayer lastTick = getTickCount ( ) addEventHandler ( "onClientRender", root, renderText ) cancelEvent ( ) end end ) function renderText ( ) if ( playerToDraw and lastTick ) then if ( getTickCount ( ) - lastTick >= 5000 ) then playerToDraw = nil lastTick = nil return removeEventHandler ( "onClientRender", root, renderText ) end if getElementData ( playerToDraw, "invincible" ) then local x, y, z = getElementPosition ( playerToDraw ) 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 ( 'Pegame Otra Vez y Te Pateare el Culo', 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
Lucario Posted May 16, 2013 Author Share Posted May 16, 2013 thank you solid, now it works , can you add me to skype please? multikiller18, i speak spanish Link to comment
iPrestege Posted May 16, 2013 Share Posted May 16, 2013 thank you solid, now it works , can you add me to skype please? multikiller18, i speak spanish I think there's a private messages . 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