boro Posted January 18, 2013 Share Posted January 18, 2013 Hi all i make script, when zombie damage player then set health go slow down, but it don't work please help setTimer(function() if ( attacker and attacker ~= source and getElementType ( attacker ) == "ped" ) then setElementHealth(source, getElementHealth(source)-1) end end, 200, 0) addEventHandler("onPlayerDamage", getRootElement(), function() end) Link to comment
csiguusz Posted January 18, 2013 Share Posted January 18, 2013 Your code is absolutely wrong. Something like this should work: addEventHandler("onPlayerDamage", getRootElement(), function(attacker) if ( attacker and attacker ~= source and getElementType ( attacker ) == "ped" ) then setTimer( function( player ) setElementHealth( player, getElementHealth( player ) - 1 ) end, 200, 20, source ) end end) Link to comment
Moderators IIYAMA Posted January 18, 2013 Moderators Share Posted January 18, 2013 Try both pls: local myVictimData = {} local timerRunning = false --local player = source reduce ppppiiieeppp bugs.... function victim_def(attacker) if attacker and attacker ~= source and getElementType ( attacker ) == "ped" ) then local player = source myVictimData[player]={} timerRunning = true if not damagetimer then setTimer( damagetimer, 200, 0) end end end addEventHandler("onPlayerDamage", getRootElement(), victim_def) function damagetimer () if timerRunning == false then killTimer (damagetimer) return end local activetimer = 0 for k,player in ipairs(myVictimData) do activetimer = activetimer +1 local health == getElementHealth(player) if health > 0 then setElementHealth(player, health-1) else killPed(player) end end if activetimer == 0 then timerRunning = false end end function resourceStart () setTimer( damagetimer, 200, 0) end addEventHandler ( "onResourceStart", resourceRoot, resourceStart ) function on_Player_Quit() -- remove him from the table when he leaves local player = source myVictimData[player] = nil end addEventHandler ( "onPlayerQuit", getRootElement(),on_Player_Quit) function on_Player_Wasted () -- remove him from the table when he get killed local player = source; myVictimData[player] = nil end addEventHandler ( "onPlayerWasted", getRootElement(),on_Player_Wasted) Link to comment
boro Posted January 18, 2013 Author Share Posted January 18, 2013 [2013-01-01 22:08:10] SCRIPT ERROR: kill\server.lua:6: 'then' expected near ')' [2013-01-01 22:08:10] WARNING: Loading script failed: kill\server.lua:6: 'then' expected near ')' Link to comment
Sparrow Posted January 18, 2013 Share Posted January 18, 2013 local myVictimData = {} local timerRunning = false --local player = source reduce ppppiiieeppp bugs.... function victim_def(attacker) if attacker and attacker ~= source and getElementType ( attacker ) == "ped" then local player = source myVictimData[player]={} timerRunning = true if not damagetimer then setTimer( damagetimer, 200, 0) end end end addEventHandler("onPlayerDamage", getRootElement(), victim_def) function damagetimer () if timerRunning == false then killTimer (damagetimer) return end local activetimer = 0 for k,player in ipairs(myVictimData) do activetimer = activetimer +1 local health == getElementHealth(player) if health > 0 then setElementHealth(player, health-1) else killPed(player) end end if activetimer == 0 then timerRunning = false end end function resourceStart () setTimer( damagetimer, 200, 0) end addEventHandler ( "onResourceStart", resourceRoot, resourceStart ) function on_Player_Quit() -- remove him from the table when he leaves local player = source myVictimData[player] = nil end addEventHandler ( "onPlayerQuit", getRootElement(),on_Player_Quit) function on_Player_Wasted () -- remove him from the table when he get killed local player = source; myVictimData[player] = nil end addEventHandler ( "onPlayerWasted", getRootElement(),on_Player_Wasted) Link to comment
boro Posted January 18, 2013 Author Share Posted January 18, 2013 lol now this error [2013-01-01 22:19:46] SCRIPT ERROR: kill\server.lua:25: unexpected symbol near '==' [2013-01-01 22:19:46] WARNING: Loading script failed: kill\server.lua:25: unexpected symbol near '==' Link to comment
Castillo Posted January 18, 2013 Share Posted January 18, 2013 local health == getElementHealth(player) Remove one of the "=". Link to comment
boro Posted January 18, 2013 Author Share Posted January 18, 2013 hm now this [2013-01-01 22:23:55] WARNING: kill\server.lua:19: Bad argument @ 'killTimer' [Expected lua-timer at argument 1, got function] [2013-01-01 22:23:55] WARNING: kill\server.lua:19: Bad argument @ 'killTimer' [Expected lua-timer at argument 1, got function] [2013-01-01 22:23:56] WARNING: kill\server.lua:19: Bad argument @ 'killTimer' [Expected lua-timer at argument 1, got function] [2013-01-01 22:23:62] WARNING: kill\server.lua:19: Bad argument @ 'killTimer' [Expected lua-timer at argument 1, got function] [2013-01-01 22:23:65] WARNING: kill\server.lua:19: Bad argument @ 'killTimer' [Expected lua-timer at argument 1, got function] [2013-01-01 22:23:67] WARNING: kill\server.lua:19: Bad argument @ 'killTimer' [Expected lua-timer at argument 1, got function] [2013-01-01 22:23:69] WARNING: kill\server.lua:19: Bad argument @ 'killTimer' [Expected lua-timer at argument 1, got function] [2013-01-01 22:23:71] WARNING: kill\server.lua:19: Bad argument @ 'killTimer' [Expected lua-timer at argument 1, got function] [2013-01-01 22:23:74] WARNING: kill\server.lua:19: Bad argument @ 'killTimer' [Expected lua-timer at argument 1, got function] [2013-01-01 22:23:76] WARNING: kill\server.lua:19: Bad argument @ 'killTimer' [Expected lua-timer at argument 1, got function] Link to comment
Sparrow Posted January 18, 2013 Share Posted January 18, 2013 try: if isTimer(damagetimer) then killTimer (damagetimer) end Link to comment
Sparrow Posted January 18, 2013 Share Posted January 18, 2013 (edited) try this one, maybe it'll work local myVictimData = {} local timerRunning = false --local player = source reduce ppppiiieeppp bugs.... function victim_def(attacker) if attacker and attacker ~= source and getElementType ( attacker ) == "ped" then local player = source myVictimData[player]={} timerRunning = true if not damagetimer then setTimer( damagetimer, 200, 0) end end end addEventHandler("onPlayerDamage", getRootElement(), victim_def) function damagetimer () if timerRunning == false then return end if isTimer(damageTimer) then killTimer (damagetimer) end local activetimer = 0 for k,player in ipairs(myVictimData) do activetimer = activetimer +1 local health = getElementHealth(player) if health > 0 then setElementHealth(player, health-1) else killPed(player) end end if activetimer == 0 then timerRunning = false end end function resourceStart () setTimer( damagetimer, 200, 0) end addEventHandler ( "onResourceStart", resourceRoot, resourceStart ) function on_Player_Quit() -- remove him from the table when he leaves local player = source myVictimData[player] = nil end addEventHandler ( "onPlayerQuit", getRootElement(),on_Player_Quit) function on_Player_Wasted () -- remove him from the table when he get killed local player = source; myVictimData[player] = nil end addEventHandler ( "onPlayerWasted", getRootElement(),on_Player_Wasted) Edited January 19, 2013 by Guest Link to comment
boro Posted January 18, 2013 Author Share Posted January 18, 2013 now not errors but don't work Link to comment
Moderators IIYAMA Posted January 18, 2013 Moderators Share Posted January 18, 2013 (edited) test it again. If it doesn't work, check with outputDebugString("") what went wrong when you don't have any erros. Edited January 18, 2013 by Guest Link to comment
Moderators IIYAMA Posted January 18, 2013 Moderators Share Posted January 18, 2013 (edited) local myVictimData = {} local timerRunning = false --local player = source reduce ppppiiieeppp bugs.... function victim_def(attacker) if attacker and attacker ~= source and getElementType ( attacker ) == "ped" then local player = source myVictimData[player]={} timerRunning = true if not isTimer(dmgtimer) then dmgtimer = setTimer( damagetimer, 200, 0) end end end addEventHandler("onPlayerDamage", getRootElement(), victim_def) function damagetimer () if timerRunning == false then if isTimer(dmgtimer) then killTimer (dmgtimer) end return end local activetimer = 0 for k,player in ipairs(myVictimData) do activetimer = activetimer +1 local health = getElementHealth(player) if health > 0 then setElementHealth(player, health-1) else killPed(player) end end if activetimer == 0 then timerRunning = false end end function resourceStart () dmgtimer = setTimer( damagetimer, 200, 0) end addEventHandler ( "onResourceStart", resourceRoot, resourceStart ) function on_Player_Quit() -- remove him from the table when he leaves local player = source myVictimData[player] = nil end addEventHandler ( "onPlayerQuit", getRootElement(),on_Player_Quit) function on_Player_Wasted () -- remove him from the table when he get killed local player = source; myVictimData[player] = nil end addEventHandler ( "onPlayerWasted", getRootElement(),on_Player_Wasted) Edited January 18, 2013 by Guest Link to comment
3NAD Posted January 18, 2013 Share Posted January 18, 2013 addEventHandler ( "onPlayerDamage", root, function ( attacker ) if attacker then if getElementType ( attacker ) == "player" and attacker ~= source then if isTimer ( theTimer ) then killTimer ( theTimer ) end local player = source theTimer = setTimer ( Damage, 1000, 0, player ) end end end ) function Damage ( player ) local health = getElementHealth ( player ) if health > 5 then setElementHealth ( player, health -1 ) else killPed ( player ) if isTimer ( theTimer ) then killTimer ( theTimer ) end end fadeCamera ( player, false, 1.0, 255, 0, 0 ) setTimer ( fadeCamera, 500, 1, player, true, 0.5 ) 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