Jump to content

Need help please .


Dude'

Recommended Posts

i saw fady's scripts which is hit script and i added onClientPlayerQuit to destroy the player blip when he quit but plz fix the script.

this is server side

function onquit () 
local name = getPlayerName ( source ) 
if hitBlip and isElement( hitBlip ) then 
destroyElement ( hitBlip ) 
outputChatBox ( name .. " has quit hit", root, 255,235,0 ) 
  end 
  end 
addEvent ( "onQuit", true ) 
addEventHandler ( "onQuit", getRootElement(), onquit ) 

this is client side

function onQuitGame () 
    triggerServerEvent ( "onQuit", localPlayer ) 
end 
addEventHandler( "onClientPlayerQuit", getRootElement(), onQuitGame ) 

please anyone help me.

Link to comment

Try this

blips = { } 
  
addEventHandler ( "onPlayerJoin", root, 
    function () 
        blips [ source ] = createBlipAttachedTo ( source, 26 ) 
    end 
) 
  
addEventHandler ( "onPlayerQuit", root, 
    function () 
        if ( blips and isElement ( blips [ source ] ) ) then 
            destroyElement ( blips [ source ] ) 
        end 
    end 
) 

Edited by Guest
Link to comment

still the same

addEventHandler ( "onPlayerQuit", root, 
    function () 
 local name = getPlayerName ( source ) 
        if hitBlip and isElement ( hitBlip ) then 
            destroyElement ( hitBlip ) 
   outputChatBox ( name .. " has quit hit", root, 255,235,0 ) 
        end 
    end) 
  

i dont want to make it with tables, i want to make it with setElementData

Link to comment

If you create the blip server side, then this code should work and this is server side only ( you don't need client side ) :

function onquit () 
    local name = getPlayerName ( source ) 
    local hitBlip = getElementData ( source, "hitBlip" ) 
    if hitBlip and isElement( hitBlip ) then 
        destroyElement ( hitBlip ) 
        outputChatBox ( name .. " has quit hit", root, 255,235,0 ) 
    end 
end 
  
addEventHandler ( "onPlayerQuit", getRootElement(), onquit ) 

If that doesn't work try to edit the part where you set element data with the userdata of the blip:

           local playername = getPlayerName ( thePlayer ) 
            local hitBlip = createBlipAttachedTo ( thePlayer, 26 ) 
            setElementData ( thePlayer, "hitBlip", tostring ( hitBlip ) ) 

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