Hero192 Posted January 25, 2016 Share Posted January 25, 2016 still one more problem, It's when I tase someone and the time still running,Like shooting him twice time. The animation be doubled I mean the old timer + new timer and If another player tased again it keep adding the timer up like on each time the time keep adding up . So can you help me please local tazerTimers = {} addEventHandler("onPlayerDamage", getRootElement(), function (attacker, weapon, _, loss) if (isElement(attacker) and getElementType(attacker) == "player" and weapon and attacker ~= source) then if ( not getPlayerTeam(attacker) ) then return end if ( getPlayerWantedLevel(source) == 0 ) then return end if ( getPlayerWantedLevel(source) >= 1 ) then if (weapon and weapon == 23) then if isTimer(tazerTimers[source]) then killTimer(tazerTimers[source]) end if (getPlayerTeam(attacker) and lawTeam[getTeamName(getPlayerTeam(attacker))]) then toggleAllControls ( source, false ) setPedAnimation(source, "ped", "KO_shot_stom") triggerClientEvent(root,"onStartTaserSound",root,attacker) tazerTimers[source] = setTimer(function(player) if ( isElement ( player ) ) then if isTimer(tazerTimers[player]) then killTimer(tazerTimers[player]) end setPedAnimation(player) toggleAllControls(player,true) end end,2500,1,source) triggerClientEvent (root, "destroySound", root) end end end end end) Link to comment
Army@1 Posted January 25, 2016 Share Posted January 25, 2016 Probably because you were not removing the previous table's timer's key. local tazerTimers = {} addEventHandler("onPlayerDamage", getRootElement(), function (attacker, weapon, _, loss) if (isElement(attacker) and getElementType(attacker) == "player" and weapon and attacker ~= source) then if ( not getPlayerTeam(attacker) ) then return end if ( getPlayerWantedLevel(source) == 0 ) then return end if ( getPlayerWantedLevel(source) >= 1 ) then if (weapon and weapon == 23) then if isTimer(tazerTimers[source]) then killTimer(tazerTimers[source]) end if (getPlayerTeam(attacker) and lawTeam[getTeamName(getPlayerTeam(attacker))]) then toggleAllControls ( source, false ) setPedAnimation(source, "ped", "KO_shot_stom") triggerClientEvent(root,"onStartTaserSound",root,attacker) tazerTimers[source] = setTimer(function(player) if ( isElement ( player ) ) then if isTimer(tazerTimers[player]) then killTimer(tazerTimers[player]) tazerTimers[player] = nil end setPedAnimation(player) toggleAllControls(player,true) end end,2500,1,source) triggerClientEvent (root, "destroySound", root) end end end end end) Link to comment
Tekken Posted January 25, 2016 Share Posted January 25, 2016 Wait make me understand you want the animation to be doubled, Or...? Link to comment
Hero192 Posted January 25, 2016 Author Share Posted January 25, 2016 Arm@y's code doesn't works, It keep doing the same! Wait make me understand you want the animation to be doubled, Or...? No,I want when cop shoot the wanted player the old timer must be removed and make new timer again. Because when cop shoot wanted twice time , the animation plays for double timer, and I won't that. for example: 3000Ms + 3000Ms: on each twice shoot So it's kinda annoying, Link to comment
Army@1 Posted January 25, 2016 Share Posted January 25, 2016 My bad, I didn't knew there were actually two timers... local tazerTimers = {} addEventHandler("onPlayerDamage", getRootElement(), function (attacker, weapon, _, loss) if (isElement(attacker) and getElementType(attacker) == "player" and weapon and attacker ~= source) then if ( not getPlayerTeam(attacker) ) then return end if ( getPlayerWantedLevel(source) == 0 ) then return end if ( getPlayerWantedLevel(source) >= 1 ) then if (weapon and weapon == 23) then if isTimer(tazerTimers[source]) then killTimer(tazerTimers[source]) tazerTimers[source] = nil end if (getPlayerTeam(attacker) and lawTeam[getTeamName(getPlayerTeam(attacker))]) then toggleAllControls ( source, false ) setPedAnimation(source, "ped", "KO_shot_stom") triggerClientEvent(root,"onStartTaserSound",root,attacker) tazerTimers[source] = setTimer(function(player) if ( isElement ( player ) ) then if isTimer(tazerTimers[player]) then killTimer(tazerTimers[player]) tazerTimers[player] = nil end setPedAnimation(player) toggleAllControls(player,true) end end,2500,1,source) triggerClientEvent (root, "destroySound", root) end end end end end) Link to comment
Hero192 Posted January 25, 2016 Author Share Posted January 25, 2016 Still the same problem Help me please Link to comment
Tekken Posted January 26, 2016 Share Posted January 26, 2016 Not sure but this may work: local tazerTimers = {}; addEventHandler("onPlayerDamage", getRootElement(), function (attacker, weapon, _, loss) if (isElement(attacker) and getElementType(attacker) == "player" and weapon and attacker ~= source) then if (not getPlayerTeam(attacker)) then return; end if (getPlayerWantedLevel(source) >= 1) then if (weapon == 23) then if (getPlayerTeam(attacker) and lawTeam[getTeamName(getPlayerTeam(attacker))]) then toggleAllControls(source, false); setPedAnimation(source, "ped", "KO_shot_stom"); triggerClientEvent(root, "onStartTaserSound", root, attacker); tazerTimers[source] = setTimer(teaser, 2500, 1, source); triggerClientEvent(root, "destroySound", root); end end end end end); function teaser(player) if isElement(player) then if isTimer(tazerTimers[player]) then local left = getTimerDetails(tazerTimers[player]); killTimer(tazerTimers[player]); tazerTimers[player] = setTimer(teaser, left+2500, 1, player); return; end tazerTimers[player] = nil; setPedAnimation(player); toggleAllControls(player, true); end end 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