Furious^ONE! Posted July 28, 2019 Share Posted July 28, 2019 hello, The setTimer in this script don't work, when someone use 'First Aid Kit', he can spam click in inventory for put x2 x3 x4 first aid in -1sec, I don't know why, and how this function don't work.. function onPlayerUseMedicObject(itemName) local playersource = source setPedAnimation (playersource,"BOMBER","BOM_Plant",2,true,false,nil,false) setTimer( function () if itemName == "Bandage" then setElementData(playersource,"bleeding",0) setElementData(playersource,itemName,getElementData(playersource,itemName)-1) elseif itemName == "First Aid Kit" then setElementData(playersource,"blood",getElementData(playersource,"blood")+math.random(3000,9000)) setElementData(playersource,"bleeding",0) setElementData(playersource,itemName,getElementData(playersource,itemName)-1) elseif itemName == "Warmer" then setElementData(playersource,"cold",false) setElementData(playersource,"temperature",37) setElementData(playersource,itemName,getElementData(playersource,itemName)-1) elseif itemName == "Painkiller" then setElementData(playersource,"pain",false) setElementData(playersource,itemName,getElementData(playersource,itemName)-1) elseif itemName == "Morphine" then setElementData(playersource,"brokenbone",false) setElementData(playersource,itemName,getElementData(playersource,itemName)-1) elseif itemName == "Antibiotics" then setElementData(playersource,"bleeding",0) setElementData(playersource,"infection",false) setElementData(playersource,itemName,getElementData(playersource,itemName)-1) end end,2500,1) triggerClientEvent(playersource,"refreshInventoryManual",playersource) end addEvent("onPlayerUseMedicObject",true) addEventHandler("onPlayerUseMedicObject",getRootElement(),onPlayerUseMedicObject) function onPlayerGiveMedicObject(itemName,player) local playersource = source setPedAnimation (playersource,"BOMBER","BOM_Plant",-1,false,false,nil,false) setTimer( function () if itemName == "bandage" then setElementData(player,"bleeding",0) setElementData(playersource,"Bandage",getElementData(playersource,"Bandage")-1) elseif itemName == "giveblood" then setElementData (player,"blood",12000) setElementData(playersource,"Blood Package",getElementData(playersource,"Blood Package")-1) elseif itemName == "infection_int" then setElementData(player,"infection",false) setElementData(playersource,"Antibiotics",getElementData(playersource,"Antibiotics")-1) elseif itemName == "brokenbone_int" then setElementData(player,"brokenbone",false) setElementData(playersource,"Morphine",getElementData(playersource,"Morphine")-1) elseif itemName == "pain_int" then setElementData(player,"pain",false) setElementData(playersource,"Painkiller",getElementData(playersource,"Painkiller")-1) end end,1500,1) end addEvent("onPlayerGiveMedicObject",true) addEventHandler("onPlayerGiveMedicObject",getRootElement(),onPlayerGiveMedicObject) Link to comment
Seba500PLK Posted August 6, 2019 Share Posted August 6, 2019 local useItem = {}; function onPlayerUseMedicObject(itemName) local playersource = source if ( not useItem[playersource] ) then useItem[playersource] = true; setPedAnimation (playersource,"BOMBER","BOM_Plant",2,true,false,nil,false) setTimer( function () if itemName == "Bandage" then setElementData(playersource,"bleeding",0) setElementData(playersource,itemName,getElementData(playersource,itemName)-1) elseif itemName == "First Aid Kit" then setElementData(playersource,"blood",getElementData(playersource,"blood")+math.random(3000,9000)) setElementData(playersource,"bleeding",0) setElementData(playersource,itemName,getElementData(playersource,itemName)-1) elseif itemName == "Warmer" then setElementData(playersource,"cold",false) setElementData(playersource,"temperature",37) setElementData(playersource,itemName,getElementData(playersource,itemName)-1) elseif itemName == "Painkiller" then setElementData(playersource,"pain",false) setElementData(playersource,itemName,getElementData(playersource,itemName)-1) elseif itemName == "Morphine" then setElementData(playersource,"brokenbone",false) setElementData(playersource,itemName,getElementData(playersource,itemName)-1) elseif itemName == "Antibiotics" then setElementData(playersource,"bleeding",0) setElementData(playersource,"infection",false) setElementData(playersource,itemName,getElementData(playersource,itemName)-1) end useItem[playersource] = nil; end,2500,1) triggerClientEvent(playersource,"refreshInventoryManual",playersource) end end addEvent("onPlayerUseMedicObject",true) addEventHandler("onPlayerUseMedicObject",getRootElement(),onPlayerUseMedicObject) 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