hi imake this code for buy map but he have little bug
function buyMap(player, command, findMap , ...)
if g_ForcedNextMap then
outputChatBox( 'Next map is ' .. getMapName( g_ForcedNextMap ), player )
return
end
local query = #{...}>0 and table.concat({...},' ') or nil
if not query then
if g_ForcedNextMap then
outputChatBox( 'Next map is ' .. getMapName( g_ForcedNextMap ), player )
else
outputChatBox( 'Next map is not set', player, 255, 0, 0 )
end
return
end
local map = findMap(query)
if not map then
outputChatBox(errormsg, player)
return
end
if(getPlayerMoney(player) > 3499) then
if lastmap_B == map then
outputChatBox( 'That map has been played too much recently.', player, 255, 0, 0 )
else
g_ForcedNextMap = map
outputChatBox(getPlayerName(player).. " bought map '" ..getMapName(g_ForcedNextMap).. "' for $3500. (/bm)", g_Root, 0, 240, 0)
givePlayerMoney(player, -3500)
setElementData(player, "Money", getPlayerMoney(player))
lastmap_B = g_ForcedNextMap
end
else
outputChatBox("You don't have enough money. ($3500)", player, 255, 0, 0)
end
end
addCommandHandler('bm', buyMap)
addCommandHandler('buymap', buyMap)
can any one fixed it plz