Jump to content

how to fix this script


SuperVisor

Recommended Posts

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
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
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
  • 4 weeks later...
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
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
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 by Dimos7
Link to comment
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 by (SAUG)Tando
Link to comment
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
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
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 by (SAUG)Tando
Link to comment
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
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
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
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 by Dimos7
Link to comment
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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...