Optimisation

  • Initiateur de la discussion
Peugeot203

Peugeot203

Bambi
Messages
65
Score réaction
4
Points
35
Bonjour à tous,
Oui j'ai encore une question concernant l'optimisation hehe :
Alors mon côté client reçoit des informations toutes les 60 secondes que je stock dans une table.
Ces informations comportent des images etc... . Le problème est qu'il faut alors refresh cette table toute les 60 secondes afin d'avoir les nouvelles qui apparaissent. J'ai alors mis ma table dans ma fonction paint afin que ça me la refresh à l'infini mais je pense que c'est une méthode vraiment dégueulasse. Est-ce qu'il existe un autre moyen de le faire ? Si oui, que dois-je utiliser s'il vous plait ?
Cordialement,
 
Shaar

Shaar

Geek suprême
Messages
151
Score réaction
24
Points
100
t'as pas un bout de script c plus simple ?

comment ca refresh ? dans un paint
 
Deadman69330

Deadman69330

Psychopathe
Messages
2 289
Score réaction
309
Points
290
Un timer ?
 
  • Initiateur de la discussion
Peugeot203

Peugeot203

Bambi
Messages
65
Score réaction
4
Points
35
Enrichi (BBcode):
net.Receive("gbet:tbltoclient", function() gbettbl = net.ReadTable() for k, v in pairs(gbettbl) do if k == 1 then ncfN = v.cfN nchN = v.chN nces = v.ces ncgn = v.cgn ncbsy = v.cbsy ncbsn = v.cbsn ncfA = v.cfA ncfB = v.cfB nchA = v.chA nchB = v.chB ncfsA = v.cfsA ncfsB = v.cfsB nImgA = v.ImgA nImgB = v.ImgB nNameA = v.NameA nNameB = v.NameB nAttA = v.AttA nAttB = v.AttB nDefA = v.DefA nDefB = v.DefB nMidA = v.MidA nMidB = v.MidB else ccfN = v.cfN cchN = v.chN cces = v.ces ccgn = v.cgn ccbsy = v.cbsy ccbsn = v.cbsn ccfA = v.cfA ccfB = v.cfB cchA = v.chA cchB = v.chB ccfsA = v.cfsA ccfsB = v.cfsB cNameA = v.NameA cNameB = v.NameB cImgA = v.ImgA cImgB = v.ImgB cAttA = v.AttA cAttB = v.AttB cDefA = v.DefA cDefB = v.DefB cMidA = v.MidA cMidB = v.MidB end end
end)
-----------------------------------------------------
--Convert our tables for national and club matches --
-----------------------------------------------------
local teams = 1
local function soccerpart() --[[---------------------------------------------
-- Soccer function --
------------------------------------------------]]
local bteamFselect = "off"
local bteamfsselect = "off"
local bteamhselect = "off"
local bteamgnselect = "X"
local bteamesselectB = "X"
local bteamesselectA = "X"
local bteam2scoreselect = "off"
local bteamFcoef = 1
local bteamgncoef = 1
local bteamescoef = 1
local bteam2scorecoef = 1
local bteamfscoef = 1
local bteamhcoef = 1
----------- Others Labels -----------
local gbetsimpletexttbl = { [1] = {name = gbet.fulltime, }, [2] = {name = gbet.halftime }, [3] = {name = gbet.bothteamscore, }, [4] = {name = gbet.firstteamtoscore }, [5] = {name = gbet.goalnumber }, [6] = {name = gbet.exactscore }, }
------------ Labels coef -----------
local bteam = vgui.Create( "DFrame", bform) bteam:SetPos( 260*Wss, 160*Hss) bteam:SetSize( 820*Wss, 480*Hss) bteam:SetTitle( "" ) bteam:ShowCloseButton(false) bteam:SetDraggable( false ) bteam.Paint = function( p, w, h ) if teams == 1 then cfN = ncfN chN = nchN ces = nces cgn = ncgn cbsy = ncbsy cbsn = ncbsn cfA = ncfA cfB = ncfB chA = nchA chB = nchB cfsA = ncfsA cfsB = ncfsB NameA = nNameA NameB = nNameB ImgA = nImgA ImgB = nImgB AttA = nAttA AttB = nAttB DefA = nDefA DefB = nDefB MidA = nMidA MidB = nMidB else cfN = ccfN chN = cchN ces = cces cgn = ccgn cbsy = ccbsy cbsn = ccbsn cfA = ccfA cfB = ccfB chA = cchA chB = cchB cfsA = ccfsA cfsB = ccfsB NameA = cNameA NameB = cNameB ImgA = cImgA ImgB = cImgB AttA = cAttA AttB = cAttB DefA = cDefA DefB = cDefB MidA = cMidA MidB = cMidB end ------------ Labels coef -----------
local gbetdisplaycoeftbl = { [1] = {name = cgn }, [2] = {name = ces }, } ----------- Background ----------- draw.RoundedBox( 0, 00*Wss, 0*Hss, w*Wss, h, dgrey ) ----------- Left Column ----------- draw.RoundedBox( 0, 0*Wss, 0*Hss, 265*Wss, h, lgrey ) y = 0 for i = 1, 2 do draw.RoundedBox( 0, 65*Wss, 10*Hss + y, 142.5*Wss, 140*Hss, dgrey ) draw.RoundedBox( 0, 5*Wss, 155*Hss + y, 255*Wss, 65*Hss, dgrey ) y = y + 235*Hss end ----------- Middle Column ----------- draw.RoundedBox( 0, 277.5*Wss, 0*Hss, 265*Wss, h*Hss, lgrey ) y = 0 for i = 1, 6 do draw.RoundedBox( 0, 285*Wss, 5*Hss + y, 250*Wss, 70*Hss, dgrey ) y = y + 80*Hss end ----------- Buttons' design in the Middle Column ----------- y = 0 x = 0 for i = 1, 2 do draw.RoundedBox( 0, 450*Wss + x, 364*Hss + y, 70*Wss, 22.5*Hss, lgreen ) draw.RoundedBox( 0, 450*Wss+ x, 364*Hss + y, 20.5*Wss, 22.5*Hss, dgreen ) y = y + 80*Hss x = - 80*Hss end ----------- Buttons' design in the Middle Column ----------- draw.RoundedBox( 0, 555*Wss, 0*Hss, 265*Wss, h, lgrey ) y = 0 for i = 1, 7 do draw.RoundedBox( 0, 560*Wss, 5*Hss + y, 255*Wss, 40*Hss, dgrey ) y = y + 50*Hss end draw.RoundedBox( 0, 560*Wss, 355*Hss, 255*Wss, 120*Hss, dgrey ) y = 0 x = 0 for k, v in SortedPairs(gbetdisplaycoeftbl) do draw.SimpleText("G", "Font.GBET.Small.w", 455*Wss + x, 366*Hss + y, white, TEXT_ALIGN_LEFT) draw.SimpleText(v.name, "Font.GBET.Small.w", 512.5*Wss + x,366*Hss + y,white, TEXT_ALIGN_RIGHT) y = y + 80*Hss x = x - 78*Hss end y = 0 for k, v in SortedPairs(gbetsimpletexttbl) do draw.SimpleText(v.name, "Font.GBET.Small.w", 295*Wss, 15*Hss + y, white, TEXT_ALIGN_LEFT) y = y + 80*Hss end ----------- Display teams ----------- local gbetteamstbl = { [1] = {name = NameB, att = AttB, def = DefB, mid = MidB, img = ImgB}, [2] = {name = NameA, att = AttA, def = DefA, mid = MidA, img = ImgA}, } y = 0 for k, v in pairs(gbetteamstbl) do surface.SetDrawColor( 255, 255, 255, 255 ) surface.SetMaterial( Material( v.img) ) surface.DrawTexturedRect(95*Wss, 24*Hss + y, 84*Wss, 84*Hss ) draw.SimpleText(v.name, "Font.GBET.Big.w", 135*Wss,120*Hss + y, white, TEXT_ALIGN_CENTER) draw.SimpleText("ATT : "..v.att, "Font.GBET.Small.w", 15*Wss,185*Hss + y, white, TEXT_ALIGN_LEFT) draw.SimpleText("MID : "..v.mid, "Font.GBET.Small.w", 130*Wss,185*Hss + y, white, TEXT_ALIGN_CENTER) draw.SimpleText("DEF : "..v.def, "Font.GBET.Small.w", 215*Wss,185*Hss + y, white, TEXT_ALIGN_CENTER) draw.SimpleText(gbet.stats, "Font.GBET.Small.w", 15*Wss, 160*Hss + y, white, TEXT_ALIGN_LEFT) y = 235*Hss end ----------- Right Column ----------- local gbetcoeflabelstbl = { [1] = {name = bteamFcoef, lblt = gbet.fulltime..bteamFselect.." ("..bteamFcoef..")", lblf = gbet.fulltime.. " 0" }, [2] = {name = bteamhcoef, lblt = gbet.halftime..bteamhselect.." ("..bteamhcoef..")", lblf = gbet.halftime.. " 0" }, [3] = {name = bteam2scorecoef, lblt = gbet.bothteamscore..bteam2scoreselect.." ("..bteam2scorecoef..")", lblf = gbet.bothteamscore..'0' }, [4] = {name = bteamfscoef, lblt = gbet.firstteamtoscore..bteamfsselect.." ("..bteamfscoef..")", lblf = gbet.firstteamtoscore.." 0 " }, [5] = {name = bteamgncoef, lblt = gbet.goalnumber..bteamgnselect.." ("..bteamgncoef..")", lblf = gbet.goalnumber.." 0 " }, [6] = {name = bteamescoef, lblt = gbet.exactscore..bteamesselectB.."-"..bteamesselectA.." ("..bteamescoef..")",lblf = gbet.exactscore.." 0 " }, } y = 0 for k, v in SortedPairs(gbetcoeflabelstbl) do if v.name != 1 and v.name then draw.SimpleText(v.lblt, "Font.GBET.Small.w", 570*Wss, 65*Hss + y, white, TEXT_ALIGN_LEFT) else draw.SimpleText(v.lblf, "Font.GBET.Small.w", 570*Wss, 65*Hss + y, white, TEXT_ALIGN_LEFT) end y = y + 50*Hss end ----------- Valid the bet section ----------- draw.SimpleText(gbet.ticketsummary, "Font.GBET.Small.w", 570*Wss, 15*Hss, white, TEXT_ALIGN_LEFT) draw.SimpleText(delay, "Font.GBET.Small.w", 800*Wss, 15*Hss, white, TEXT_ALIGN_RIGHT) draw.SimpleText(gbet.validthebet, "Font.GBET.Small.w", 570*Wss, 360*Hss, white, TEXT_ALIGN_LEFT) if amount != nil then draw.SimpleText(gbet.bet..amount.."$", "Font.GBET.Small.w", 570*Wss, 385*Hss, white, TEXT_ALIGN_LEFT) draw.SimpleText( gbet.potentialgains..math.Round(amount*bteamgncoef*bteamescoef*bteamfscoef*bteam2scorecoef*bteamhcoef*bteamFcoef,2).."$", "Font.GBET.Small.w", 570*Wss, 405*Hss, white, TEXT_ALIGN_LEFT) else draw.SimpleText(gbet.bet.."0$", "Font.GBET.Small.w", 570*Wss, 385*Hss, white, TEXT_ALIGN_LEFT) draw.SimpleText( gbet.potentialgains.."0$ ", "Font.GBET.Small.w", 570*Wss, 405*Hss, white, TEXT_ALIGN_LEFT) end end
 
  • Initiateur de la discussion
