Newbie Posted March 13, 2014 Share Posted March 13, 2014 Yesterday and a couple of days ago i tryed to fix my panel script but now i decided to make it by other way. Simply command code. Here is it: It says that i dont have money but i have, thats all. function buyMap(player, command, ...) local account = getPlayerAccount(thePlayer) if not (isGuestAccount(account)) then local playerCash = tonumber(getAccountData(account,"cash")) 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, 255, 255 ) end return end local map = findMap(query) if not map then outputChatBox(errormsg, player) return end if ( playerCash ) and ( playerCash >= 1000 ) then if lastmap_B == map then outputChatBox( "* That map has been played recently.", player, 255, 255, 255 ) else g_ForcedNextMap = map outputChatBox(getPlayerName(player).. " bought next map to be " ..getMapName(g_ForcedNextMap).. "", g_Root, 255, 255, 255) setAccountData(account,"cash",playerCash - 1000) addStat(account,"buyedMaps",1) lastmap_B = g_ForcedNextMap end else outputChatBox("* You need more cash", player, 255, 255, 255) end end end addCommandHandler('bm', buyMap) addCommandHandler('buymap', buyMap) Link to comment
Anubhav Posted March 13, 2014 Share Posted March 13, 2014 function buyMap(player, command, ...) local account = getPlayerAccount(thePlayer) if not (isGuestAccount(account)) then return local playerCash = getPlayerMoney(source) 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, 255, 255 ) end return end local map = findMap(query) if not map then outputChatBox(errormsg, player) return end if ( playerCash ) and ( playerCash >= 1000 ) then if lastmap_B == map then outputChatBox( "* That map has been played recently.", player, 255, 255, 255 ) else g_ForcedNextMap = map outputChatBox(getPlayerName(player).. " bought next map to be " ..getMapName(g_ForcedNextMap).. "", g_Root, 255, 255, 255) takePlayerMoney(source,1000) addStat(account,"buyedMaps",1) lastmap_B = g_ForcedNextMap end else outputChatBox("* You need more cash", player, 255, 255, 255) end end end addCommandHandler('bm', buyMap) addCommandHandler('buymap', buyMap) Link to comment
oPIXz Posted March 13, 2014 Share Posted March 13, 2014 try function buyMap(thePlayer, command, ...) local account = getPlayerAccount(thePlayer) if not (isGuestAccount(account)) then local playerCash = tonumber(getAccountData(account,"cash")) if g_ForcedNextMap then outputChatBox( "* Next map is " .. getMapName( g_ForcedNextMap ), thePlayer ) 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 ), thePlayer ) else outputChatBox( "* Next map is not set", thePlayer, 255, 255, 255 ) end return end local map = findMap(query) if not map then outputChatBox(errormsg, thePlayer) return end if if playerCash >= 1000 then if lastmap_B == map then outputChatBox( "* That map has been played recently.", thePlayer, 255, 255, 255 ) else g_ForcedNextMap = map outputChatBox(getPlayerName(thePlayer).. " bought next map to be " ..getMapName(g_ForcedNextMap).. "", g_Root, 255, 255, 255) setAccountData(account,"cash",playerCash - 1000) addStat(account,"buyedMaps",1) lastmap_B = g_ForcedNextMap end else outputChatBox("* You need more cash", thePlayer, 255, 255, 255) end end end addCommandHandler('bm', buyMap) addCommandHandler('buymap', buyMap) 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