Jump to content

Help with ATM Robbing script


Recommended Posts

Hi guys can you please ,please,please  help me with this script , i have problem triggering the server side Event from a gui button  as Below , the client side works just fine but the server side doesnt work it should change the Range of the  random number according to the chosen difficulty :

Client Side :

function MKH_OPENHACK (localPlayer)

	if (source == GUIEditor.button[1]) then                                 ----------the Button open the Hack panel
		guiSetVisible(GUIEditor.window[1], false)
		guiSetVisible(ATM.window[1], true)
		output ("Hacking started..." )    
		LabelHackTimer = guiCreateLabel ( 0.61,0.61, 0.68, 0.48, "", true, ATM.window[1] ) 
		guiLabelSetColor(LabelHackTimer,255,0,0)
		guiSetFont(LabelHackTimer, "sa-header")
		guiSetAlpha ( LabelHackTimer, 1 )
		local Difficulty = guiComboBoxGetItemText(GUIEditor.combobox[1], guiComboBoxGetSelected(GUIEditor.combobox[1]))--- combobox with 3 Difficulties
		if Difficulty and Difficulty ~= "" then
			
			triggerServerEvent("onHacking",localPlayer,Difficulty)  	    ----- probably the mistake here 
			
      												
      ------------------------ all Below working just fine
			if Difficulty == "Easy" then                     -------------easy difficulty (the Difference is in time )
		HackingStart = setTimer(function()
			output ( "Time Out" )
			destroyElement(LabelHackTimer) 
			guiSetVisible(ATM.window[1], false)
			showCursor(false)
				end,30000,1)       
			elseif   Difficulty == "Medium" then   	        --------------Medium
				HackingStart = setTimer(function()
					output ( "Time Out" )
					destroyElement(LabelHackTimer)		 
					guiSetVisible(ATM.window[1], false)
					showCursor(false)
						end,120000,1) 					
			elseif   Difficulty == "Hard" then  						 ----- ------------Hard
						HackingStart = setTimer(function()	
							output ( "Time Out" )
							destroyElement(LabelHackTimer)	 
							guiSetVisible(ATM.window[1], false)
							showCursor(false)
								end,300000,1)       
						
				end			
			end					
		end
	end
addEventHandler("onClientGUIClick", root, MKH_OPENHACK)		

Server Side :

 


function HackingRange(source, Difficulty)
if source then 
	if Difficulty == "Easy" then
	local randomNumber = math.random(1, 1000)              -----------------Range should change in each Difficulty + chat (both not working)
	executeSQLQuery("DROP TABLE ATMRobbery" )
	executeSQLQuery("CREATE TABLE IF NOT EXISTS ATMRobbery (ATM TEXT, theNumber INT)")
	executeSQLQuery( "INSERT INTO ATMRobbery(ATM, theNumber) VALUES(?,?)", "ATMs", randomNumber)
	outputDebugString ("ATM Robbery: SQL Database has been created!")
	outputDebugString ("ATM Robbery: The Number is "..randomNumber)
	outputChatBox("Difficulty has been set to Easy you've got 30 Sec ",source, 0, 255, 0)
	ATM_ROBBERY = true
	elseif Difficulty == "Medium" then
		local randomNumber = math.random(1, 1000000)
		executeSQLQuery("DROP TABLE ATMRobbery" )
		executeSQLQuery("CREATE TABLE IF NOT EXISTS ATMRobbery (ATM TEXT, theNumber INT)")
		executeSQLQuery( "INSERT INTO ATMRobbery(ATM, theNumber) VALUES(?,?)", "ATMs", randomNumber)
		outputDebugString ("ATM Robbery: SQL Database has been created!")
		outputDebugString ("ATM Robbery: The Number is "..randomNumber)
		outputChatBox("Difficulty has been set to Medium you've got 2 Minutes",source, 0, 255, 0)
		ATM_ROBBERY = true
	elseif Difficulty == "Hard" then
		local randomNumber = math.random(1, 1000000000)
		executeSQLQuery("DROP TABLE ATMRobbery" )
		executeSQLQuery("CREATE TABLE IF NOT EXISTS ATMRobbery (ATM TEXT, theNumber INT)")
		executeSQLQuery( "INSERT INTO ATMRobbery(ATM, theNumber) VALUES(?,?)", "ATMs", randomNumber)
		outputDebugString ("ATM Robbery: SQL Database has been created!")
		outputDebugString ("ATM Robbery: The Number is "..randomNumber)
		outputChatBox("Difficulty has been set to Medium you've got 5 Minutes",source, 0, 255, 0)
		ATM_ROBBERY = true

	end
end
end
addEvent("onHacking",true)
addEventHandler("onHacking",resourceRoot,HackingRange)

 

Edited by DarkBeautyDZ
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...