DonOmar Posted June 24, 2016 Share Posted June 24, 2016 I wanna make a timer for using an armor pickup in this function : function buyArmor() if status == true then triggerServerEvent("CIFarmor.buyArmor", localPlayer, localPlayer) end end bindKey("n", "down", buyArmor) Link to comment
DonOmar Posted June 25, 2016 Author Share Posted June 25, 2016 Guys you will help me or no ? Link to comment
#RooTs Posted June 25, 2016 Share Posted June 25, 2016 you mean like this? setTimer (function() if status == true then triggerServerEvent("CIFarmor.buyArmor", localPlayer, localPlayer) end end, 5000, 0 ) Link to comment
Bean666 Posted June 25, 2016 Share Posted June 25, 2016 you mean like this? setTimer (function() if status == true then triggerServerEvent("CIFarmor.buyArmor", localPlayer, localPlayer) end end, 5000, 0 ) you are making the timer endless by putting 0. should be like this. 5000, 1 setTimer (function() if status == true then triggerServerEvent("CIFarmor.buyArmor", getLocalPlayer(), CIFarmor.buyArmor) end end, 5000, 1 ) Link to comment
DonOmar Posted June 25, 2016 Author Share Posted June 25, 2016 This is the Server Side function buyArmor(plr) setPedArmor(plr, 100) exports.CRPaccounts:TPM(plr, price, "buying amor") exports.CIThelp:dm(plr, "armor", "", 168, 164, 159, 255) end addEvent("CIFarmor.buyArmor", true) addEventHandler("CIFarmor.buyArmor", root, buyArmor) Link to comment
Bean666 Posted June 25, 2016 Share Posted June 25, 2016 its pretty much PLR isn't defined as a player, anyway are the exports in the meta.xml? try using source instead of PLR, leave the parentheses empty () Link to comment
DonOmar Posted June 25, 2016 Author Share Posted June 25, 2016 its pretty much PLR isn't defined as a player, anyway are the exports in the meta.xml?try using source instead of PLR, leave the parentheses empty () this is the whole script (client) status = false function onDie() exports.CIThelp:modTextBar("armor", "") end addEventHandler("onClientPlayerWasted", localPlayer, onDie) function status(status2) if status2 == true then status = true end if status2 == false then status = false end end addEvent("CIFarmor.setStatus", true) addEventHandler("CIFarmor.setStatus", root, status) function buyArmor() if status == true then triggerServerEvent("CIFarmor.buyArmor", localPlayer, localPlayer) end end bindKey("n", "down", buyArmor) Server Side ------------------------------------------------------------------------------------ local armorPick = { {x = 2195.48, y = -1147.18, z = 1029.2, dim = 921, int = 15}, -- JFM 1 {x = 2190.62, y = -1179.36, z = 1029.2, dim = 921, int = 15}, -- JFM 2 {x = 2227.91, y = -1150.60, z = 1025.2, dim = 921, int = 15}, -- JFM 3 -- {x = 2854.01, y = 1325.200, z = 10.500, dim = 0, int = 0}, -- RxN Base {x = 1123.941, y = -2033.68, z = 69.01, dim = 0, int = 0}, -- Crim Villa {x = 571.485, y = -1512.88, z = 8.034, dim = 0, int = 0}, -- FBI base } function createArmorLocations() for index, val in pairs(armorPick) do armorp = createPickup(val.x, val.y, val.z + 0.5, 3, 1242, 50) armorMarker = createMarker(val.x, val.y, val.z + 0.5, "cylinder", 1, 255, 0, 0, 0) setElementDimension(armorp, val.dim) setElementDimension(armorMarker, val.dim) setElementInterior(armorp, val.int) setElementInterior(armorMarker, val.int) addEventHandler("onPickupHit", armorp, armorHit) addEventHandler("onMarkerLeave", armorMarker, armorLeave) addEventHandler("onMarkerHit", armorMarker, armorEnter) end end addEventHandler("onResourceStart", resourceRoot, createArmorLocations) function armorHit(element) cancelEvent() end function armorEnter(element) if (isElement(element) and getElementType(element) == "player") then if (isPedInVehicle(element)) then return end local playerArmor = getPedArmor(element) if playerArmor == 100 then return end if playerArmor <= 10 then price = 1000 elseif playerArmor <= 20 then price = 900 elseif playerArmor <= 30 then price = 800 elseif playerArmor <= 40 then price = 700 elseif playerArmor <= 50 then price = 600 elseif playerArmor <= 60 then price = 500 elseif playerArmor <= 70 then price = 400 elseif playerArmor <= 80 then price = 300 elseif playerArmor <= 90 then price = 200 elseif playerArmor <= 99 then price = 100 end exports.CIThelp:modTextBar(element, "armor", "Press 'n' to buy armor for $"..price, 168, 164, 159, 255) local status = true triggerClientEvent(element, "CIFarmor.setStatus", element, status) end end function armorLeave(plr) local status = false exports.CIThelp:modTextBar(plr, "armor", "", 168, 164, 159, 255) triggerClientEvent(plr, "CIFarmor.setStatus", plr, status) end function buyArmor(plr) setPedArmor(plr, 100) exports.CRPaccounts:TPM(plr, price, "buying amor") exports.CIThelp:dm(plr, "armor", "", 168, 164, 159, 255) end addEvent("CIFarmor.buyArmor", true) addEventHandler("CIFarmor.buyArmor", root, buyArmor) Link to comment
Bean666 Posted June 25, 2016 Share Posted June 25, 2016 do u just have CITscripts? explain me this: exports.CIThelp:modTextBar("armor", "") exports.CIThelp:modTextBar(element, "armor", "Press 'n' to buy armor for $"..price, 168, 164, 159, 255) i wont help u if u do and this is also like CIT armour system press N on Armour pickup locations. 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