Jump to content

buymap


Micro

Recommended Posts

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

Link to comment

Hmm i've tried to modify this script to work with race_starter_pack's money but there are some errors :(

  
    local money1 = tostring(getElementData(localPlayer,"Money")) 
    function buyMap(player, command,  ...) 
        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(money1 > 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", money1) 
                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) 
  

line 22 : attempt to compare number with string

Link to comment
function buyMap(player, command,  ...) 
    local money1 = tonumber(getElementData(player,"Money")) 
    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(money1 >= 3500) 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) 
            setElementData(player, "Money", money1-3500) 
            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) 

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