Jump to content

Help With Tazer


xXMADEXx

Recommended Posts

Hey guys, i am using the community tazer. It isnt working well tho.

I don't want the eventHandler to be "onClientPlayerTarget", i want to to toggle when the player gets shot.

Any Help?

-- S

local time = 1 
function Praliz() 
    setElementFrozen ( source, true ) 
    setPedAnimation( source, "ped", "KO_shot_stom")  
    setTimer(setElementFrozen, time*3000, 1, source, false) 
    setTimer(setPedAnimation, time*3000, 1, source) 
end 
addEvent( "shot", true ) 
addEventHandler( "shot", getRootElement(),Praliz) 
  

-- C

function targetingActivated ( target ) 
    local name = getTeamName(getPlayerTeam(source)) 
    local nick=getPlayerName(source) 
    if ( name == "Police" ) or ( name == "Swat" ) or ( name == "FBI" ) or ( name == "Military" ) then 
        if ( target ) then 
        local weapon = getPedWeapon ( source ) 
            if weapon == 23 then 
                if getElementType(target) == "player" then 
                    triggerServerEvent ( "shot", target)  
                    outputChatBox("You have tazed ".. target, source, 255, 0, 0 ) 
                end 
            end 
        end 
    end 
end 
addEventHandler ( "", getRootElement(), targetingActivated )  

Link to comment

--c

function targetingActivated ( target ) 
    local name = getTeamName(getPlayerTeam(source)) 
    local nick=getPlayerName(source) 
    if ( name == "Police" ) or ( name == "Swat" ) or ( name == "FBI" ) or ( name == "Military" ) then 
        if ( target ) then 
        local weapon = getPedWeapon ( source ) 
            if weapon == 23 then 
                if getElementType(target) == "player" then 
                    triggerServerEvent ( "shot", target)  
                    outputChatBox("You have tazed ".. target, source, 255, 0, 0 ) 
                end 
            end 
        end 
    end 
end 
addEventHandler ( "onClientPlayerWeaponFire", getRootElement(), targetingActivated )  

-- S

local time = 1 
function Praliz() 
    setElementFrozen ( source, true ) 
    setPedAnimation( source, "ped", "KO_shot_stom")  
    setTimer(setElementFrozen, time*3000, 1, source, false) 
    setTimer(setPedAnimation, time*3000, 1, source) 
end 
addEvent( "shot", true ) 
addEventHandler( "shot", getRootElement(),Praliz) 
  

Link to comment

I looked at onClientPlayerWeaponFire a little more, and now my client side looks like this:

function targetingActivated ( target ) 
    local name = getTeamName(getPlayerTeam(source)) 
    local nick=getPlayerName(source) 
    if ( name == "Police" ) or ( name == "Swat" ) or ( name == "FBI" ) or ( name == "Military" ) then 
        if ( target ) then 
        local weapon = getPedWeapon ( source ) 
            if weapon == 23 and getElementType(target)=="player" then 
                triggerServerEvent ( "shot", target)  
            end 
        end 
    end 
end 
addEventHandler ( "onClientPlayerWeaponFire", getRootElement(), targetingActivated )  

Link to comment

-- Client Side --

local eTeams = { 
    ["Police"] = true, 
    ["Swat"] = true, 
    ["FBI"] = true, 
    ["Military"] = true 
} 
  
addEventHandler("onClientPlayerWeaponFire", root, 
function(weapon, _, _, _, _, _, hitElement) 
    if (hitElement) and (getElementType(hitElement) == "player") and (weapon == 23) then 
        local Team = getPlayerTeam(source) 
        local TeamName = Team and getTeamName(Team) or "" 
        if (eTeams[TeamName]) then 
            outputChatBox("You have tazed "..getPlayerName(hitElement), 255, 0, 0) 
            triggerServerEvent("onShot", localPlayer, hitElement) 
        end 
    end 
end) 

-- Server Side --

local time = 1 
  
addEvent("onShot", true) 
addEventHandler("onShot", root, 
function(hitElement) 
    setElementFrozen(hitElement, true) 
    setPedAnimation(hitElement, "ped", "KO_shot_stom")  
    setTimer(setElementFrozen, time*3000, 1, hitElement, false) 
    setTimer(setPedAnimation, time*3000, 1, hitElement) 
end) 

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