Newbie Posted April 29, 2014 Share Posted April 29, 2014 I'ma trying to make a map shop, when i select map on gridlist and press button to buy i get this: attempt to callServerFunction a nil value Server: function buyMap(player, command, ...) local account = ( ( getPlayerAccount( player ) and not isGuestAccount( getPlayerAccount( player ) ) ) and getPlayerAccount( player ) or false ) if ( account ) then local cashHave = tonumber( getAccountData( account, "Cash" ) ) local buyMapss = tonumber( getAccountData( account, "BuyMaps" ) ) 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( '#FF0000={#FFFFFFBuyMap#FF0000}=#FFFFFF Next map is ' .. getMapName( g_ForcedNextMap )"", player, 255, 0, 0, true) else outputChatBox( '#FF0000={#FFFFFFBuyMap#FF0000}=#FFFFFF Next map is not set', player, 255, 0, 0, true ) end return end local map = findMap(query) if not map then outputChatBox(errormsg, player) return end if ( cashHave ) and ( cashHave >= 3000 ) then if lastmap_B == map then outputChatBox( '#FF0000={#FFFFFFBuyMap#FF0000}=#FFFFFF That map has been played too much recently.', player, 255, 0, 0, true) else g_ForcedNextMap = map outputChatBox("#FF0000={#FFFFFFBuyMap#FF0000}=#FFFFFF "..getPlayerName(player).. " #FFFFFFbought next map to be #FF0000'" ..getMapName(g_ForcedNextMap).. "'", g_Root, 255, 255, 255, true) setAccountData( account, "Cash", cashHave - 3000 ) setAccountData( account,"BuyMaps",tostring( getAccountData( account,"BuyMaps" ) or 0 )+1 ) lastmap_B = g_ForcedNextMap end else outputChatBox("#FF0000={#FFFFFFBuyMap#FF0000}=#FFFFFF You don't have enough money! #FF00003000$", player, 255, 0, 0, true) end end end addCommandHandler('bm', buyMap) addCommandHandler('buymap', buyMap) Client: function buyNextMap() local row,column = guiGridListGetSelectedItem(mapGridList) local mapName = guiGridListGetItemText(mapGridList,row,1) callServerFunction("buyMap",getLocalPlayer(),mapName) end addEventHandler ( "onClientGUIClick", GUIEditor.button[4], buyNextMap, false ) Link to comment
LonelyRoad Posted April 29, 2014 Share Posted April 29, 2014 callServerFunction is a useful function, as the wiki page says at the top. Have you included this function anywhere in your script? You'd probably be better off using addEvent and addEventHandler instead for something like this (with, in this case triggerServerEvent). Link to comment
Newbie Posted April 29, 2014 Author Share Posted April 29, 2014 You didn't solved my problem Link to comment
LonelyRoad Posted April 29, 2014 Share Posted April 29, 2014 What is the error message this time? Link to comment
Newbie Posted April 30, 2014 Author Share Posted April 30, 2014 I've have fixed it by changing to getMapName from mapName and adding function to read the resource name of the selected map to make it match with buyMap function 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