Jump to content

Need help with script


Bleidex

Recommended Posts

Hey, im making buy map script, as i thought it shouldnt be hard but i failed somewhere and i can't understand what i did wrong.

Heres whole code:

addCommandHandler('bm', 
    function( player, command, ... ) 
        local query = #{...}>0 and table.concat({...},' ') or nil 
        if not query then 
            if g_ForcedNextMap then 
                outputRace( 'Next map is ' .. getMapName( g_ForcedNextMap ), player ) 
            else 
                outputRace( 'Next map is not set', player ) 
            end 
            return 
        end 
        if not _TESTING and not isPlayerInACLGroup(player, g_GameOptions.everyone) then 
            return 
        end 
        local map, errormsg = findMap( query ) 
        if not map then 
            outputRace( errormsg, player ) 
            return 
        end 
        if g_ForcedNextMap == map then 
            outputRace( 'Next map is already set to ' .. getMapName( g_ForcedNextMap ), player ) 
            return 
        end 
        g_ForcedNextMap = map 
        outputChatBox(getPlayerName( player ) .. 'bought' .. getMapName( g_ForcedNextMap ), g_Root, 0, 240, 0) 
    end 
     takePlayerMoney ( player, tonumber(5000) ) 
    end 
) 
  

With debugscript 3 it says that unexpected symbol near '..' in line 25. Thats this line:

        outputChatBox(getPlayerName( player ) .. 'bought' .. getMapName( g_ForcedNextMap ), g_Root, 0, 240, 0) 

Also, I dont know if I made takePlayercash function right(It needs to take 5k), could you guy check that?

P.S. I donk know what to do with this line:

if not _TESTING and not isPlayerInACLGroup(player, g_GameOptions.everyone) then 

I need that Everyone could use this command.

Link to comment

uhm try this (not tested)

addCommandHandler('bm', 
    function( player, command, ... ) 
        local query = #{...}>0 and table.concat({...},' ') or nil 
        if not query then 
            if g_ForcedNextMap then 
                outputRace( 'Next map is ' .. getMapName( g_ForcedNextMap ), player ) 
            else 
                outputRace( 'Next map is not set', player ) 
            end 
            return 
        end 
        if not _TESTING and not isPlayerInACLGroup(player, g_GameOptions.everyone) then 
            return 
        end 
        local map, errormsg = findMap( query ) 
        if not map then 
            outputRace( errormsg, player ) 
            return 
        end 
        if g_ForcedNextMap == map then 
            outputRace( 'Next map is already set to ' .. getMapName( g_ForcedNextMap ), player ) 
            return 
        end 
        g_ForcedNextMap = map 
        outputChatBox(getPlayerName( player ) .. 'bought' .. getMapName( g_ForcedNextMap ), g_Root, 0, 240, 0) 
        takePlayerMoney ( player, 5000) 
end 
) 

Link to comment
addCommandHandler('bm', 
    function( player, command, ... ) 
        local query = #{...}>0 and table.concat({...},' ') or nil 
        if not query then 
            if g_ForcedNextMap then 
                exports.race:outputRace( 'Next map is ' .. getMapName( g_ForcedNextMap ), player ) 
            else 
                outputRace( 'Next map is not set', player ) 
            end 
            return 
        end 
        if not _TESTING and not isPlayerInACLGroup(player, g_GameOptions.everyone) then 
            return 
        end 
        local map, errormsg = findMap( query ) 
        if not map then 
            exports.race:outputRace( errormsg, player ) 
            return 
        end 
        if g_ForcedNextMap == map then 
            exports.race:outputRace( 'Next map is already set to ' .. getMapName( g_ForcedNextMap ), player ) 
            return 
        end 
        g_ForcedNextMap = map 
        outputChatBox(getPlayerName( player ) .. 'bought' .. getMapName( g_ForcedNextMap ), g_Root, 0, 240, 0) 
        takePlayerMoney ( player, 5000) 
end 
) 

this only fixes the outputRace errors, you still got errors with variables.

Link to comment

I implemented it into race resource.

addCommandHandler('bm', 
    function( player, command, ... ) 
        local query = #{...}>0 and table.concat({...},' ') or nil 
        if not query then 
            if g_ForcedNextMap then 
                outputRace( 'Next map is ' .. getMapName( g_ForcedNextMap ), player ) 
            else 
                outputRace( 'Next map is not set', player ) 
            end 
            return 
        end 
        if not _TESTING and not isPlayerInACLGroup(player, g_GameOptions.admingroup) then 
            return 
        end 
        local map, errormsg = findMap( query ) 
        if not map then 
            outputRace( errormsg, player ) 
            return 
        end 
        if g_ForcedNextMap == map then 
            outputRace( 'Next map is already set to ' .. getMapName( g_ForcedNextMap ), player ) 
            return 
        end 
        g_ForcedNextMap = map 
        outputChatBox(getPlayerName( player ) .. 'bought' .. getMapName( g_ForcedNextMap ), g_Root, 0, 240, 0) 
        takePlayerMoney ( player, 5000) 
end 
) 
  

Now if you are admin it buys the map, but it doesnt take the money and also it can do it when ur admin only. How to make that maps could be bought if you are just normal player and whats wrong with taking money function?

Link to comment
addCommandHandler('bm', 
    function( player, command, ... ) 
        local query = #{...}>0 and table.concat({...},' ') or nil 
        if not query then 
            if g_ForcedNextMap then 
                outputRace( 'Next map is ' .. getMapName( g_ForcedNextMap ), player ) 
            else 
                outputRace( 'Next map is not set', player ) 
            end 
            return 
        end 
        local map, errormsg = findMap( query ) 
        if not map then 
            outputRace( errormsg, player ) 
            return 
        end 
        if g_ForcedNextMap == map then 
            outputRace( 'Next map is already set to ' .. getMapName( g_ForcedNextMap ), player ) 
            return 
        end 
        g_ForcedNextMap = map 
        outputChatBox(getPlayerName( player ) .. 'bought' .. getMapName( g_ForcedNextMap ), g_Root, 0, 240, 0) 
        if getPlayerMoney(player) >= 5000 then 
        takePlayerMoney ( player, 5000) 
    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...