Peugeot203

Peugeot203

Bambi
Messages
65
Score réaction
4
Points
35
Deadman69330 à dit:
Si j'utilise un timer, je ne recevrai les images etc.. qu'au bout de mon premier délais et ça va donc me créer une erreur
 
Shaar

Shaar

Geek suprême
Messages
151
Score réaction
24
Points
100
Peugeot203 à dit:
Enrichi (BBcode):
net.Receive("gbet:tbltoclient", function() gbettbl = net.ReadTable() for k, v in pairs(gbettbl) do if k == 1 then ncfN = v.cfN nchN = v.chN nces = v.ces ncgn = v.cgn ncbsy = v.cbsy ncbsn = v.cbsn ncfA = v.cfA ncfB = v.cfB nchA = v.chA nchB = v.chB ncfsA = v.cfsA ncfsB = v.cfsB nImgA = v.ImgA nImgB = v.ImgB nNameA = v.NameA nNameB = v.NameB nAttA = v.AttA nAttB = v.AttB nDefA = v.DefA nDefB = v.DefB nMidA = v.MidA nMidB = v.MidB else ccfN = v.cfN cchN = v.chN cces = v.ces ccgn = v.cgn ccbsy = v.cbsy ccbsn = v.cbsn ccfA = v.cfA ccfB = v.cfB cchA = v.chA cchB = v.chB ccfsA = v.cfsA ccfsB = v.cfsB cNameA = v.NameA cNameB = v.NameB cImgA = v.ImgA cImgB = v.ImgB cAttA = v.AttA cAttB = v.AttB cDefA = v.DefA cDefB = v.DefB cMidA = v.MidA cMidB = v.MidB end end
end)
-----------------------------------------------------
--Convert our tables for national and club matches --
-----------------------------------------------------
local teams = 1
local function soccerpart() --[[---------------------------------------------
-- Soccer function --
------------------------------------------------]]
local bteamFselect = "off"
local bteamfsselect = "off"
local bteamhselect = "off"
local bteamgnselect = "X"
local bteamesselectB = "X"
local bteamesselectA = "X"
local bteam2scoreselect = "off"
local bteamFcoef = 1
local bteamgncoef = 1
local bteamescoef = 1
local bteam2scorecoef = 1
local bteamfscoef = 1
local bteamhcoef = 1
----------- Others Labels -----------
local gbetsimpletexttbl = { [1] = {name = gbet.fulltime, }, [2] = {name = gbet.halftime }, [3] = {name = gbet.bothteamscore, }, [4] = {name = gbet.firstteamtoscore }, [5] = {name = gbet.goalnumber }, [6] = {name = gbet.exactscore }, }
------------ Labels coef -----------
local bteam = vgui.Create( "DFrame", bform) bteam:SetPos( 260*Wss, 160*Hss) bteam:SetSize( 820*Wss, 480*Hss) bteam:SetTitle( "" ) bteam:ShowCloseButton(false) bteam:SetDraggable( false ) bteam.Paint = function( p, w, h ) if teams == 1 then cfN = ncfN chN = nchN ces = nces cgn = ncgn cbsy = ncbsy cbsn = ncbsn cfA = ncfA cfB = ncfB chA = nchA chB = nchB cfsA = ncfsA cfsB = ncfsB NameA = nNameA NameB = nNameB ImgA = nImgA ImgB = nImgB AttA = nAttA AttB = nAttB DefA = nDefA DefB = nDefB MidA = nMidA MidB = nMidB else cfN = ccfN chN = cchN ces = cces cgn = ccgn cbsy = ccbsy cbsn = ccbsn cfA = ccfA cfB = ccfB chA = cchA chB = cchB cfsA = ccfsA cfsB = ccfsB NameA = cNameA NameB = cNameB ImgA = cImgA ImgB = cImgB AttA = cAttA AttB = cAttB DefA = cDefA DefB = cDefB MidA = cMidA MidB = cMidB end ------------ Labels coef -----------
local gbetdisplaycoeftbl = { [1] = {name = cgn }, [2] = {name = ces }, } ----------- Background ----------- draw.RoundedBox( 0, 00*Wss, 0*Hss, w*Wss, h, dgrey ) ----------- Left Column ----------- draw.RoundedBox( 0, 0*Wss, 0*Hss, 265*Wss, h, lgrey ) y = 0 for i = 1, 2 do draw.RoundedBox( 0, 65*Wss, 10*Hss + y, 142.5*Wss, 140*Hss, dgrey ) draw.RoundedBox( 0, 5*Wss, 155*Hss + y, 255*Wss, 65*Hss, dgrey ) y = y + 235*Hss end ----------- Middle Column ----------- draw.RoundedBox( 0, 277.5*Wss, 0*Hss, 265*Wss, h*Hss, lgrey ) y = 0 for i = 1, 6 do draw.RoundedBox( 0, 285*Wss, 5*Hss + y, 250*Wss, 70*Hss, dgrey ) y = y + 80*Hss end ----------- Buttons' design in the Middle Column ----------- y = 0 x = 0 for i = 1, 2 do draw.RoundedBox( 0, 450*Wss + x, 364*Hss + y, 70*Wss, 22.5*Hss, lgreen ) draw.RoundedBox( 0, 450*Wss+ x, 364*Hss + y, 20.5*Wss, 22.5*Hss, dgreen ) y = y + 80*Hss x = - 80*Hss end ----------- Buttons' design in the Middle Column ----------- draw.RoundedBox( 0, 555*Wss, 0*Hss, 265*Wss, h, lgrey ) y = 0 for i = 1, 7 do draw.RoundedBox( 0, 560*Wss, 5*Hss + y, 255*Wss, 40*Hss, dgrey ) y = y + 50*Hss end draw.RoundedBox( 0, 560*Wss, 355*Hss, 255*Wss, 120*Hss, dgrey ) y = 0 x = 0 for k, v in SortedPairs(gbetdisplaycoeftbl) do draw.SimpleText("G", "Font.GBET.Small.w", 455*Wss + x, 366*Hss + y, white, TEXT_ALIGN_LEFT) draw.SimpleText(v.name, "Font.GBET.Small.w", 512.5*Wss + x,366*Hss + y,white, TEXT_ALIGN_RIGHT) y = y + 80*Hss x = x - 78*Hss end y = 0 for k, v in SortedPairs(gbetsimpletexttbl) do draw.SimpleText(v.name, "Font.GBET.Small.w", 295*Wss, 15*Hss + y, white, TEXT_ALIGN_LEFT) y = y + 80*Hss end ----------- Display teams ----------- local gbetteamstbl = { [1] = {name = NameB, att = AttB, def = DefB, mid = MidB, img = ImgB}, [2] = {name = NameA, att = AttA, def = DefA, mid = MidA, img = ImgA}, } y = 0 for k, v in pairs(gbetteamstbl) do surface.SetDrawColor( 255, 255, 255, 255 ) surface.SetMaterial( Material( v.img) ) surface.DrawTexturedRect(95*Wss, 24*Hss + y, 84*Wss, 84*Hss ) draw.SimpleText(v.name, "Font.GBET.Big.w", 135*Wss,120*Hss + y, white, TEXT_ALIGN_CENTER) draw.SimpleText("ATT : "..v.att, "Font.GBET.Small.w", 15*Wss,185*Hss + y, white, TEXT_ALIGN_LEFT) draw.SimpleText("MID : "..v.mid, "Font.GBET.Small.w", 130*Wss,185*Hss + y, white, TEXT_ALIGN_CENTER) draw.SimpleText("DEF : "..v.def, "Font.GBET.Small.w", 215*Wss,185*Hss + y, white, TEXT_ALIGN_CENTER) draw.SimpleText(gbet.stats, "Font.GBET.Small.w", 15*Wss, 160*Hss + y, white, TEXT_ALIGN_LEFT) y = 235*Hss end ----------- Right Column ----------- local gbetcoeflabelstbl = { [1] = {name = bteamFcoef, lblt = gbet.fulltime..bteamFselect.." ("..bteamFcoef..")", lblf = gbet.fulltime.. " 0" }, [2] = {name = bteamhcoef, lblt = gbet.halftime..bteamhselect.." ("..bteamhcoef..")", lblf = gbet.halftime.. " 0" }, [3] = {name = bteam2scorecoef, lblt = gbet.bothteamscore..bteam2scoreselect.." ("..bteam2scorecoef..")", lblf = gbet.bothteamscore..'0' }, [4] = {name = bteamfscoef, lblt = gbet.firstteamtoscore..bteamfsselect.." ("..bteamfscoef..")", lblf = gbet.firstteamtoscore.." 0 " }, [5] = {name = bteamgncoef, lblt = gbet.goalnumber..bteamgnselect.." ("..bteamgncoef..")", lblf = gbet.goalnumber.." 0 " }, [6] = {name = bteamescoef, lblt = gbet.exactscore..bteamesselectB.."-"..bteamesselectA.." ("..bteamescoef..")",lblf = gbet.exactscore.." 0 " }, } y = 0 for k, v in SortedPairs(gbetcoeflabelstbl) do if v.name != 1 and v.name then draw.SimpleText(v.lblt, "Font.GBET.Small.w", 570*Wss, 65*Hss + y, white, TEXT_ALIGN_LEFT) else draw.SimpleText(v.lblf, "Font.GBET.Small.w", 570*Wss, 65*Hss + y, white, TEXT_ALIGN_LEFT) end y = y + 50*Hss end ----------- Valid the bet section ----------- draw.SimpleText(gbet.ticketsummary, "Font.GBET.Small.w", 570*Wss, 15*Hss, white, TEXT_ALIGN_LEFT) draw.SimpleText(delay, "Font.GBET.Small.w", 800*Wss, 15*Hss, white, TEXT_ALIGN_RIGHT) draw.SimpleText(gbet.validthebet, "Font.GBET.Small.w", 570*Wss, 360*Hss, white, TEXT_ALIGN_LEFT) if amount != nil then draw.SimpleText(gbet.bet..amount.."$", "Font.GBET.Small.w", 570*Wss, 385*Hss, white, TEXT_ALIGN_LEFT) draw.SimpleText( gbet.potentialgains..math.Round(amount*bteamgncoef*bteamescoef*bteamfscoef*bteam2scorecoef*bteamhcoef*bteamFcoef,2).."$", "Font.GBET.Small.w", 570*Wss, 405*Hss, white, TEXT_ALIGN_LEFT) else draw.SimpleText(gbet.bet.."0$", "Font.GBET.Small.w", 570*Wss, 385*Hss, white, TEXT_ALIGN_LEFT) draw.SimpleText( gbet.potentialgains.."0$ ", "Font.GBET.Small.w", 570*Wss, 405*Hss, white, TEXT_ALIGN_LEFT) end end
ta table a une structure vraiment complique pour pas grand chose et tu ne devrai pas crée de variables globale

