SuperVisor Posted December 20, 2018 Share Posted December 20, 2018 addEventHandler("onPlayerTarget", getRootElement(), function(targetEl) if exports.bcho:isCriminal(source) then if(targetEl) then if(getElementType(targetEl) == "ped") then if(not getElementData(source, "rob")) then if(getElementData(targetEl, "robLoc") ~= false) then robloc = getElementData(targetEl, "robLoc") setElementData(source, "rob", robloc) setElementData(source, "Charges", tonumber(getElementData(source, "Charges"))+1000) triggerClientEvent(source, "StartRobTimer", getRootElement()) exports. Messages:sendClientMessage("Store Robbery: Don't get arrested/killed or you will fail the robbery",source, 255, 100, 0) end end end end end end) addEventHandler("onResourceStop", getResourceRootElement(getThisResource()), function() for k, v in ipairs(getElementsByType("player")) do setElementData(v, "rob", false) end end) How to make start rob when quit shop and can't join any interior untl finish rob ? Link to comment
Dimos7 Posted December 20, 2018 Share Posted December 20, 2018 getElementInterior 0 is world Link to comment
SuperVisor Posted December 20, 2018 Author Share Posted December 20, 2018 (edited) 14 minutes ago, Dimos7 said: getElementInterior 0 is world can u explan more ? like can't join and exports.Massges:Local("You Can't join Agian until Finish rob!",source, 255, 100, 0) Edited December 20, 2018 by SuperVisor Link to comment
mazarati21 Posted December 20, 2018 Share Posted December 20, 2018 You a space between exports and Messages. Link to comment
SuperVisor Posted December 20, 2018 Author Share Posted December 20, 2018 7 minutes ago, mazarati21 said: You a space between exports and Messages. ik i just say example for Link to comment
Dimos7 Posted December 20, 2018 Share Posted December 20, 2018 addEventHandler("onPlayerTarget", getRootElement(), function(targetEl) if exports.bcho:isCriminal(source) then if(targetEl) then if(getElementType(targetEl) == "ped") then if(not getElementData(source, "rob")) then if(getElementData(targetEl, "robLoc") ~= false) then robloc = getElementData(targetEl, "robLoc") setElementData(source, "rob", robloc) setElementData(source, "Charges", tonumber(getElementData(source, "Charges"))+1000) if getElementInterior(source) ==0 then triggerClientEvent(source, "StartRobTimer", getRootElement()) end exports.Messages:sendClientMessage("Store Robbery: Don't get arrested/killed or you will fail the robbery",source, 255, 100, 0) end end end end end end) addEventHandler("onResourceStop", getResourceRootElement(getThisResource()), function() for k, v in ipairs(getElementsByType("player")) do setElementData(v, "rob", false) end end) Try this Link to comment
SuperVisor Posted December 20, 2018 Author Share Posted December 20, 2018 12 minutes ago, Dimos7 said: addEventHandler("onPlayerTarget", getRootElement(), function(targetEl) if exports.bcho:isCriminal(source) then if(targetEl) then if(getElementType(targetEl) == "ped") then if(not getElementData(source, "rob")) then if(getElementData(targetEl, "robLoc") ~= false) then robloc = getElementData(targetEl, "robLoc") setElementData(source, "rob", robloc) setElementData(source, "Charges", tonumber(getElementData(source, "Charges"))+1000) if getElementInterior(source) ==0 then triggerClientEvent(source, "StartRobTimer", getRootElement()) end exports.Messages:sendClientMessage("Store Robbery: Don't get arrested/killed or you will fail the robbery",source, 255, 100, 0) end end end end end end) addEventHandler("onResourceStop", getResourceRootElement(getThisResource()), function() for k, v in ipairs(getElementsByType("player")) do setElementData(v, "rob", false) end end) Try this this server.lua ! and what u add will be able join interior when quit ? Link to comment
Tando Posted January 14, 2019 Share Posted January 14, 2019 On 20/12/2018 at 23:18, Dimos7 said: Yes it will addEventHandler("onPlayerTarget", getRootElement(), function(targetEl) if exports.becho:isCriminal(source) then if(targetEl) then if(getElementType(targetEl) == "ped") then if(not getElementData(source, "rob")) then if(getElementData(targetEl, "robLoc") ~= false) then robloc = getElementData(targetEl, "robLoc") setElementData(source, "rob", robloc) setElementData(source, "Charges", tonumber(getElementData(source, "Charges"))+1000) if getElementInterior(source) ==0 then triggerClientEvent(source, "StartRobTimer", getRootElement()) end exports.Messages:sendClientMessage("Store Robbery: Don't get arrested/killed or you will fail the robbery",source, 255, 100, 0) end end end end end end) addEventHandler("onResourceStop", getResourceRootElement(getThisResource()), function() for k, v in ipairs(getElementsByType("player")) do setElementData(v, "rob", false) end end) not working when player quit from interior it's not shown rob time or anything just giving msg Link to comment
Tando Posted January 17, 2019 Share Posted January 17, 2019 On 20/12/2018 at 23:18, Dimos7 said: Yes it will any help ? Link to comment
Dimos7 Posted January 17, 2019 Share Posted January 17, 2019 On 14/01/2019 at 16:47, (SAUG)Tando said: addEventHandler("onPlayerTarget", getRootElement(), function(targetEl) if exports.becho:isCriminal(source) then if(targetEl) then if(getElementType(targetEl) == "ped") then if(not getElementData(source, "rob")) then if(getElementData(targetEl, "robLoc") ~= false) then robloc = getElementData(targetEl, "robLoc") setElementData(source, "rob", robloc) setElementData(source, "Charges", tonumber(getElementData(source, "Charges"))+1000) if getElementInterior(source) ==0 then triggerClientEvent(source, "StartRobTimer", getRootElement()) end exports.Messages:sendClientMessage("Store Robbery: Don't get arrested/killed or you will fail the robbery",source, 255, 100, 0) end end end end end end) addEventHandler("onResourceStop", getResourceRootElement(getThisResource()), function() for k, v in ipairs(getElementsByType("player")) do setElementData(v, "rob", false) end end) not working when player quit from interior it's not shown rob time or anything just giving msg Any errors or warnings in debugscipt 3? Link to comment
Tando Posted January 22, 2019 Share Posted January 22, 2019 On 17/01/2019 at 21:26, Dimos7 said: Any errors or warnings in debugscipt 3? nope Link to comment
SuperVisor Posted January 22, 2019 Author Share Posted January 22, 2019 On 17/01/2019 at 21:26, Dimos7 said: Any errors or warnings in debugscipt 3? Not showing anything when i quit the shop No errors or warnings in debugscript Link to comment
Dimos7 Posted January 23, 2019 Share Posted January 23, 2019 (edited) addEventHandler("onPlayerTarget", getRootElement(), function(targetEl) if exports.bcho:isCriminal(source) then if(targetEl) then if(getElementType(targetEl) == "ped") then if(not getElementData(source, "rob")) then if(getElementData(targetEl, "robLoc") ~= false) then robloc = getElementData(targetEl, "robLoc") setElementData(source, "rob", robloc) setElementData(source, "Charges", tonumber(getElementData(source, "Charges"))+1000) exports["Messages"]:sendClientMessage("For start the robbery you need exit the store!", source, 255, 100, 0) if getElementInterior(source) == 0 then triggerClientEvent(source, "StartRobTimer", root) exports["Messages"]:sendClientMessage("Store Robberry: Don't get arrested/killed or you will fail the robberry", source, 255, 100, 0) end end end end end end end) addEventHandler("onResourceStop", getResourceRootElement(getThisResource()), function() for k, v in ipairs(getElementsByType("player")) do setElementData(v, "rob", false) end end) Try this Edited January 23, 2019 by Dimos7 Link to comment
Tando Posted January 23, 2019 Share Posted January 23, 2019 (edited) 8 hours ago, Dimos7 said: addEventHandler("onPlayerTarget", getRootElement(), function(targetEl) if exports.bcho:isCriminal(source) then if(targetEl) then if(getElementType(targetEl) == "ped") then if(not getElementData(source, "rob")) then if(getElementData(targetEl, "robLoc") ~= false) then robloc = getElementData(targetEl, "robLoc") setElementData(source, "rob", robloc) setElementData(source, "Charges", tonumber(getElementData(source, "Charges"))+1000) exports["Messages"]:sendClientMessage("For start the robbery you need exit the store!", source, 255, 100, 0) if getElementInterior(source) == 0 then triggerClientEvent(source, "StartRobTimer", root) exports["Messages"]:sendClientMessage("Store Robberry: Don't get arrested/killed or you will fail the robberry", source, 255, 100, 0) end end end end end end end) addEventHandler("onResourceStop", getResourceRootElement(getThisResource()), function() for k, v in ipairs(getElementsByType("player")) do setElementData(v, "rob", false) end end) Try this same error : Crimes/crimes.lua:221: attempt to call global 'Timer' (a nil value) 6 minutes ago, (SAUG)Tando said: same error : Crimes/crimes.lua:221: attempt to call global 'Timer' (a nil value) Timer( function () for _, plr in ipairs(Element.getAllByType("player")) do if (getWantedPoints(plr) and not getElementData(plr,"ArrestedBy")and not getElementData(plr,"Jailed") == true ) then if (getWantedPoints(plr) > 0) then setWantedPoints(plr, getWantedPoints(plr) - 1) end end end end, 60 * 1000, 0 ) Edited January 23, 2019 by (SAUG)Tando Link to comment
SuperVisor Posted January 23, 2019 Author Share Posted January 23, 2019 16 hours ago, Dimos7 said: addEventHandler("onPlayerTarget", getRootElement(), function(targetEl) if exports.bcho:isCriminal(source) then if(targetEl) then if(getElementType(targetEl) == "ped") then if(not getElementData(source, "rob")) then if(getElementData(targetEl, "robLoc") ~= false) then robloc = getElementData(targetEl, "robLoc") setElementData(source, "rob", robloc) setElementData(source, "Charges", tonumber(getElementData(source, "Charges"))+1000) exports["Messages"]:sendClientMessage("For start the robbery you need exit the store!", source, 255, 100, 0) if getElementInterior(source) == 0 then triggerClientEvent(source, "StartRobTimer", root) exports["Messages"]:sendClientMessage("Store Robberry: Don't get arrested/killed or you will fail the robberry", source, 255, 100, 0) end end end end end end end) addEventHandler("onResourceStop", getResourceRootElement(getThisResource()), function() for k, v in ipairs(getElementsByType("player")) do setElementData(v, "rob", false) end end) Try this Not working just giving msg of exit shop then nothing happen Link to comment
Peti Posted January 24, 2019 Share Posted January 24, 2019 (edited) Quote error : Crimes/crimes.lua:221: attempt to call global 'Timer' (a nil value) I think it is a syntax error. Check if "Timer" is really called "Timer" and not "timer", "timeR" or whatever. Edited January 24, 2019 by Peti Link to comment
Dimos7 Posted January 24, 2019 Share Posted January 24, 2019 15 hours ago, (SAUG)Tando said: same error : Crimes/crimes.lua:221: attempt to call global 'Timer' (a nil value) Timer( function () for _, plr in ipairs(Element.getAllByType("player")) do if (getWantedPoints(plr) and not getElementData(plr,"ArrestedBy")and not getElementData(plr,"Jailed") == true ) then if (getWantedPoints(plr) > 0) then setWantedPoints(plr, getWantedPoints(plr) - 1) end end end end, 60 * 1000, 0 ) Show me the client side also server side Link to comment
Tando Posted January 24, 2019 Share Posted January 24, 2019 (edited) local x,y = guiGetScreenSize() local sx, sy = x/1280, y/768 addEvent("StartRobTimer",true) addEventHandler("StartRobTimer",root,function() addEventHandler( "onClientRender", root, showRobTime ) Time = 300 tick = getTickCount() end) function showRobTime( ) if getElementData( localPlayer, "ArrestedBy" ) or getElementData(localPlayer,"Jailed") == "yes" or isPedDead ( localPlayer ) then removeEventHandler("onClientRender",root,showRobTime) triggerServerEvent("giveRobMoney",localPlayer,1) return end if getTickCount( )-tick >= 1000 then Time = Time -1 tick = getTickCount() end dxDrawText(Time.." seconds left ", sx*69, sy*728, sx*187, sy*758, tocolor(254, 0, 0, 255), 1.80, "default-bold", "left", "bottom", false, false, false, false, false) if Time <= 0 then removeEventHandler("onClientRender",root,showRobTime) triggerServerEvent("giveRobMoney",localPlayer) end end server: function giveTheMoney(data) if(data == 1) then setElementData(source, "rob", false) exports.Messages:sendClientMessage("Store Robbery: The robbery ended because you were jailed/arrested!",source, 255, 100, 0) return end money = 3000 + math.random(100, 900) vip = getElementData(source, "viplevel") if vip == 2 then money = money+money*0.25 elseif vip == 3 then money = money+money*0.50 elseif vip == 4 then money = money+money*0.75 end givePlayerMoney(source, money) exports["Jobs"]:addJobMark(source, "Gangster", 1) setElementData(source, "rob", false) local textDisplay = textCreateDisplay() local textItem = textCreateTextItem("Robbery Successfull!\nYou received: "..convertNumber(money).."$", 0.5, 0.5, 2, 208, 29, 37, 200, 4, "center", "center" ) textDisplayAddText(textDisplay, textItem) textDisplayAddObserver(textDisplay, source) setTimer(textDestroyTextItem, 5000, 1, textItem) setTimer(textDestroyDisplay, 5000, 1, textDisplay) local xdata = exports.bcho:getPlayerAccountData(source,"robs") if xdata == nil or xdata == 0 or xdata == false then xdata = 0 end exports.bcho:setPlayerAccountData(source,"robs",xdata+1) local xdata = exports.bcho:getPlayerAccountData(source,"robs") if xdata == 1 then exports.ucp:givePlayerAch(source,2) elseif xdata == 50 then exports.ucp:givePlayerAch(source,3) elseif xdata == 1000 then exports.ucp:givePlayerAch(source,4) end end addEvent("giveRobMoney", true) addEventHandler("giveRobMoney", getRootElement(), giveTheMoney) function convertNumber ( number ) local formatted = number while true do formatted, k = string.gsub(formatted, "^(-?%d+)(%d%d%d)", '%1,%2') if ( k==0 ) then break end end return formatted end addEventHandler("onPlayerTarget", getRootElement(), function(targetEl) if exports.bcho:isCriminal(source) then if(targetEl) then if(getElementType(targetEl) == "ped") then if(not getElementData(source, "rob")) then if(getElementData(targetEl, "robLoc") ~= false) then robloc = getElementData(targetEl, "robLoc") setElementData(source, "rob", robloc) setElementData(source, "Charges", tonumber(getElementData(source, "Charges"))+1000) triggerClientEvent(source, "StartRobTimer", getRootElement()) exports.Messages:sendClientMessage("Store Robbery: Don't get arrested/killed or you will fail the robbery",source, 255, 100, 0) end end end end end end) addEventHandler("onResourceStop", getResourceRootElement(getThisResource()), function() for k, v in ipairs(getElementsByType("player")) do setElementData(v, "rob", false) end end) thats without editing client side and serverside Timer if error it's like evade system losing stars after mins local wantedPoints = {} Timer( function () for _, plr in ipairs(Element.getAllByType("player")) do if (getWantedPoints(plr) and not getElementData(plr,"ArrestedBy")and not getElementData(plr,"Jailed") == true ) then if (getWantedPoints(plr) > 0) then setWantedPoints(plr, getWantedPoints(plr) - 1) end end end end, 60 * 1000, 0 ) function getWantedPoints(plr) if (plr and not plr.account.guest) then local a = plr.account.name if (not wantedPoints[a]) then wantedPoints[a] = getElementData(plr, "Wanted") or 0 end return wantedPoints[a] end end Edited January 24, 2019 by (SAUG)Tando Link to comment
Peti Posted January 24, 2019 Share Posted January 24, 2019 Timer = setTimer( function () for _, plr in ipairs(Element.getAllByType("player")) do if (getWantedPoints(plr) and not getElementData(plr,"ArrestedBy")and not getElementData(plr,"Jailed") == true ) then if (getWantedPoints(plr) > 0) then setWantedPoints(plr, getWantedPoints(plr) - 1) end end end end, 60 * 1000, 0 ) Timer is undefined. Link to comment
Tando Posted January 24, 2019 Share Posted January 24, 2019 27 minutes ago, Peti said: Timer = setTimer( function () for _, plr in ipairs(Element.getAllByType("player")) do if (getWantedPoints(plr) and not getElementData(plr,"ArrestedBy")and not getElementData(plr,"Jailed") == true ) then if (getWantedPoints(plr) > 0) then setWantedPoints(plr, getWantedPoints(plr) - 1) end end end end, 60 * 1000, 0) Timer is undefined. okay what about when player exit shop rob start? Link to comment
SuperVisor Posted January 25, 2019 Author Share Posted January 25, 2019 On 24/01/2019 at 06:36, Dimos7 said: Show me the client side also server side On 24/01/2019 at 15:35, (SAUG)Tando said: local x,y = guiGetScreenSize()local sx, sy = x/1280, y/768addEvent("StartRobTimer",true)addEventHandler("StartRobTimer",root,function()addEventHandler( "onClientRender", root, showRobTime )Time = 300tick = getTickCount()end)function showRobTime( ) if getElementData( localPlayer, "ArrestedBy" ) or getElementData(localPlayer,"Jailed") == "yes" or isPedDead ( localPlayer ) then removeEventHandler("onClientRender",root,showRobTime) triggerServerEvent("giveRobMoney",localPlayer,1) return end if getTickCount( )-tick >= 1000 then Time = Time -1 tick = getTickCount() end dxDrawText(Time.." seconds left ", sx*69, sy*728, sx*187, sy*758, tocolor(254, 0, 0, 255), 1.80, "default-bold", "left", "bottom", false, false, false, false, false) if Time <= 0 then removeEventHandler("onClientRender",root,showRobTime) triggerServerEvent("giveRobMoney",localPlayer) endend server: function giveTheMoney(data) if(data == 1) then setElementData(source, "rob", false) exports.Messages:sendClientMessage("Store Robbery: The robbery ended because you were jailed/arrested!",source, 255, 100, 0) return end money = 3000 + math.random(100, 900) vip = getElementData(source, "viplevel") if vip == 2 then money = money+money*0.25 elseif vip == 3 then money = money+money*0.50 elseif vip == 4 then money = money+money*0.75 end givePlayerMoney(source, money) exports["Jobs"]:addJobMark(source, "Gangster", 1) setElementData(source, "rob", false) local textDisplay = textCreateDisplay() local textItem = textCreateTextItem("Robbery Successfull!\nYou received: "..convertNumber(money).."$", 0.5, 0.5, 2, 208, 29, 37, 200, 4, "center", "center" ) textDisplayAddText(textDisplay, textItem) textDisplayAddObserver(textDisplay, source) setTimer(textDestroyTextItem, 5000, 1, textItem) setTimer(textDestroyDisplay, 5000, 1, textDisplay) local xdata = exports.bcho:getPlayerAccountData(source,"robs") if xdata == nil or xdata == 0 or xdata == false then xdata = 0 end exports.bcho:setPlayerAccountData(source,"robs",xdata+1) local xdata = exports.bcho:getPlayerAccountData(source,"robs") if xdata == 1 then exports.ucp:givePlayerAch(source,2) elseif xdata == 50 then exports.ucp:givePlayerAch(source,3) elseif xdata == 1000 then exports.ucp:givePlayerAch(source,4) endendaddEvent("giveRobMoney", true)addEventHandler("giveRobMoney", getRootElement(), giveTheMoney)function convertNumber ( number ) local formatted = number while true do formatted, k = string.gsub(formatted, "^(-?%d+)(%d%d%d)", '%1,%2') if ( k==0 ) then break end end return formattedendaddEventHandler("onPlayerTarget", getRootElement(), function(targetEl) if exports.bcho:isCriminal(source) then if(targetEl) then if(getElementType(targetEl) == "ped") then if(not getElementData(source, "rob")) then if(getElementData(targetEl, "robLoc") ~= false) then robloc = getElementData(targetEl, "robLoc") setElementData(source, "rob", robloc) setElementData(source, "Charges", tonumber(getElementData(source, "Charges"))+1000) triggerClientEvent(source, "StartRobTimer", getRootElement()) exports.Messages:sendClientMessage("Store Robbery: Don't get arrested/killed or you will fail the robbery",source, 255, 100, 0) end end end end endend)addEventHandler("onResourceStop", getResourceRootElement(getThisResource()), function() for k, v in ipairs(getElementsByType("player")) do setElementData(v, "rob", false) end end) thats without editing client side and serverside Timer if error it's like evade system losing stars after mins local wantedPoints = {}Timer( function () for _, plr in ipairs(Element.getAllByType("player")) do if (getWantedPoints(plr) and not getElementData(plr,"ArrestedBy")and not getElementData(plr,"Jailed") == true ) then if (getWantedPoints(plr) > 0) then setWantedPoints(plr, getWantedPoints(plr) - 1) end end end end, 60 * 1000, 0)function getWantedPoints(plr) if (plr and not plr.account.guest) then local a = plr.account.name if (not wantedPoints[a]) then wantedPoints[a] = getElementData(plr, "Wanted") or 0 end return wantedPoints[a] endend Link to comment
Dimos7 Posted January 26, 2019 Share Posted January 26, 2019 (edited) local x,y = guiGetScreenSize()local sx, sy = x/1280, y/768 addEvent("StartRobTimer",true) addEventHandler("StartRobTimer",root,function() addEventHandler( "onClientRender", root, showRobTime ) Time = 300 tick = getTickCount() end) function showRobTime( ) if getElementData( localPlayer, "ArrestedBy" ) or getElementData(localPlayer,"Jailed") == "yes" or isPedDead ( localPlayer ) then removeEventHandler("onClientRender",root,showRobTime) triggerServerEvent("giveRobMoney",localPlayer,1) return end if getTickCount( )-tick >= 1000 then Time = Time -1 tick = getTickCount() end dxDrawText(Time.." seconds left ", sx*69, sy*728, sx*187, sy*758, tocolor(254, 0, 0, 255), 1.80, "default-bold", "left", "bottom", false, false, false, false, false) if Time <= 0 then removeEventHandler("onClientRender",root,showRobTime) triggerServerEvent("giveRobMoney",localPlayer) end end local wantedPoints = {}Timer= setTimer ( function () for _, plr in ipairs(Element.getAllByType("player")) do if (getWantedPoints(plr) and not getElementData(plr,"ArrestedBy")and not getElementData(plr,"Jailed") == true ) then if (getWantedPoints(plr) > 0) then setWantedPoints(plr, getWantedPoints(plr) - 1) end end end end, 60 * 1000, 0)function getWantedPoints(plr) if (plr and not plr.account.guest) then local a = plr.account.name if (not wantedPoints[a]) then wantedPoints[a] = getElementData(plr, "Wanted") or 0 end return wantedPoints[a] ndend function giveTheMoney(data) if(data == 1) then setElementData(source, "rob", false) exports.Messages:sendClientMessage("Store Robbery: The robbery ended because you were jailed/arrested!",source, 255, 100, 0) return end money = 3000 + math.random(100, 900) vip = getElementData(source, "viplevel") if vip == 2 then money = money+money*0.25 elseif vip == 3 then money = money+money*0.50 elseif vip == 4 then money = money+money*0.75 end givePlayerMoney(source, money) exports["Jobs"]:addJobMark(source, "Gangster", 1) setElementData(source, "rob", false) local textDisplay = textCreateDisplay() local textItem = textCreateTextItem("Robbery Successfull!You received: "..convertNumber(money).."$", 0.5, 0.5, 2, 208, 29, 37, 200, 4, "center", "center" ) textDisplayAddText(textDisplay, textItem) textDisplayAddObserver(textDisplay, source) setTimer(textDestroyTextItem, 5000, 1, textItem) setTimer(textDestroyDisplay, 5000, 1, textDisplay) local xdata = exports.bcho:getPlayerAccountData(source,"robs") if xdata == nil or xdata == 0 or xdata == false then xdata = 0 end exports.bcho:setPlayerAccountData(source,"robs",xdata+1) local xdata = exports.bcho:getPlayerAccountData(source,"robs") if xdata == 1 then exports.ucp:givePlayerAch(source,2) elseif xdata == 50 then exports.ucp:givePlayerAch(source,3) elseif xdata == 1000 then exports.ucp:givePlayerAch(source,4) end end addEvent("giveRobMoney", true) addEventHandler("giveRobMoney", root , giveTheMoney) function convertNumber ( number ) local formatted = number while true do formatted, k = string.gsub(formatted, "^(-?%d+)(%d%d%d)", '%1,%2') if ( k==0 ) then break end end return formatted end addEventHandler("onPlayerTarget", root , function(targetEl) if exports.bcho:isCriminal(source) then if(targetEl) then if(getElementType(targetEl) == "ped") then if(not getElementData(source, "rob")) then if(getElementData(targetEl, "robLoc") ~= false) then robloc = getElementData(targetEl, "robLoc") setElementData(source, "rob", robloc) setElementData(source, "Charges", tonumber(getElementData(source, "Charges"))+1000) if getElementInterior (source) == 0 then triggerClientEvent(source, "StartRobTimer", root) exports.Messages:sendClientMessage("Store Robbery: Don't get arrested/killed or you will fail the robbery",source, 255, 100, 0) end end end end end end end) addEventHandler("onResourceStop", resourceRoot , function() for k, v in ipairs(getElementsByType("player")) do setElementData(v, "rob", false) end end) Edited January 26, 2019 by Dimos7 Link to comment
Tando Posted January 27, 2019 Share Posted January 27, 2019 On 26/01/2019 at 10:48, Dimos7 said: local x,y = guiGetScreenSize()local sx, sy = x/1280, y/768addEvent("StartRobTimer",true)addEventHandler("StartRobTimer",root,function() addEventHandler( "onClientRender", root, showRobTime ) Time = 300 tick = getTickCount() end)function showRobTime( ) if getElementData( localPlayer, "ArrestedBy" ) or getElementData(localPlayer,"Jailed") == "yes" or isPedDead ( localPlayer ) then removeEventHandler("onClientRender",root,showRobTime) triggerServerEvent("giveRobMoney",localPlayer,1) return end if getTickCount( )-tick >= 1000 then Time = Time -1 tick = getTickCount() end dxDrawText(Time.." seconds left ", sx*69, sy*728, sx*187, sy*758, tocolor(254, 0, 0, 255), 1.80, "default-bold", "left", "bottom", false, false, false, false, false) if Time <= 0 then removeEventHandler("onClientRender",root,showRobTime) triggerServerEvent("giveRobMoney",localPlayer) endend local wantedPoints = {}Timer= setTimer ( function () for _, plr in ipairs(Element.getAllByType("player")) do if (getWantedPoints(plr) and not getElementData(plr,"ArrestedBy")and not getElementData(plr,"Jailed") == true ) then if (getWantedPoints(plr) > 0) then setWantedPoints(plr, getWantedPoints(plr) - 1) end end end end, 60 * 1000, 0)function getWantedPoints(plr) if (plr and not plr.account.guest) then local a = plr.account.name if (not wantedPoints[a]) then wantedPoints[a] = getElementData(plr, "Wanted") or 0 end return wantedPoints[a] ndend function giveTheMoney(data) if(data == 1) then setElementData(source, "rob", false) exports.Messages:sendClientMessage("Store Robbery: The robbery ended because you were jailed/arrested!",source, 255, 100, 0) return end money = 3000 + math.random(100, 900) vip = getElementData(source, "viplevel") if vip == 2 then money = money+money*0.25 elseif vip == 3 then money = money+money*0.50 elseif vip == 4 then money = money+money*0.75 end givePlayerMoney(source, money) exports["Jobs"]:addJobMark(source, "Gangster", 1) setElementData(source, "rob", false) local textDisplay = textCreateDisplay() local textItem = textCreateTextItem("Robbery Successfull!You received: "..convertNumber(money).."$", 0.5, 0.5, 2, 208, 29, 37, 200, 4, "center", "center" ) textDisplayAddText(textDisplay, textItem) textDisplayAddObserver(textDisplay, source) setTimer(textDestroyTextItem, 5000, 1, textItem) setTimer(textDestroyDisplay, 5000, 1, textDisplay) local xdata = exports.bcho:getPlayerAccountData(source,"robs") if xdata == nil or xdata == 0 or xdata == false then xdata = 0 end exports.bcho:setPlayerAccountData(source,"robs",xdata+1) local xdata = exports.bcho:getPlayerAccountData(source,"robs") if xdata == 1 then exports.ucp:givePlayerAch(source,2) elseif xdata == 50 then exports.ucp:givePlayerAch(source,3) elseif xdata == 1000 then exports.ucp:givePlayerAch(source,4) endendaddEvent("giveRobMoney", true)addEventHandler("giveRobMoney", root , giveTheMoney)function convertNumber ( number ) local formatted = number while true do formatted, k = string.gsub(formatted, "^(-?%d+)(%d%d%d)", '%1,%2') if ( k==0 ) then break end end return formatted end addEventHandler("onPlayerTarget", root , function(targetEl) if exports.bcho:isCriminal(source) then if(targetEl) then if(getElementType(targetEl) == "ped") then if(not getElementData(source, "rob")) then if(getElementData(targetEl, "robLoc") ~= false) then robloc = getElementData(targetEl, "robLoc") setElementData(source, "rob", robloc) setElementData(source, "Charges", tonumber(getElementData(source, "Charges"))+1000) if getElementInterior (source) == 0 then triggerClientEvent(source, "StartRobTimer", root) exports.Messages:sendClientMessage("Store Robbery: Don't get arrested/killed or you will fail the robbery",source, 255, 100, 0) end end end end end end end)addEventHandler("onResourceStop", resourceRoot , function() for k, v in ipairs(getElementsByType("player")) do setElementData(v, "rob", false) end end) still too 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