Jump to content

BuyNextMap Server/Client


Recommended Posts

Posted

Hi all Guyz, well, for long time i have been triyng to fix this, when i click the button nothing happens, i think im missing something, but i cant find it...

Server Side:

  
-- Buy a next map 
function buyMap(thePlayer,mapName) 
 --local playerLevel = tonumber(loadPlayerData(thePlayer,"level")) 
 local playerCash = tonumber(loadPlayerData(thePlayer,"cash")) 
 if mapIsAlreadySet == false then 
  if not (mapName == "") then 
   --if playerLevel >= mapLevel then 
    if playerCash >= mapCost then 
     triggerEvent("onNextmapRequest",thePlayer,thePlayer,mapName) 
    else 
     outputChatBox("#FF6600* #FFFFFFYou don't have enough money to set a map!",thePlayer,255,255,255,true) 
    end 
   --else 
    --outputChatBox("#FF6600* #FFFFFFYou need to be level #ABCDEF"..mapLevel.." #FFFFFFor higher to set maps!",thePlayer,255,255,255,true) 
   --end 
  else 
   outputChatBox("#FF6600* #FFFFFFPlease select a map from the list first!",thePlayer,255,255,255,true) 
  end 
 else 
  outputChatBox("#FF6600* #FFFFFFA map is already set at the moment! Please try again later.",thePlayer,255,255,255,true) 
 end 
end 
  
function resetMapSetStatus() 
 mapIsAlreadySet = false 
end 
addEventHandler("onMapStarting",getRootElement(),resetMapSetStatus) 
  
  
addEvent("onSetNextMap",true) 
addEventHandler("onSetNextMap",getRootElement(), 
function (mapName) 
 thePlayer = source 
 local playerCash = tonumber(loadPlayerData(thePlayer,"cash")) 
 savePlayerData(thePlayer,"cash",playerCash-mapCost) 
 outputChatBox("#FFFFFFNextmap: "..getPlayerName(thePlayer).."#FFFFFF has bought a next map!",getRootElement(),255,255,255,true) 
 outputChatBox("#FFFFFFNextmap: #FF8800"..mapName,getRootElement(),255,255,255,true) 
 mapIsAlreadySet = true 
 scoreboardRefresh(thePlayer) 
 achievement31(thePlayer) 
end) 
  
addEvent("onSetNextMap",true) 
addEventHandler("onSetNextMap",getRootElement(), 
function () 
 mapIsAlreadySet = true 
end) 

Client Side:

  
function buyNextMap() 
 local selectedMap = guiGridListGetSelectedItem(gridMaps) 
 if selectedMap == -1 then 
  outputChatBox("#FF6600* #FFFFFFERROR! Please select a Map to buy!",255,255,255,true) 
 local row,column = guiGridListGetSelectedItem(gridMaps) 
 local mapName = guiGridListGetItemText(gridMaps,row,1) 
   addEventHandler("onClientGUIClick",btn_buyNextMap, buyNextMap, buyMap, true) 
 callServerfunction("buyMap",getLocalPlayer(),mapName,getPlayerName, onClientGUIClick) 
end 
end 

This is an image of tab related to this:

(its on KN3 so wont drop)

F7D3CDBEB.png

My ingame nick is ~HyPeX~

BF3 Gamemode Progress: ~30% - Currently working on AI & MapManager

gKhdyRJ.png

Posted (edited)

Try:

Server Side:

  
addEvent("onMapStarting",true) 
  
function buyMap(thePlayer,mapName) 
    local playerCash = tonumber(loadPlayerData(thePlayer,"cash")) 
    if ( mapIsAlreadySet == false ) then 
        if ( not mapName == "" ) then 
            if ( playerCash >= mapCost ) then 
                triggerEvent("onSetNextMap",thePlayer,thePlayer,mapName) 
            else 
                outputChatBox("#FF6600* #FFFFFFYou don't have enough money to set a map!",thePlayer,255,255,255,true) 
            end 
        else 
            outputChatBox("#FF6600* #FFFFFFPlease select a map from the list first!",thePlayer,255,255,255,true) 
        end 
    else 
        outputChatBox("#FF6600* #FFFFFFA map is already set at the moment! Please try again later.",thePlayer,255,255,255,true) 
    end 
end 
  
function resetMapSetStatus() 
    mapIsAlreadySet = false 
end 
addEventHandler("onMapStarting",getRootElement(),resetMapSetStatus) 
  
  
addEvent("onSetNextMap",true) 
addEventHandler("onSetNextMap",getRootElement(), 
    function (thePlayer,mapName) 
        local playerCash = tonumber(loadPlayerData(thePlayer,"cash")) 
        savePlayerData(thePlayer,"cash",playerCash-mapCost) 
        outputChatBox("#FFFFFFNextmap: "..getPlayerName(thePlayer).."#FFFFFF has bought a next map!",getRootElement(),255,255,255,true) 
        outputChatBox("#FFFFFFNextmap: #FF8800"..mapName,getRootElement(),255,255,255,true) 
        mapIsAlreadySet = true 
        scoreboardRefresh(thePlayer) 
        achievement31(thePlayer) 
    end 
) 