tu peut faire ca
cfN = ncfN
chN = nchN
ces = nces
cgn = ncgn
cbsy = ncbsy
cbsn = ncbsn
cfA = ncfA
cfB = ncfB
chA = nchA
chB = nchB
cfsA = ncfsA
cfsB = ncfsB
NameA = nNameA
NameB = nNameB
ImgA = nImgA
ImgB = nImgB
AttA = nAttA
AttB = nAttB
DefA = nDefA
DefB = nDefB
MidA = nMidA
MidB = nMidB

dans le net.receive ?
 
  • Initiateur de la discussion
Peugeot203

Peugeot203

Bambi
Messages
65
Score réaction
4
Points
35
Shaar à dit:
ta table a une structure vraiment complique pour pas grand chose et tu ne devrai pas crée de variables globale

tu peut faire ca
cfN = ncfN
chN = nchN
ces = nces
cgn = ncgn
cbsy = ncbsy
cbsn = ncbsn
cfA = ncfA
cfB = ncfB
chA = nchA
chB = nchB
cfsA = ncfsA
cfsB = ncfsB
NameA = nNameA
NameB = nNameB
ImgA = nImgA
ImgB = nImgB
AttA = nAttA
AttB = nAttB
DefA = nDefA
DefB = nDefB
MidA = nMidA
MidB = nMidB

dans le net.receive ?
elles sont déjà déclarées en local précedemment je l'ai juste pas copié, et non j'ai vraiment besoin de faire comme ça ^^. mais j'ai surtout besoin de trouver un moyen de réactuliser cfn ( par exemple) toutes les 60 secondes. Sauf que la table ne se réactualise pas lorsque cfn change et donc quand j'utilise cette table pour mes bouttons j'ai la première valeur de cfn et non pas elle qui vient toutes les 60 sec
 
Discord d'entraide
Rejoignz-nous sur Discord