Jump to content

i need a little help


Marilith

Recommended Posts

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 by Marilith
Link to comment
  • Moderators

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
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 by Marilith
Link to comment
  • Moderators

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
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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...