deltamta Posted November 30, 2012 Share Posted November 30, 2012 Hello there, I'm making a MySQL stats system that you can buy / unbuy maps from. I already made the buying maps function and it works : ( executeCommandHandler("nextmapcommand", thePlayer, MapName ) ) and i wanna make the unbuying map and im not so sure how I could do that... i tried many things but they dont seem to work : ex. ( unbuy = executeCommandHandler( "nextmapcommand", thePlayer, nil ) ) Doesn't work though... Still keeps the same map as next map. Could you please tell me how could I make it unbuy the map that was bought? That would be great if you could Thanks in advance. *Delta^# Link to comment
Reflex# Posted November 30, 2012 Share Posted November 30, 2012 Hehe...delta,delta...hi It's me. WTF//Reflex# Link to comment
deltamta Posted November 30, 2012 Author Share Posted November 30, 2012 hey I dont see you helping me by saying hi :3 Link to comment
Reflex# Posted November 30, 2012 Share Posted November 30, 2012 First : show your lua code in tagSecond : You must to show all script..to look on all script.May be problem in another part Link to comment
deltamta Posted November 30, 2012 Author Share Posted November 30, 2012 As I said the bm command works so I dont see why the ubm command should not work. I just wanna destroy the map bought so that the next map is random... Hmm let me create a function that gets a random map. Link to comment
deltamta Posted December 1, 2012 Author Share Posted December 1, 2012 addCommandHandler ( "bm", function( thePlayer, command, ... ) local mapName = #{...}>0 and table.concat({...},' ') or nil if mapbought == false then local cash = tonumber( getElementData( thePlayer, "Cash" ) ) if cash >= mapcost then buymap = executeCommandHandler("asdasdfavaginabomb", thePlayer, mapName ) if ( buymap ) then setElementData ( thePlayer, "Cash", cash-mapcost ) mapbought = thePlayer end else outputChatBox("#ff8900[iNFO] #ffffffYou don't have enough money to set a map.", thePlayer, 255, 255, 255, true ) end else outputChatBox("#ff8900[iNFO] #ffffffA map has been already set. Please try again later.", thePlayer, 255, 255, 255,true ) end end ) addCommandHandler ( "ubm", function ( thePlayer ) if mapbought ~= false then if mapbought == thePlayer then unbuy = executeCommandHandler( "asdasdfavaginabomb", thePlayer, nil ) if ( unbuy ) then local cash = tonumber( getElementData( thePlayer, "Cash" ) ) outputChatBox("#ff8900[iNFO] #ffffff"..getPlayerName( thePlayer ).. " #ffffffhas unbought next map",getRootElement(),255,255,255,true) mapbought = false setElementData ( thePlayer, "Cash", cash+mapcost ) end end end end ) This is the stats system part and bellow is the racevoting_server.lua or whatever part : addCommandHandler('asdasdfavaginabomb', 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( "#ff8900[iNFO] #ffffff"..getPlayerName( player ).." #ffffffhas bought next map.", getRootElement(), 255, 255, 255, true) outputChatBox( "#ff8900[iNFO] #ffffffNext map : #ff8900 "..getMapName( g_ForcedNextMap ), getRootElement(), 255, 255, 255, true ) end ) Link to comment
Guest Guest4401 Posted December 1, 2012 Share Posted December 1, 2012 That's not how you unbuy a map. To clear the nextmap, g_ForcedNextMap (a variable in racevoting_server.lua) has to be nil or false. For e.g: (This won't work because "bm" command is not in the same resource and mapbought would be nothing. I suggest you using setElementData to the player and checking if he was the person who bought the next map or not. And replace line 4 in this code later on. Alternatively, you can move the /bm command in the same resource - race, to continue with mapbought variable rather than element data) addCommandHandler("ubm", function(p) if g_ForcedNextMap then if p == mapbought then g_ForcedNextMap = nil outputChatBox(getPlayerName(p).." has unbought the next map") -- return him the cash here else outputChatBox("You did not buy the next map.",p) end else outputChatBox("Next map isn't set.",p) end end ) Link to comment
deltamta Posted December 1, 2012 Author Share Posted December 1, 2012 ehm is there a way to use /ubm and to replace the map you bought with a random map? So basically like buy a random map? Link to comment
Guest Guest4401 Posted December 1, 2012 Share Posted December 1, 2012 ehm is there a way to use /ubm and to replace the map you bought with a random map? So basically like buy a random map? If you want to set a random map, you can make a simple function out of these: exports.mapmanager:getMapsCompatibleWithGamemode ( getResourceFromName'race' ) math.random What I'm trying to say is - Get a list of maps in a table and pick a random map out of it. And assign the map to g_ForcedNextMap variable. Link to comment
deltamta Posted December 1, 2012 Author Share Posted December 1, 2012 You are the boss thanks! It functions! 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