xXMADEXx Posted December 27, 2012 Posted December 27, 2012 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 ) The Ultimate Lua Tutorial! | MTA PHP SDK
TAPL Posted December 27, 2012 Posted December 27, 2012 You can do it with onClientPlayerWeaponFire or onPlayerDamage or onClientPlayerDamage
xXMADEXx Posted December 28, 2012 Author Posted December 28, 2012 i used onPlayerDamage, but nothing happend to the person who got shot. Any suggestions? The Ultimate Lua Tutorial! | MTA PHP SDK
Castillo Posted December 28, 2012 Posted December 28, 2012 Use: onClientPlayerWeaponFire San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
TAPL Posted December 28, 2012 Posted December 28, 2012 i used onPlayerDamage, but nothing happend to the person who got shot. Any suggestions? Post your code.
xXMADEXx Posted December 28, 2012 Author Posted December 28, 2012 --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) The Ultimate Lua Tutorial! | MTA PHP SDK
Castillo Posted December 28, 2012 Posted December 28, 2012 Go back to the wiki and check the arguments of onClientPlayerWeaponFire, because the first argument is the weapon used. San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
xXMADEXx Posted December 28, 2012 Author Posted December 28, 2012 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 ) The Ultimate Lua Tutorial! | MTA PHP SDK
TAPL Posted December 28, 2012 Posted December 28, 2012 -- 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)
xXMADEXx Posted December 28, 2012 Author Posted December 28, 2012 Thank you The Ultimate Lua Tutorial! | MTA PHP SDK
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