Jump to content

[BUG]Roob script#2


DiGiTal

Recommended Posts

Once i do a Error key (need to do the right key to have the money) i have -1000$, Thanks

code = ""
maxAmount = 5000000
playPrice = 1000
timeOut = 5000
totalMoney = 0
prevAtt = { }

function startUp()
 for k,v in ipairs ( getElementsByType ( 'player' ) ) do
 if exports["SADZcommands"]:isPlayerInTeam(v, "Criminals") then
	safeTable = createObject (1829 ,2580.619140625, 2328.5845703125, 17.222208404541)
	createBlipAttachedTo ( safeTable, 38, 3, 0, 117 , 0 , 255, 0, 99999.0 )
	
	loadConfig()
	else 			exports.SADZcommands:sendMessage("You are not in Criminals Team!", 200, 255, 100, player ) 
	end
	
 end
 end
addEventHandler( "onResourceStart", getResourceRootElement( getThisResource() ), startUp)



function loadConfig()
	totalMoney = math.random(2500,100000)
	
	local xml = xmlLoadFile("jackpot.xml")
		
	if xml then
		for i,jackpot1 in ipairs(xmlNodeGetChildren(xml)) do
			local node = xmlFindChild(xml,"jackpot1",0)
			local success = xmlNodeSetValue(node,tostring(totalMoney))
						
			xmlSaveFile(xml)
			xmlUnloadFile(xml)
		end
	end
	createCode()
end

function createCode()
	numOne = math.random(0,9)
	numTwo = math.random(0,9)
	numThree = math.random(0,9)
	numFour = math.random(0,9)
	
	if openSafe then
		destroyElement ( openSafe )
	end
	
	closedSafe = createObject ( 2332, 2580.619140625, 2328.5845703125, 17.222208404541 )
		setObjectRotation ( closedSafe, 0, 0, 180 )
	Marker = createMarker (2580.611328125, 2330.4267578125, 16.822208404541, "cylinder", 1, 105,144,61, 170 )
	setElementData ( Marker, "Safe", "Crack" )
	
	code = tostring(numOne)..tostring(numTwo)..tostring(numThree)..tostring(numFour)
	outputDebugString("CODE: "..code)
	exports.SADZcommands:sendMessage( "*SAFE CRACKER* The safe has been filled with: $ "..tostring(totalMoney),0,200,0,getRootElement())
end

function dataRequest()
	previousAtt = table.concat(prevAtt, ",")
	triggerClientEvent ( source, "showStartWindow", getRootElement(), playPrice, totalMoney, previousAtt )
end
addEvent( "dataRequest", true )
addEventHandler( "dataRequest", getRootElement(), dataRequest )

function codeCheck(checkCode)
	takePlayPrice()

	if checkCode == code then
		exports.SADZcommands:sendMessage( "*SAFE CRACKER* You cracked the code! You earned: $"..tostring(totalMoney), 0, 200, 0, source)
		exports.SADZcommands:giveMoney(source, totalMoney)
		destroyElement( closedSafe )
		destroyElement( Marker )
		openSafe = createObject ( 1829, 2580.59375, 2329.0810546875, 17.822208404541 )
		setObjectRotation ( openSafe, 0, 0, 180 )
		setTimer( loadConfig, 300000, 1)
		exports.SADZcommands:sendMessage( "*SAFE CRACKER* The code of the safe has been cracked by: "..getPlayerName(source), 0, 200, 0, getRootElement())
		exports.SADZcommands:sendMessage( "*SAFE CRACKER* The safe will be refilled in 5 minutes", 0, 200, 0, getRootElement())
		
		triggerClientEvent ( "destroySafeGUI", getRootElement() )
		
		xml = xmlLoadFile("jackpot.xml")
		
		if xml then
			for i,jackpot1 in ipairs(xmlNodeGetChildren(xml)) do
				local randBoost = math.random(750,1500)
				
				local node = xmlFindChild(xml,"jackpot1",0)
				local ammount = xmlNodeGetValue(xmlFindChild(xml,"jackpot1",0))
					xmlNodeSetValue(node,tostring(0))
				
				xmlSaveFile(xml)
				xmlUnloadFile(xml)
			end
		end
	else
		if checkCode > code then
			exports.SADZcommands:sendMessage( "*SAFE CRACKER* LOWER!", 255, 255, 0, source)
			if #prevAtt == 10 then
				table.insert(prevAtt, 1 , checkCode)
				table.remove(prevAtt, 11)
			else
				table.insert(prevAtt, 1 , checkCode)
			end
		elseif checkCode < code then
			exports.SADZcommands:sendMessage( "*SAFE CRACKER* HIGHER!", 255, 255, 0, source)
			if #prevAtt == 10 then
				table.insert(prevAtt, 1 , checkCode)
				table.remove(prevAtt, 11)
			else
				table.insert(prevAtt, 1 , checkCode)
			end		
		end
		
		xml = xmlLoadFile("jackpot.xml")
		
		if xml then
			for i,jackpot1 in ipairs(xmlNodeGetChildren(xml)) do
				local randBoost = math.random(750,1500)
				
				local node = xmlFindChild(xml,"jackpot1",0)
				local ammount = xmlNodeGetValue(xmlFindChild(xml,"jackpot1",0))
					xmlNodeSetValue(node,tostring(ammount+randBoost))
				
				xmlSaveFile(xml)
				xmlUnloadFile(xml)
			end
		end
	end
end
addEvent( "codeCheck", true )
addEventHandler( "codeCheck", getRootElement(), codeCheck )

function takePlayPrice()
	exports.SADZcommands:takeMoney(source, playPrice)
	totalMoney = totalMoney + playPrice
	
	if totalMoney > maxAmount then
		totalMoney = maxAmount
	end
end
addEvent( "takePlayPrice", true )
addEventHandler( "takePlayPrice", getRootElement(), takePlayPrice )

 

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...