Jump to content

Map is adding to queue but doesnt fit [RACE]


Recommended Posts

I made userpanel, with shop... I made a code for userpanel, to buy a map for cash, but map is just adding to queue.. Like map doesnt fit.. 

Im an amateur on lua code, so please help me sb

-- Buy a next map // wolfeens
function buyMap(thePlayer,mapName,command)
	if not PVP[thePlayer] then
		local account = getPlayerAccount(thePlayer)
		if not (isGuestAccount(account)) then
			local playerCash = tonumber(getAccountData(account,"cash"))
			if not (mapName == "") then
				if playerCash >= mapCost then
					if command then
						mapName = getMapName(mapName)
					else
						mapName = tostring(mapName)
					end
					if not mapTimer[mapName] then
						table.insert(mapQueue,mapName)
						local freeMaps = tonumber(getAccountData(account,"freeMaps"))
						if freeMaps ~= 0 then
							addStat(account,"freeMaps",-1)
						else
							setAccountData(account,"cash",playerCash - mapCost)
						end
						addStat(account,"buyedMaps",1)
						scoreboardRefresh(thePlayer)
						mapTimer[mapName] = true
						setTimer(resetMapTimer,900000,1,mapName)
						if #mapQueue == 1 then
							triggerEvent("onUseranelWantSetMap",getRootElement(),mapQueue[1])
						end
						callClientFunction(thePlayer,"setFreeMapPurchase",getAccountData(account,"freeMaps"))
						unlockAchievement(thePlayer,18)
						unlockAchievement(thePlayer)
						showServerMsg(getRootElement(),"Map queue",getPlayerName(thePlayer).." #ffffffbought and add "..mapName.." to map queue")
						callClientFunction(getRootElement(),"updateMapQueueList",mapQueue)
					else
						showServerMsg(thePlayer,"Buy nextmap","#FFFFFFYou can't set this map now, wait some time to set!")
					end
				else
					showServerMsg(thePlayer,"Buy nextmap","#FFFFFFYou don't have enough money to set a map!")
				end
			else
				showServerMsg(thePlayer,"Buy nextmap","#FFFFFFPlease select a map from the list first!")
			end
		end
	else
		showServerMsg(thePlayer,"Buy nextmap","#FFFFFFYou can't buy maps because you're playing a PVP match now!")
	end
end


 

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