WelCome Posted July 9, 2018 Share Posted July 9, 2018 Hello i want create a new hitbox-system but i have little problem with headshot -client function returining(endZ) return triggerServerEvent("daj_cos",localPlayer,endZ) end addEventHandler("onClientPlayerWeaponFire",getLocalPlayer(),function(weapon, ammo, ammoInClip,endX,endY,endZ,hitElement) if not getElementType(hitElement)=="player" then return end if returining(endZ)<0.3 then outputChatBox("true") end end) -server addEvent("daj_cos",true) addEventHandler("daj_cos",root,function(endZ) for i,v in pairs(getElementsByType("player")) do local x,y,z = getElementPosition(v) local distance = getDistanceBetweenPoints3D(_,_,z,_,_,endZ) return distance end end) Link to comment
Moderators IIYAMA Posted July 9, 2018 Moderators Share Posted July 9, 2018 You can not use return to send information to the other side. Sending information cost time(ping) and the code doesn't wait for that. Think about about ping pong. You hit a ping pong ball with a bat and it takes some time before it comes back to you. You need two trigger events to make this work + restructure code. Link to comment
WelCome Posted July 9, 2018 Author Share Posted July 9, 2018 I don't know how to do it Link to comment
Moderators IIYAMA Posted July 9, 2018 Moderators Share Posted July 9, 2018 https://wiki.multitheftauto.com/wiki/TriggerClientEvent instead of return, trigger from serverside to clientside. Link to comment
WelCome Posted July 9, 2018 Author Share Posted July 9, 2018 (edited) :facepalm: client addEventHandler("onClientPlayerWeaponFire",getLocalPlayer(),function(weapon, ammo, ammoInClip,endX,endY,endZ,hitElement) triggerServerEvent("daj_cos",localPlayer,endZ,hitElement) end) server addEvent("daj_cos",true) addEventHandler("daj_cos",root,function(endZ,hitElement) local x,y,z = getElementPosition(hitElement) if getDistanceBetweenPoints3D(_,_,z,_,_,endZ)<1.0 then killPed(hitElement) end end) db : Bad argument getDistanceBetweenPoints3D [ Expected vector3 at argument 1, got nil] Edited July 9, 2018 by WelCome Link to comment
Moderators IIYAMA Posted July 9, 2018 Moderators Share Posted July 9, 2018 (edited) getDistanceBetweenPoints3D(0,0,z,0,0,endZ) Those values are not optional. You have to fill them in. If they were optional, the syntax would be: getDistanceBetweenPoints3D([float x], [float y], [float z], [float x2], [float y2], [float z2]) Edited July 9, 2018 by IIYAMA 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