Marilith Posted April 11, 2022 Share Posted April 11, 2022 (edited) I made a script with killdayzplayer that triggers a server event to kill the other player whenever he is hit by a sniper as a method of removing the shot you miss and kill anyway. if (weapon == 34) then triggerServerEvent("kilLDayZPlayer", hitElement), in this case hitElement == "player" then identify the other player and it works. but with this method there is no "killer" so kill messages appear that the player was killed by unknown. I tried a few things but everything went wrong, does anyone have a solution? https://i.imgur.com/I2dzgln.mp4 Edited April 11, 2022 by Marilith Link to comment
Administrators Tut Posted April 11, 2022 Administrators Share Posted April 11, 2022 Moving this thread into the Scripting section for you - the Tutorials section is for tutorials on scripting in MTA 1 Link to comment
Moderators Citizen Posted April 11, 2022 Moderators Share Posted April 11, 2022 Where did you put that code ? can you show more of the script so we can see the context ? if you have the attacker available as a variable, you have to add it in your triggerServerEvent: triggerServerEvent("kilLDayZPlayer", hitElement, attacker) -- assuming attacker is the variable that holds the player element who attacked Link to comment
Marilith Posted April 11, 2022 Author Share Posted April 11, 2022 (edited) 1 hour ago, Citizen said: Where did you put that code ? can you show more of the script so we can see the context ? if you have the attacker available as a variable, you have to add it in your triggerServerEvent: triggerServerEvent("kilLDayZPlayer", hitElement, attacker) -- assuming attacker is the variable that holds the player element who attacked yes, the code is in the hitmarker script: function fireFunc(weapon, ammo, ammoInClip, hitX, hitY, hitZ, hitElement) if hitElement then if getElementType(hitElement)=="player" then screenX, screenY = getScreenFromWorldPosition(hitX, hitY, hitZ) if not screenX then return end if isDrawing then return end isDrawing = true if (weapon == 34) then triggerServerEvent("kilLDayZPlayer", hitElement) end if (weapon == 34) then setElementData(localPlayer,"murders",getElementData(localPlayer,"murders")+1) end local sound = playSound("hitmarker-sound.wav") setSoundVolume( sound , 1) addEventHandler("onClientRender", root, drawHitMarker) if drawTimer and isTimer(drawTimer) then killTimer(drawTimer) end drawTimer = setTimer(function() isDrawing = false removeEventHandler("onClientRender", root, drawHitMarker) end, 500, 1) addEventHandler ( "onPlayerDamage", root, playerDamage_text ) end end end--func addEventHandler("onClientPlayerWeaponFire", localPlayer, fireFunc) Edited April 11, 2022 by Marilith Link to comment
mafioz Posted April 11, 2022 Share Posted April 11, 2022 killPed ( hitElement, source, 34, 3 ) use instead of triggerServerEvent! Link to comment
Marilith Posted April 11, 2022 Author Share Posted April 11, 2022 17 minutes ago, shishani said: killPed ( hitElement, source, 34, 3 ) use instead of triggerServerEvent! i tested here, it seems to not worth, the image appears, but do not kill the target Link to comment
Moderators Citizen Posted April 12, 2022 Moderators Share Posted April 12, 2022 Then this should work : triggerServerEvent("kilLDayZPlayer", hitElement, source) For onClientPlayerWeaponFire, source is the player element who fired the weapon, so adding it as the attacker attacker for the kilLDayZPlayer event should do the trick. Link to comment
Marilith Posted April 12, 2022 Author Share Posted April 12, 2022 4 hours ago, Citizen said: Then this should work : triggerServerEvent("kilLDayZPlayer", hitElement, source) For onClientPlayerWeaponFire, source is the player element who fired the weapon, so adding it as the attacker attacker for the kilLDayZPlayer event should do the trick. the idea was good, it really should work, but now when the element gets hit, he bug and needs to reconnect, i'll try to see why this happen 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