ForLaXPy Posted September 5, 2017 Share Posted September 5, 2017 Well I recently made a new script that gonna attach some weapon to a specific and i bounded this function to key and evrything was going fine the weapons ae attached to the car and its firing and alls good but the issue is when i try to shoot another player car or i try to damage a player , I cannot do well i think because that function is only called for the client when he press the bind and i was looking arround for something to let that fire dmg the others but i cant find in mta client function wiki that's why I'm seeking for help here local replacementGunKey = "vehicle_fire" function addt() bindKey ( replacementGunKey, "both", fireHydraGuns ) end addEventHandler ( "onClientResourceStart", root, addt) function fireHydraGuns ( key, keyState ) if ( keyState == "down" ) then if ( key == replacementGunKey ) and hydraGuns == true then toggleControl ( replacementGunKey, false ) setWeaponState(hydraGunL, "firing") setWeaponState(hydraGunR, "firing") fireWeapon(hydraGunL) fireWeapon(hydraGunR) setWeaponProperty(hydraGunL, "fire_rotation", 10, 4, 0) setWeaponProperty(hydraGunR, "fire_rotation", 10, 4, 0) end end if ( keyState == "up" ) then if ( key == replacementGunKey ) or hydraGuns == false then setWeaponState(hydraGunL, "ready") setWeaponState(hydraGunR, "ready") toggleControl ( replacementGunKey, true ) end end end Link to comment
ForLaXPy Posted September 5, 2017 Author Share Posted September 5, 2017 Anyone ? i really need to fix this Link to comment
Moderators IIYAMA Posted September 5, 2017 Moderators Share Posted September 5, 2017 Is the weapon not firing? Or is the weapon not doing damage? It is true that weapons stopped doing damage at a given moment. (not sure what the reason behind this is) You can fix that problem with: https://wiki.multitheftauto.com/wiki/OnClientWeaponFire https://wiki.multitheftauto.com/wiki/SetElementHealth Link to comment
ForLaXPy Posted September 6, 2017 Author Share Posted September 6, 2017 the Car is shooting Fine but there is no dmg for vehicles or players I tryed to Add this function using your event and still nothing function DamageToPlayersFromCustomWeapons(target) if target == localPlayer then setElementHealth ( target, -5 ) elseif isElement( target ) and getElementType( target ) == "vehicle" then setElementHealth ( target, -10 ) end end addEventHandler("onClientWeaponFire", root, DamageToPlayersFromCustomWeapons) Link to comment
Moderators IIYAMA Posted September 7, 2017 Moderators Share Posted September 7, 2017 function DamageToPlayersFromCustomWeapons(hitElement) iprint("onClientWeaponFire") if hitElement then iprint("hitElement exist") if hitElement == localPlayer then setElementHealth(hitElement, math.max(getElementHealth(hitElement) - 5, 0)) iprint("hit localPlayer") elseif getElementType( hitElement ) == "vehicle" then setElementHealth(hitElement, math.max(getElementHealth(hitElement) - 10, 0)) iprint("hit vehicle") end end end addEventHandler("onClientWeaponFire", root, DamageToPlayersFromCustomWeapons) Try this and show the debug results. Link to comment
ForLaXPy Posted September 7, 2017 Author Share Posted September 7, 2017 (edited) Well @IIYAMA I tried it and it works for vehicle that in the debug prints : INFO: "onClientWeaponFire" INFO: "hitElement exist" INFO: "hit vehicle" But when i tested it with a player I found this INFO: "onClientWeaponFire" INFO: "hitElement exist" and nothing about hit localplayer also no dmg for them Edited September 7, 2017 by ForLaXPy fix Link to comment
Moderators IIYAMA Posted September 7, 2017 Moderators Share Posted September 7, 2017 If the localPlayer gets hit, other players will not see: "hit localPlayer" (only the localPlayer will see that message if it is actually working) Replace line 4 with this: iprint("hitElement exist, element type of the hitElement =", getElementType(hitElement),", the userdata of the hitElement =", hitElement, ", the userdata of the localPlayer =", localPlayer) To see what is going. 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