Bleidex Posted December 29, 2010 Share Posted December 29, 2010 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
Castillo Posted December 29, 2010 Share Posted December 29, 2010 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
Bleidex Posted December 29, 2010 Author Share Posted December 29, 2010 Doesnt work ;/ Lots of errors: Idk what to do. Link to comment
Aibo Posted December 29, 2010 Share Posted December 29, 2010 you can't use race resource (not exported) functions and variables outside of race resource. Link to comment
Castillo Posted December 29, 2010 Share Posted December 29, 2010 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
Bleidex Posted December 29, 2010 Author Share Posted December 29, 2010 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
Castillo Posted December 29, 2010 Share Posted December 29, 2010 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
Aibo Posted December 29, 2010 Share Posted December 29, 2010 if you'd «implemented» it in race resource it wouldn't give nil errors at race global variables. and g_ForcedNextMap is race global variable that sets next map as i recall. so g_ForcedNextMap in Buymap resource will do nothing. Link to comment
Bleidex Posted December 29, 2010 Author Share Posted December 29, 2010 Now it sets next map, but it doesnt take the cash. I think i placed it in wrong place, but cant get where to place it. Can you help me? Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now