Client Side:

  
function buyNextMap() 
 local selectedMap, column = guiGridListGetSelectedItem(gridMaps) 
 if not selectedMap and not column and selectedMap == -1 and column == -1 then 
  outputChatBox("#FF6600* #FFFFFFERROR! Please select a Map to buy!",255,255,255,true) -- you can't use color codes in client-side 
 else 
  local mapName = guiGridListGetItemText(gridMaps,colName,1) --change colName by your column name. 
 triggerServerEvent("buyMap",getLocalPlayer(),mapName,getPlayerName(localPlayer)) 
end 
end 
addEventHandler("onClientGUIClick",btn_buyNextMap, buyNextMap, true) 

Updated. Verify if btn_buyNextMap exists !!

Edited by Guest

EPT Team Server Development: 0%

Learning C++ | C++ is amazing xD

Posted

Draken, You not add event buyMap and handler.

1 argument is string( not element ), 2 argument is string in function buyMap.

http://vk.com/the_kenix

Вопросы задавайте на форуме, не пишите мне в личку.

Please don't pm me.

Posted

Server Side:

  
addEvent("onMapStarting",true) 
addEvent('buyMap',true) 
  
function buyMap(thePlayer,mapName) 
    local playerCash = tonumber(loadPlayerData(thePlayer,"cash")) 
    if ( mapIsAlreadySet == false ) then 
        if ( not mapName == "" ) then 
            if ( playerCash >= mapCost ) then 
                triggerEvent("onSetNextMap",thePlayer,thePlayer,mapName) 
            else 
                outputChatBox("#FF6600* #FFFFFFYou don't have enough money to set a map!",thePlayer,255,255,255,true) 
            end 
        else 
            outputChatBox("#FF6600* #FFFFFFPlease select a map from the list first!",thePlayer,255,255,255,true) 
        end 
    else 
        outputChatBox("#FF6600* #FFFFFFA map is already set at the moment! Please try again later.",thePlayer,255,255,255,true) 
    end 
end 
addEventHandler('buyMap',root,buyMap) 
  
function resetMapSetStatus() 
    mapIsAlreadySet = false 
end 
addEventHandler("onMapStarting",getRootElement(),resetMapSetStatus) 
  
  
addEvent("onSetNextMap",true) 
addEventHandler("onSetNextMap",getRootElement(), 
    function (thePlayer,mapName) 
        local playerCash = tonumber(loadPlayerData(thePlayer,"cash")) 
        savePlayerData(thePlayer,"cash",playerCash-mapCost) 
        outputChatBox("#FFFFFFNextmap: "..getPlayerName(thePlayer).."#FFFFFF has bought a next map!",getRootElement(),255,255,255,true) 
        outputChatBox("#FFFFFFNextmap: #FF8800"..mapName,getRootElement(),255,255,255,true) 
        mapIsAlreadySet = true 
        scoreboardRefresh(thePlayer) 
        achievement31(thePlayer) 
    end 
) 

Client Side:

  
function buyNextMap() 
 local selectedMap, column = guiGridListGetSelectedItem(gridMaps) 
 if not selectedMap and not column and selectedMap == -1 and column == -1 then 
  outputChatBox("#FF6600* #FFFFFFERROR! Please select a Map to buy!",255,255,255,true) -- you can't use color codes in client-side 
 else 
  local mapName = guiGridListGetItemText(gridMaps,colName,1) --change colName by your column name. 
 triggerServerEvent("buyMap",localPlayer,localPlayer,mapName) 
end 
end 
addEventHandler("onClientGUIClick",btn_buyNextMap, buyNextMap, true) 

EPT Team Server Development: 0%

Learning C++ | C++ is amazing xD

  • 2 weeks later...
Posted

1)This map never will set, because its not your script,

You stole script in NexTrime panel.

2)You need trigger 'racevoting_server.lua' (Function Nextmap)

357ac0078264.jpg

- Working on [php/HTML/Mysql/Lua/Java Scripts/Web Design/3D Modeling]

Posted

*facepalm*

Dude , you make ur own nextmap , just trigger an event when a button is double clicked , and then simply do

  
executeCommandHandler("nextmap",source,map) 

or smth like that.

My Projects!

No one.

Posted
1)This map never will set, because its not your script,

You stole script in NexTrime panel.

2)You need trigger 'racevoting_server.lua' (Function Nextmap)

i didnt stole the script, i have it and im trying to fix it.

okay, i thanks, thats what i forgot, the racevoting.

My ingame nick is ~HyPeX~

BF3 Gamemode Progress: ~30% - Currently working on AI & MapManager

gKhdyRJ.png

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...