Jump to content

client / server


COOKIE2

Recommended Posts

hello i made a gui with things tht save stats/shop/settings and things like tht

now it works cuz when i press f5 it shows my gui but when i press on example buy nitro in shop it closes

in the server command screen it says serverside not added

HOW do i add it? this is client.lua

toServer = {} 
theSkins = {}
theTimers = {}
theMessages = {}
boxW = 333
boxH = 111
screenW, screenH = guiGetScreenSize()
boxX = screenW/2 - 166
boxY = screenH/2 - 50
headX = boxX + 60
headY = boxY + 12
headXb = boxX + 277
headYb = boxY + 40
textX = boxX + 13
textY = boxY + 48
textXb = boxX + 320
textYb = boxY + 98
textF = 1.3
headF = 2.5
timeDeath = 1
black = tocolor(0,0,0,255)
local thisResourceRoot = getResourceRootElement(getThisResource())
 
addEventHandler('onClientResourceStart', thisResourceRoot, replace)
addCommandHandler("replace", replace)
 
addEvent("ddcBox", true)
addEventHandler("ddcBox", getRootElement(),
  function(mType,mHead,mText)
    if mType == 'off' then
      --removeEventHandler("onClientRender", getRootElement(), showBox)
      theMessages['type'] = nil
      theMessages['head'] = nil
      theMessages['text'] = nil
    else
      --addEventHandler("onClientRender", getRootElement(), showBox)
      theMessages['type'] = mType
      theMessages['head'] = mHead
      theMessages['text'] = mText
    end
  end
)  
 
addEvent("ddcMap", true)
addEventHandler("ddcMap", getRootElement(),
  function (mapName)
    theMessages['map'] = mapName
  end
)  
 
function showBox()
  if theMessages['type'] == "warning" then
    dxDrawImage(boxX, boxY, boxW, boxH, "img/warning.png", 0, 0, 0, tocolor(255,255,255,255), true)
    dxDrawText(theMessages['head'], headX, headY, headXb, headYb, black, headF, "default", "center", "center", true, true, true)
    dxDrawText(theMessages['text'], textX, textY, textXb, textYb, black, textF, "default", "center", "center", true, true, true)
  elseif theMessages['type'] == "info" then
    dxDrawImage(boxX, boxY, boxW, boxH, "img/info.png", 0, 0, 0, tocolor(255,255,255,255), true)
    dxDrawText(theMessages['head'], headX, headY, headXb, headYb, black, headF, "default", "center", "center", true, true, true)
    dxDrawText(theMessages['text'], textX, textY, textXb, textYb, black, textF, "default", "center", "center", true, true, true)
  end
  dxDrawText(theMessages['map'], headX, 58, headXb+25, 72, tocolor(255,255,255,222), 1, "default", "center", "center", true, true, true)
end
 
addEvent("requestReply", true)
addEventHandler("requestReply", getRootElement(),
  function (tempTable)
    theText = "Currently you have $" .. tempTable['cash'] .. " in cash.\n\n"
    theText = theText .. "Played " .. tempTable['dms'] .. " matches and won " .. tempTable['wins'] .. ", which is " .. tempTable['ratio'] .. "%\n\n"
    theText = theText .. "You've earned " .. tempTable['pts'] .. " points and " .. tempTable['skill'] .. " skill points total.\n\n"
    theText = theText .. "Your price is $" .. tempTable['price'] .. " and your owner is: " .. tempTable['owner'] .. "\n\nYour deathmatch rank is: " .. tempTable['rank'] .. "\n\n"
    theText = theText .. "Time spent on server (HH:MM): " .. tempTable['gametime']
    guiSetText ( labelStats, theText )
    guiSetText ( labelMaps, tempTable['maplist'])
    guiLabelSetColor ( labelMaps, 255, 180, 0)
    guiSetText ( labelSlaves, tempTable['playerlist'])
    guiLabelSetColor ( labelSlaves, 255, 180, 0)
    guiSetText ( wndInfo, "Multi Player Race: " .. tempTable['name'] )
    guiSetText ( setSexEdit, tempTable['sexage'])
    guiSetText ( setContactEdit, tempTable['contact'])
    guiSetText ( setMsgEdit, tempTable['message'])
    if tempTable['messageon'] > 1 then guiCheckBoxSetSelected(setMsgDEdit, true)
    else guiCheckBoxSetSelected(setMsgDEdit, false) end
    guiSetText ( setCColorEdit, tempTable['namecolor'])
    guiSetText ( setTColorEdit, tempTable['chatcolor'])
    guiSetText ( setVColor1Edit, tempTable['vcolor1'])
    guiSetText ( setVColor2Edit, tempTable['vcolor2'])
    guiSetText ( setSkinEdit, tempTable['skin'])
    guiSetText ( setLockEdit, tempTable['lock'])
  end
)
 
