Wysłany: 2014-11-19, 17:53
flimbo123
Wiek: 33 Na forum: 5776 dni Posty: 93
Nick w MP: Flimbo
Piwa : 190
Tak jak powy?ej, mam skrypt na towary jednak nie wiadomo ile gracz ma score poniewa? tabelka nie wy?wietla ?ADNEJ liczby.
Wysłany: 2014-11-19, 17:58
MeeShuffle
Programista/Grafik
Wiek: 32 Na forum: 4395 dni Posty: 2758
Nick w MP: Shuffle
Piwa : 8575
Wysłany: 2014-11-19, 18:12
flimbo123
Wiek: 33 Na forum: 5776 dni Posty: 93
Nick w MP: Flimbo
Piwa : 190
Zapodaje fragment kodu, bo wszystko inne dzia?a OK
Server:
Kod: (getResourceFromName("scoreboard"), "addScoreboardColumn", "Score")
Okrojony Client:
Kod: GUIEditor_Progress = {}
GUIEditor_Button = {}
GUIEditor_Label = {}
GUIEditor_Grid = {}
gui =
{
window = {},
scrool = {},
tabpanel = {},
tab = {}
}
tow =
{
towary = { },
last =
{
select = false,
text = "",
grupa = "",
},
grupa = {},
labelRed = { },
przesylki = {}
}
timer = { }
praca = { }
kolu = { }
cache = {}
local v = "v1.5"
local x,y = guiGetScreenSize()
local outputokienko = false
local span =
else
return
end
guiSetVisible(gui.window[2],false)
end
end
function open_praca_rpg(admin,id,towarytable)
if pojazdDostawczy(getLocalPlayer()) or pojazdZNaczepa(getLocalPlayer()) then
guiSetVisible(gui.window[1],true)
guiSetVisible(GUIEditor_Label[1],admin)
guiSetVisible(GUIEditor_Label[2],admin)
guiSetText(GUIEditor_Label[1],"ID: "..id)
cache.marid = id
cache.towtable = towarytable
showCursor(true)
else
error("Tw?j pojazd nie jest pojadem dostawczym,lub nie posiadasz naczepy.")
end
end
function pojazdDostawczy(a)
local v = getPedOccupiedVehicle(a)
if v then
if getElementModel(v) == tonumber(499) or getElementModel(v) == tonumber(482) or getElementModel(v) == tonumber(498) or getElementModel(v) == tonumber(609) or getElementModel(v) == tonumber(455) or getElementModel(v) == tonumber(440) or getElementModel(v) == tonumber(459) or getElementModel(v) == tonumber(456) then
return true
end
end
return false
end
function pojazdZNaczepa(a)
local car = getPedOccupiedVehicle(a)
if car then
for k,v in ipairs(getElementsByType("vehicle",getRootElement())) do
if getElementModel(v) == tonumber(435) or getElementModel(v) == tonumber(450) or getElementModel(v) == tonumber(584) or getElementModel(v) == tonumber(591) then
if getVehicleTowingVehicle(v) == car then
return true
end
end
end
end
return false
end
function update_task (a,b,c,d)
guiSetVisible(gui.window[1],false)
guiSetVisible(gui.tabpanel[1],false)
guiSetVisible(gui.window[3],true)
local prog = guiProgressBarGetProgress(GUIEditor_Progress[1])
guiSetText(gui.window[3],b)
setElementData(gui.window[3],"type",c)
setElementData(gui.window[3],"names",d)
guiProgressBarSetProgress(GUIEditor_Progress[1],prog + tonumber(a))
if prog >= 100 then
if isTimer(timer[1]) then
killTimer(timer[1])
end
end
end
function close_praca()
guiSetVisible(gui.window[1],false)
guiSetVisible(gui.tabpanel[1],false)
guiSetVisible(gui.window[2],false)
guiSetVisible(gui.window[3],false)
showCursor(false)
for k,v in ipairs(getElementChildren(gui.scrool[1])) do
destroyElement(v)
end
tow.last.text = ""
tow.labelRed = {}
tow.towary = { }
tow.last.select = false
end
function wymaganeScore(app)
return tonumber(tow.przesylki[app].score) or tonumber(0)
end
function checkTimerToColor(timer)
if getMissionTimerTime(timer) == tonumber(0) then
return "Mozesz rozladowac",0,255,0
else
return "Nie mozesz rozladowac",255,0,0
end
end
function getTimerCzas(timer)
return getMissionTimerTime(timer)
end
function button_1()
local praca = getElementData(getLocalPlayer(), "praca")
if praca["jest"] == false then
guiSetVisible(gui.tabpanel[1],true)
guiBringToFront(gui.tabpanel[1])
local loadStart = getTickCount ()
if table.size(tow.towary) == 0 then
createTowary()
end
guiSetText(GUIEditor_Label[3],"Czas ladowania: "..(getTickCount ()-loadStart)/1000)
guiSetText(GUIEditor_Label[2],"Liczba towarow: "..table.size(tow.towary))
else
error("Posiadasz juz paczke")
end
end
function iniciateZapisData()
local mar = getMarkerByID(cache.marid)
for num,data in ipairs(split(cache.towtable,',')) do
setElementData(mar,"towar_"..tostring(data['towarName']),tonumber(data['wartosc']))
end
end
function createTowary()
iniciateZapisData()
local up = 1
for l,a in ipairs(split(getDane("zal"),',')) do
local lab = guiCreateLabel(10, 5+(up*20), 700, 30, a.."\n"..span, false, gui.scrool[1])
guiLabelSetColor (lab, 0,255,100)
up = up+2
for i,v in ipairs(tow.grupa[a]) do
local labelname = guiCreateLabel(50, 5+(up*20), 150, 15, v[1], false, gui.scrool[1])
local labelscore = guiCreateLabel(250, 5+(up*20), 70, 15, v[2], false, gui.scrool[1])
local podkladimage = guiCreateStaticImage(300, 5+(up*20), 200, 15, "image/capture_bg.png", false, gui.scrool[1])
local minlabel = guiCreateLabel(530, 5+(up*20), 70, 15, v[3], false, gui.scrool[1])
local maxlabel = guiCreateLabel(630, 5+(up*20), 70, 15, v[4], false, gui.scrool[1])
tow.towary[v[1]] =
{
labelname,
labelscore,
podkladimage,
minlabel,
maxlabel,
v[5],
a
}
setElementSource(labelname,labelname)
setElementSource(labelscore,labelname)
setElementSource(minlabel,labelname)
setElementSource(maxlabel,labelname)
local postepbar = guiCreateStaticImage(300, 5+(up*20), 0, 15, "image/capture.png", false, gui.scrool[1])
local mar = getMarkerByID(cache.marid)
if mar then
local data = getElementData(mar,"towar_"..tostring(v[1]))
if tonumber(data) then
setProggesPasek(postepbar,data)
else
setProggesPasek(postepbar,100)
setElementData(mar,"towar_"..tostring(v[1]),100)
end
end
if tonumber(v[2]) > getClientPlayerScore() then
guiSetAlpha(labelname,0.5)
guiSetAlpha(labelscore,0.5)
guiSetAlpha(podkladimage,0.5)
guiSetAlpha(minlabel,0.5)
guiSetAlpha(maxlabel,0.5)
guiSetAlpha(postepbar,0.5)
end
up = up+1
end
end
end
function setElementSource(element,elementtosource)
return setElementData(element,"source_Element",elementtosource)
end
function getElementSource(element)
return getElementData(element,"source_Element")
end
function setProggesPasek(ele,postep)
guiSetSize (ele, tonumber(postep)*2, 15, false )
end
function getDane(typ)
for a,marker in ipairs(getElementsByType("marker",getResourceRootElement(getThisResource()))) do
if getElementData(marker,"id") == cache.marid then
return getElementData(marker,typ)
end
end
return false
end
function getMarkerByID(id)
for a,marker in ipairs(getElementsByType("marker",getResourceRootElement(getThisResource()))) do
if getElementData(marker,"id") == id then
return marker
end
end
return false
end
function bliskoMiejsce(id)
for a,marker in ipairs(getElementsByType("marker",getResourceRootElement(getThisResource()))) do
if getElementData(marker,"id") == id then
local a,b,c = getElementPosition(getLocalPlayer())
local d,e,f = getElementPosition(marker)
if getDistanceBetweenPoints3D(a,b,c,d,e,f) < 10 then
return getElementData(marker,"id")
end
end
end
return false
end
function error(string)
if outputokienko then
triggerEvent("createcustom", getLocalPlayer(),string)
else
outputChatBox(string,255,0,0)
end
end
function button_2()
local praca = getElementData(getLocalPlayer(), "praca")
if praca["jest"] == true then
if getTimerCzas(praca.time) == tonumber(0) then
if bliskoMiejsce(praca.markerid) then
update_task (0,"Rozladuj "..praca.towar,"roz","")
timer[1] = setTimer(update_task,100,0,getTimerFromZadanie(praca.towar),"Rozladuj "..praca.towar,"roz","")
else
error("To nie jest twoje miejsce rozladowania")
end
else
error("Nie mozesz jeszcze rozladowac")
end
else
error("Nie masz towaru do rozladowania")
end
end
function button_7()
close_praca()
if isTimer(timer[1]) then
killTimer(timer[1])
end
guiProgressBarSetProgress(GUIEditor_Progress[1],tonumber(0))
end
function getWynagrodzenie(app)
return tonumber(tow.przesylki[app].min) or tonumber(0), tonumber(tow.przesylki[app].max) or tonumber(5000)
end
function button_5()
guiSetVisible(gui.tabpanel[1],false)
guiBringToFront(gui.window[1])
end
function getMiejsceDostarcz()
local i = 0
miejsce_marker = nil
miejsce_marker = { }
for a,marker in ipairs(getElementsByType("marker",getResourceRootElement(getThisResource()))) do
local dane = getElementData(marker,"roz")
if string.find(dane,tow.last.grupa) then
local x,y,z = getElementPosition(getLocalPlayer())
local x1,y1,z1 = getElementPosition(marker)
if getZoneName (x,y,z,true) ~= getZoneName (x1,y1,z1,true) then
if i == 0 then i = 1 end
miejsce_marker[i] = { }
miejsce_marker[i].id = getElementData(marker,"id")
miejsce_marker[i].elem = marker
i = i + 1
end
end
end
if i ~= 0 then
local sp = math.random(1,i)
--outputChatBox(i.." "..sp.." "..miejsce_marker[sp].id)
return miejsce_marker[sp].id , miejsce_marker[sp].elem
end
return false
end
function getTimerFromZadanie(app)
return tonumber(tow.przesylki[app].pas*ifElse(isVip(),2,1)) or false
end
function button_4()
local nazwa = tostring(tow.last.text)
if nazwa ~= "" then
local wym = wymaganeScore(nazwa)
if wym <= getClientPlayerScore() then
local a = getTimerFromZadanie(nazwa)
if a then
update_task (0,"Zaladuj "..nazwa,"zal",nazwa)
timer[1] = setTimer(update_task,100,0,a,"Zaladuj "..nazwa,"zal",nazwa)
else
error("Blad skryptu!, \nDane dla administratora(nalezy zglosic adminowi!): Linijka: 398, Powod bledu: Brak czasu zadania")
end
else
error("Nie masz wymaganego Score by wziasc ten towar. By wziasc towar: "..nazwa.." potrzeba: "..wym.." Score")
end
else
error("Zaznacz Towar")
end
end
function zaladujRPG(names)
if names then
local a,c = getMiejsceDostarcz()
local posx,posy,posz = getElementPosition(c)
praca.jest = true
praca.towar = names
praca.time = createMissionTimer(60000*getTimeZadanie(name)/ifElse(isVip(),2,1),true,true,x-120,y-144,false,"default-bold",1)
praca.blip = createBlipAttachedTo (c, 41, 2, 255, 0, 0, 255, 0, 9999 )
praca.model = getElementModel(getPedOccupiedVehicle(getLocalPlayer()))
praca.markerid = a
setElementData(getLocalPlayer(),"praca",praca)
close_praca()
local mar = getMarkerByID(cache.marid)
local aktualstan = getElementData(mar,"towar_"..tostring(names))-1
setElementData(mar,"towar_"..tostring(names),aktualstan)
outputChatBox("Zaladowano pomyslnie: "..names..". Towar dostarcz do: "..getZoneName (posx,posy,posz).. " (" ..getZoneName (posx,posy,posz,true).. ")",0,255,0)
return true
end
return false
end
function button_6()
if guiProgressBarGetProgress(GUIEditor_Progress[1]) >= tonumber(100) then
local type = getElementData(gui.window[3],"type")
if type == "zal" then
if zaladujRPG(getElementData(gui.window[3],"names")) then
if guiProgressBarGetProgress(GUIEditor_Progress[1]) >= 100 then
if isTimer(timer[1]) then
killTimer(timer[1])
end
end
end
guiProgressBarSetProgress(GUIEditor_Progress[1],tonumber(0))
elseif type == "roz" then
if rozladujRPG() then
if guiProgressBarGetProgress(GUIEditor_Progress[1]) >= 100 then
if isTimer(timer[1]) then
killTimer(timer[1])
end
end
end
guiProgressBarSetProgress(GUIEditor_Progress[1],tonumber(0))
else
error("Blad skryptu!,\nDane dla administratora(nalezy zglosic adminowi!): nieznany typ")
end
else
error("Twoj pasek zaladowania/rozladowania nie jest jeszcze pelny!")
end
end
function rozladujRPG()
player = getLocalPlayer()
local praca = getElementData(getLocalPlayer(),"praca")
local min,max = getWynagrodzenie(praca.towar)
local wynagrodzenie = math.random(min,max)
giveGraczMoney(wynagrodzenie)
destroyElement(praca.blip)
destroyElement(praca.time)
local scoretoadd = 1
if isVip() then
local num = math.random(1,5)
if num == 2 then
scoretoadd = 2
end
end
setClientPlayerScore(getClientPlayerScore() + tonumber(scoretoadd))
guiSetText(GUIEditor_Label[4],"Dostarczono "..praca.towar.." za "..wynagrodzenie.."$ i "..scoretoadd.." score")
triggerServerEvent ("ZapiszLadunek_False", getLocalPlayer(),player)
guiSetVisible(gui.window[3],false)
guiSetVisible(gui.window[2],true)
tow.last.dostarczone = praca.towar
praca.jest = false
praca.towar = nil
praca.time = nil
praca.model = nil
praca.blip = nil
praca.markerid = nil
local mar = getMarkerByID(cache.marid)
if mar then
local data = getElementData(mar,"towar_"..tostring(names))
if data then
if data + 1 <= 100 then
setElementData(mar,"towar_"..tostring(names),data+1)
end
end
end
setElementData(getLocalPlayer(),"praca",praca)
--close_praca()
return true
end
function isVip()
return getElementData(getLocalPlayer(),"rpgvip")
end
function getClientPlayerScore()
local score = getElementData(getLocalPlayer(),"Score")
if tonumber(score) then
return tonumber(score)
end
return tonumber(0)
end
function setClientPlayerScore(data)
local score = getElementData(getLocalPlayer(),"Score")
if tonumber(score) then
if setElementData(getLocalPlayer(),"Score",data) then
return true
end
end
return false
end
Wysłany: 2014-11-19, 18:52
MeeShuffle
Programista/Grafik
Wiek: 32 Na forum: 4395 dni Posty: 2758
Nick w MP: Shuffle
Piwa : 8575
Okrojony? Daj funkcj?, kt?ra odpowiada za score.
Wysłany: 2014-11-19, 19:37
flimbo123
Wiek: 33 Na forum: 5776 dni Posty: 93
Nick w MP: Flimbo
Piwa : 190
Funkcjii score nie wycialem, usunalem tylko czesc elementow GUI abym mogl wyslac post (limit 15000 znakow)
Wysłany: 2014-11-19, 19:43
MeeShuffle
Programista/Grafik
Wiek: 32 Na forum: 4395 dni Posty: 2758
Nick w MP: Shuffle
Piwa : 8575
Nie b?d? analizowa? tak d?ugiego kodu, daj odpowiedni? funkcj? do pytania, wtedy Ci pomog?.
Wysłany: 2014-11-19, 22:24
Blur
Wiek: 28 Na forum: 4298 dni Posty: 47
Nick w MP: Blu
Piwa : 2
Zapomnia?es o call :v
call(getResourceFromName("scoreboard"), "addScoreboardColumn", "Score")
Wysłany: 2014-11-20, 08:34
markob0
Wiek: 27 Na forum: 4248 dni Posty: 151
Nick w MP: Markob
Piwa : 939
Blur , ale w wersji s-side poda? funkcje na tworzenie kolumny.
Wysłany: 2014-11-20, 10:01
Blur
Wiek: 28 Na forum: 4298 dni Posty: 47
Nick w MP: Blu
Piwa : 2
markob0 , poda?, ale bez call. Mo?e by? to jednym z problem?w.
Je?li nie jest to to, to albo jego skrypt odpowiadaj?cy za zapis nie dzia?a albo dodawanie. Wydaje mi si? ?e skrypt nie dzia?a dla tego ?e w logowaniu/rejestracji nie ma deklarowania "Score", dla gracza. Czyli pokazuje si? tabelka a nie ma tam ?adnej liczby, czyli gracz nie ma ElementDaty("Score"). Gdy skrypt, po roz?adowaniu towaru chce mu doda? punkty, nie mo?e sprawdzi? aktualnej liczby poniewa? takowa nie istnieje.
Wysłany: 2014-11-20, 14:53
flimbo123
Wiek: 33 Na forum: 5776 dni Posty: 93
Nick w MP: Flimbo
Piwa : 190
Sprecyzuje troszeczke
Kolumna sie pojawia, i normalnie jak wchodze na server powinno byc tam 0, a nie ma nic, ani zera ani jedynki poprostu puste miejsce.
Wysłany: 2014-11-20, 15:12
Blur
Wiek: 28 Na forum: 4298 dni Posty: 47
Nick w MP: Blu
Piwa : 2
Napisa?em ci wy?ej dlaczego. Masz jaki? panel logowania/rejestracji ?
Wysłany: 2014-11-20, 15:17
flimbo123
Wiek: 33 Na forum: 5776 dni Posty: 93
Nick w MP: Flimbo
Piwa : 190
Nie nie mam, skrypt zapisujacy staty nie ma prawa kolidowa? bo go te? nie ma
PS. jest Call
Wysłany: 2014-11-20, 16:14
Blur
Wiek: 28 Na forum: 4298 dni Posty: 47
Nick w MP: Blu
Piwa : 2
Zr?b skrypt, kt?ry nadaje date "Score". Np:
function dajScore ( gracz )
if not getElementData ( gracz , "Score" ) then
setElementData ( gracz , "Score" , 0 )
end
addCommandHandler ( "scoredaj" , dajScore )
Tagi: tabelka :: quotscorequot :: nie :: pokazuje :: liczby
Anonymous
Na forum: 245 dni
Posty: 1
Anonymous Koniecznie zajrzyj na: