Jump to content

buymap


Micro

Recommended Posts

Posted

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

94.23.158.18022003.png
Posted

And the bug is...?

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

findMap is a custom function in race/racevoting_server.lua.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

Where are you running this script from? if is not from the race himself, then findMap function will be missing.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

ty man iadd code in race/racevoting_server.lua. and work anyone need buymap add this code to

recourse/race/racevoting_server.lua

94.23.158.18022003.png
Posted

On debugscript 3 says: Attempt to call local "findMap" (a string value)

That's an error.

Plz help :S

PD: I added all the code to race/racevoting_server.lua

Posted

because findMap is a string in that function scope, due to: function buyMap(player, command, findMap, ...)

rename/remove that variable, it's not needed: function buyMap(player, command, ...)

?

Posted

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

Posted

whit your script when a player leave the server he will lost his money i don't think player's will lake that every time to get 0$ when join to the server use AccountData

Ingame Name : |DGT|Puma

DGT Clan Server 24/7 Owner/Scripter

MultiGameMode in progress :

n-560x95_FFFFFF_FFFFFF_0283C4_000000.png

Posted (edited)
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

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

Copy the code again.

P.S: 10000 - 3500 = 6500 ;).

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

And if i want to show maps found with like player type /bm air , the suggested maps that contains "air" are: FOUND 3 : Aircraft DM, Aircraft strike DM, Air 3 DM.

Posted

You'll have to do that, you didn't suppose that I was going to give you everything done, right?

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

Yes you are right, but first time when i tried micro's code posted the suggested maps appeared. Now i don't know why it doesn't show. Thank you very much for all your help, i really appreciate it.

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