addEventHandler("onClientResourceStart", thisResourceRoot,
    function ()
    addEventHandler("onClientRender", getRootElement(), showBox)
    local x, y = guiGetScreenSize()
 
        wndInfo  = guiCreateWindow( x / 2 - 280, y / 2 - 150, 560, 300,  "Multi Player Race", false)
    infoImg = guiCreateStaticImage( .78, 0.17, .22, .38, "img/logo.png", true, wndInfo )
        infoClose = guiCreateButton(.78, .9, .22, .09, "Close", true, wndInfo)
    infoTabs = guiCreateTabPanel ( 0, 0.1, 0.75, 1, true, wndInfo )
 
    tabStats = guiCreateTab( "Statistics", infoTabs)  
    labelStats = guiCreateLabel(0.02,0.04,0.94,0.94,"OMG! OMGOMGOMG!!! O M F G!\nYOU SHOULDNT SEE THIS!!\nPlease relogin if you see this message!\n\n\n\nlol",true,tabStats)
    setLockEdit = guiCreateEdit( 0.02, 0.86, 0.1, 0.1, "1", true, tabStats)
    guiEditSetMaxLength(setLockEdit, 2)    
    setLockDesc = guiCreateLabel(0.15,0.86,0.80,0.15, "You can lock your account with login timeout up to 30 sec.\nAnything below 3 seconds disables the lock.",true,tabStats)
    setLockB = guiCreateButton(.78, .86, .2, .1, "Set lock", true, tabStats)
    guiSetFont(setLockDesc, "default-small")
 
    tabSettings = guiCreateTab( "Settings", infoTabs)  
    guiCreateLabel(0.02,0.04,0.50,0.15, "Your sex and age:",true,tabSettings)
    setSexEdit = guiCreateEdit( 0.02, 0.11, 0.4, 0.1, "", true,tabSettings )    
    setMsgDEdit = guiCreateCheckBox(0.45,0.04,0.55,0.07, "Message when you login: ", false, true, tabSettings)
    setMsgEdit = guiCreateEdit( 0.45, 0.11, 0.5, 0.1, "", true,tabSettings )    
    guiCreateLabel(0.02,0.24,0.50,0.15, "Your contact info:",true,tabSettings)
    setContactEdit = guiCreateEdit( 0.02, 0.31, 0.4, 0.1, "", true,tabSettings )    
    guiCreateLabel(0.02,0.44,0.50,0.15, "Your name and chat #COLORS:",true,tabSettings)
    setCColorEdit = guiCreateEdit( 0.02, 0.51, 0.19, 0.1, "#FFFFFF", true,tabSettings )    
    setTColorEdit = guiCreateEdit( 0.23, 0.51, 0.19, 0.1, "#FFFFFF", true,tabSettings )    
    guiEditSetMaxLength(setCColorEdit, 7)
    guiEditSetMaxLength(setTColorEdit, 7)
    guiCreateLabel(0.02,0.64,0.50,0.15, "Your vehicle colors (0-126):",true,tabSettings)
    setVColor1Edit = guiCreateEdit( 0.02, 0.71, 0.19, 0.1, "1", true,tabSettings )    
    setVColor2Edit = guiCreateEdit( 0.23, 0.71, 0.19, 0.1, "1", true,tabSettings )    
    guiEditSetMaxLength(setVColor1Edit, 3)
    guiEditSetMaxLength(setVColor2Edit, 3)
 
        vehicleColorHelp = guiCreateButton(.02, .84, .4, .1, "Vehicle colors list", true, tabSettings)
    vehicleColorHelpWindow = guiCreateWindow ( x / 2 - 280, y / 2 - 150, 540, 215, "Vehicle colors", false )
        guiCreateStaticImage ( 0.01, 0.08, 0.98, 0.80, "img/colors.png", true, vehicleColorHelpWindow )
        vehicleColorHelpClose = guiCreateButton ( 0.86, 0.86, 0.19, 0.15, "Close", true, vehicleColorHelpWindow )
        guiSetVisible ( vehicleColorHelpWindow, false )    
 
    guiCreateLabel(0.45,0.24,0.50,0.15, "Your skin (select ID from the list):",true,tabSettings)
    setSkinList = guiCreateGridList(0.45, 0.31, 0.5, 0.50, true, tabSettings)
    guiGridListAddColumn( setSkinList, "ID", 0.20 )
      guiGridListAddColumn( setSkinList, "", 0.75 )    
    guiEditSetMaxLength(setSkinEdit, 3)
    theSkins = parseSkins()
    aListSkins()
    setSkinEdit = guiCreateEdit( 0.45, 0.84, 0.08, 0.1, "1", true, tabSettings)    
        settingsSaveB = guiCreateButton(.65, .84, .3, .1, "Save all", true, tabSettings)
 
    tabMaps = guiCreateTab( "My maps", infoTabs)  
    labelMapsHead = guiCreateLabel(0.02,0.04,0.94,0.14,"This is the list of the maps you own (/mymaps):",true,tabMaps)
    labelMaps = guiCreateLabel(0.02,0.30,0.94,0.84,"This is the list of you maps.\n\nIf you see this message - something is wrong with the script :D",true,tabMaps)
    labelMapsFoot = guiCreateLabel(0.02,0.08,0.94,0.20,"\nEvery time your map is played you are getting some cash.\nYou can buy a running map with /buymap command.\nOr sell with /sellmap, if that map belongs to you.",true,tabMaps)
 
    tabSlaves = guiCreateTab( "My players", infoTabs)  
    labelSlavesHead = guiCreateLabel(0.02,0.04,0.94,0.14,"This is the list of the players you own (/myplayers):",true,tabSlaves)
    labelSlaves = guiCreateLabel(0.02,0.30,0.94,0.84,"This is the list of you players.\n\nIf you see this message - something is wrong with the script :D",true,tabSlaves)
    labelSlavesFoot = guiCreateLabel(0.02,0.08,0.94,0.20,"\nEvery time your player wins you will get some cash for it too.\nYou can buy an online player with /buyp <name>.\nOr sell with /sellp <name> command.",true,tabSlaves)
 
    tabShop = guiCreateTab( "Shop", infoTabs)  
    labelShop = guiCreateLabel(0.02,0.04,0.94,0.14,"Here (or using /buy) you can buy some stuff. All effects are immediate!",true,tabShop)
    labelShopDesc = guiCreateLabel(0.03,0.86,0.90,0.15, "Please always check currently available item prices by just typing /buy without parameters.\nItem prices or availability can be changed by admin at any time.",true,tabShop)
        guiSetFont(labelShopDesc, "default-small")
 
    buyBomb = guiCreateButton(.02, .15, .19, .08, "/buy bomb", true, tabShop)
    labelShopBomb = guiCreateLabel(0.22,0.14,0.74,0.10, "Puts an exploding barrel\nat your location in 2 sec",true,tabShop)
        guiSetFont(labelShopBomb, "default-small")
    buyFix = guiCreateButton(.5, .15, .19, .08, "/buy fix", true, tabShop)
    labelShopFix = guiCreateLabel(0.7,0.14,0.74,0.10, "Fixes your vehicle to 100%",true,tabShop)
        guiSetFont(labelShopFix, "default-small")
 
    buyMine = guiCreateButton(.02, .27, .19, .08, "/buy mine", true, tabShop)
    labelShopMine = guiCreateLabel(0.22,0.26,0.74,0.10, "Creates a spiky sea mine\nat your location in 2 sec",true,tabShop)
        guiSetFont(labelShopMine, "default-small")
    buyNitro = guiCreateButton(.5, .27, .19, .08, "/buy nitro", true, tabShop)
    labelShopNitro = guiCreateLabel(0.7,0.26,0.74,0.10, "Gives you a nitro to use",true,tabShop)
        guiSetFont(labelShopNitro, "default-small")
 
    buyHay = guiCreateButton(.02, .39, .19, .08, "/buy hay", true, tabShop)
    labelShopHay = guiCreateLabel(0.22,0.38,0.74,0.10, "Creates a stack of hay\nat your location in 2 sec",true,tabShop)
        guiSetFont(labelShopHay, "default-small")
    buyGod = guiCreateButton(.5, .39, .19, .08, "/buy god", true, tabShop)
    labelShopGod = guiCreateLabel(0.7,0.38,0.74,0.10, "God of Destruction:\nfor 30 sec kills everyone near",true,tabShop)
        guiSetFont(labelShopGod, "default-small")
 
    buyRamp = guiCreateButton(.02, .51, .19, .08, "/buy ramp", true, tabShop)
    labelShopRamp = guiCreateLabel(0.22,0.50,0.74,0.10, "Adds a ramp to your car\nFun stuff :D",true,tabShop)
        guiSetFont(labelShopRamp, "default-small")
    buyGs = guiCreateButton(.5, .51, .19, .08, "/buy gs", true, tabShop)
    labelShopGs = guiCreateLabel(0.7,0.50,0.74,0.10, "Use Gravity Strike\naffecting all players",true,tabShop)
        guiSetFont(labelShopGs, "default-small")
 
        guiSetVisible(wndInfo, false)
        guiSetFont(labelMapsHead, "clear-normal")
        guiSetFont(labelMaps, "default-small")
        guiSetFont(labelMapsFoot, "default-small")
        guiSetFont(labelSlavesHead, "clear-normal")
        guiSetFont(labelSlaves, "default-small")
        guiSetFont(labelSlavesFoot, "default-small")
        guiSetFont(labelSettings, "sa-gothic")
        guiSetFont(setSkinList, "default-small")
        guiSetFont(setSkinList, "default-small")
        guiSetFont(settingsSaveB, "default-bold-small")
        guiSetFont(infoClose, "default-bold-small")
        guiWindowSetSizable(wndInfo, false)
 
    addEventHandler("onClientGUIClick", source,
            function()
                if source == vehicleColorHelp then
            guiSetVisible(vehicleColorHelpWindow, true)
          guiBringToFront(vehicleColorHelpWindow)
        elseif source == vehicleColorHelpClose then
          guiSetVisible(vehicleColorHelpWindow, false)
            elseif source == setSkinList then
                if ( guiGridListGetSelectedItem ( setSkinList ) ~= -1 ) then
                    local id = guiGridListGetItemText ( setSkinList, guiGridListGetSelectedItem ( setSkinList ), 1 )
                    guiSetText ( setSkinEdit, id )
                 end
        elseif source == infoClose then
          toggleInfo(false)
            elseif source == setLockB then
          toServer['lock'] = guiGetText(setLockEdit)
          triggerServerEvent("lockUpdate", getLocalPlayer(), toServer)
          toggleInfo(false)
            elseif source == settingsSaveB then
                toServer['sexage'] = guiGetText(setSexEdit)
                toServer['contact'] = guiGetText(setContactEdit)
                toServer['skin'] = guiGetText(setSkinEdit)
                toServer['message'] = guiGetText(setMsgEdit)
          if guiCheckBoxGetSelected(setMsgDEdit) then
            toServer['messageon'] = 2
          else
            toServer['messageon'] = 1
          end
                toServer['vcolor1'] = guiGetText(setVColor1Edit)
                toServer['vcolor2'] = guiGetText(setVColor2Edit)
                toServer['namecolor'] = guiGetText(setCColorEdit)
                toServer['chatcolor'] = guiGetText(setTColorEdit)
          triggerServerEvent("settingsUpdate", getLocalPlayer(), toServer)
          toggleInfo(false)
        elseif source == buyBomb then
          triggerServerEvent("shopGate", getLocalPlayer(), "bomb")
          toggleInfo(false)
        elseif source == buyHay then
          triggerServerEvent("shopGate", getLocalPlayer(), "hay")
          toggleInfo(false)
        elseif source == buyMine then
          triggerServerEvent("shopGate", getLocalPlayer(), "mine")
          toggleInfo(false)
        elseif source == buyGs then
          triggerServerEvent("shopGate", getLocalPlayer(), "gs")
          toggleInfo(false)
        elseif source == buyFix then
          triggerServerEvent("shopGate", getLocalPlayer(), "fix")
          toggleInfo(false)
        elseif source == buyNitro then
          triggerServerEvent("shopGate", getLocalPlayer(), "nitro")
            toggleInfo(true)
Edited by Guest
Link to comment
Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

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