Micro Posted November 29, 2011 Share Posted November 29, 2011 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
Micro Posted November 29, 2011 Author Share Posted November 29, 2011 findMap code error Link to comment
Castillo Posted November 29, 2011 Share Posted November 29, 2011 findMap is a custom function in race/racevoting_server.lua. Link to comment
Micro Posted November 29, 2011 Author Share Posted November 29, 2011 iknow but why bug Link to comment
Castillo Posted November 29, 2011 Share Posted November 29, 2011 Where are you running this script from? if is not from the race himself, then findMap function will be missing. Link to comment
Micro Posted November 29, 2011 Author Share Posted November 29, 2011 ty man iadd code in race/racevoting_server.lua. and work anyone need buymap add this code to recourse/race/racevoting_server.lua Link to comment
novo Posted December 4, 2011 Share Posted December 4, 2011 On debugscript 3 says: Attempt to call local "findMap" (a string value) That's an error. Plz help PD: I added all the code to race/racevoting_server.lua Link to comment
Aibo Posted December 4, 2011 Share Posted December 4, 2011 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, ...) Link to comment
novo Posted December 4, 2011 Share Posted December 4, 2011 So i should rename findMap ? Please explain me, i'm a noob. Thanks Edit: Ok thanks <3 Link to comment
SnoopCat Posted December 9, 2011 Share Posted December 9, 2011 i tryed to add but nothing happens when i put /bm [Mapname] can someone help plz? there are no errors just not working... Link to comment
h4x7o0r Posted December 10, 2011 Share Posted December 10, 2011 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
bandi94 Posted December 10, 2011 Share Posted December 10, 2011 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 Link to comment
h4x7o0r Posted December 10, 2011 Share Posted December 10, 2011 ty but i don't know what and where should i modify ? Link to comment
Castillo Posted December 10, 2011 Share Posted December 10, 2011 (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 December 11, 2011 by Guest Link to comment
h4x7o0r Posted December 11, 2011 Share Posted December 11, 2011 Thank you again solid, the script now it works fine but it doesn't decrease the money (from 10000 - 3500 = 7500). Link to comment
Castillo Posted December 11, 2011 Share Posted December 11, 2011 Copy the code again. P.S: 10000 - 3500 = 6500 . Link to comment
h4x7o0r Posted December 11, 2011 Share Posted December 11, 2011 Now it's perfect. Thank you for your help man. PS : yeah my bad Link to comment
h4x7o0r Posted December 11, 2011 Share Posted December 11, 2011 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. Link to comment
Castillo Posted December 11, 2011 Share Posted December 11, 2011 You'll have to do that, you didn't suppose that I was going to give you everything done, right? Link to comment
h4x7o0r Posted December 11, 2011 Share Posted December 11, 2011 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. 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