Zaloguj się by uzyskać pełen dostęp. Nie masz jeszcze konta? Założ je już teraz w kilka sekund.

Wysłany: 2015-07-06, 12:13


GamerHD11







Wiek: 24
Na forum: 4402 dni
Posty: 259
Nick w MP: SzokoHD

Piwa: 23

Respekt: 50

Mam taki problem. Zrobi?em skrypt na temperatur? cia?a, wszystko git, ale gdy zrobi?em zapis tej temperatury to wog?le si? nie pokazuje dxDrawText.

P.S. Gdy robi?em to na setElementDatach itp. to si? pojawia? text lecz nie zapisywa? si?.

local x, y = guiGetScreenSize()
local nar = getTickCount()

function narastanie()
if getTickCount()-nar > 6000 then
nar = getTickCount()
local konto = getPlayerAccount(localPlayer)
local temp = getAccountData(konto, "temperatura") or 0
temp1 = temp + 0.1
setAccountData(konto, "temperatura", temp1)
end
end
addEventHandler("onClientRender", root, narastanie)

function wyswietl()
local konto = getPlayerAccount(localPlayer)
local temperatura = getAccountData(konto, "temperatura")
local temper1 = string.format("%.02f", temperatura) 
dxDrawText("Temperatura: "..temper1.." ?C ", x/1.80, y/6.5, 1209, 835, tocolor(255, 0, 0, 255), 1.00, "pricedown", "left", "top", false, false, false, false, false)  
end
addEventHandler("onClientRender", root, wyswietl)

function zapisz()
local konto = getPlayerAccount(localPlayer)
local stan = getAccountData(konto, "temperatura")
end
addEventHandler("onClientPlayerQuit", root, zapisz)

function wczytaj()
if getAccountData(konto, "temperatura") then
setAccountData(konto, "temperatura", stan)
else
setAccountData(konto, "temperatura", 36.6)
end
end
addEventHandler("onPlayerLogin", root, wczytaj)


Postaw piwo autorowi tego posta
 

 
Wysłany: 2015-07-06, 12:17


MeeShuffle

Programista/Grafik






Wiek: 33
Na forum: 4536 dni
Posty: 2758
Nick w MP: Shuffle

Piwa: 8578

Respekt: 535,3
Respekt: 535,3

accountdata dzia?a tylko po stronie s-side

Podpis

https://shufflecode.pl
Static Codes and Graphics - Join our discord!
Postaw piwo autorowi tego posta
 

 
Wysłany: 2015-07-06, 12:47


GamerHD11







Wiek: 24
Na forum: 4402 dni
Posty: 259
Nick w MP: SzokoHD

Piwa: 23

Respekt: 50

Shuffle, a jak zrobi? na elementdat? te? nie dzia?a.

local x, y = guiGetScreenSize()
local nar = getTickCount()

function narastanie()
if getTickCount()-nar > 6000 then
nar = getTickCount()
local temp = getElementData(localPlayer, "temperatura") or 0
temp1 = temp + 0.1
setElementData(localPlayer, "temperatura", temp1)
end
end
addEventHandler("onClientRender", root, narastanie)

function wyswietl()
local temperatura = getElementData(localPlayer, "temperatura")
local temper1 = string.format("%.02f", temperatura) 
dxDrawText("Temperatura: "..temper1.." ?C ", x/1.80, y/6.5, 1209, 835, tocolor(255, 0, 0, 255), 1.00, "pricedown", "left", "top", false, false, false, false, false)  
end
addEventHandler("onClientRender", root, wyswietl)

function zapisz()
local stan = getElementData(localPlayer, "temperatura")
end
addEventHandler("onClientPlayerQuit", root, zapisz)

function wczytaj()
if getElementData(localPlayer, "temperatura") then
setElementData(localPlayer, "temperatura", stan)
else
setElementData(localPlayer, "temperatura", 36.6)
end
end
addEventHandler("onPlayerLogin", root, wczytaj)


Postaw piwo autorowi tego posta
 

 
Wysłany: 2015-07-06, 12:54


piotr172







Wiek: 27
Na forum: 4558 dni
Posty: 130

Piwa: 2329

Respekt: 105,3
Respekt: 105,3

Poniewa? gdy wyjdziesz z serwera to ElemntData jest usuwana. Musia?by? zrobi? triggerServerEvent ?eby zapisywa?o temperatur? i odczytywa?o z AccountDaty.

Postaw piwo autorowi tego posta
 

 
Wysłany: 2015-07-06, 13:23


#404







Wiek: 27
Na forum: 4913 dni
Posty: 1438

Piwa: 2512

Respekt: 833,5
Respekt: 833,5Respekt: 833,5

Ostrzeżeń: 60%
Kod na zapisywanie po stronie serwer'a

function quitPlayer()
acc = getPlayerAccount(source)
setAccountData(acc, "temperatura", getElementData(source, "temperatura")
addEventHandler ( "onPlayerQuit", getRootElement(), quitPlayer )



function loginPlayer(_, konto)
if getAccountData(konto, "temperatura") then
setElementData(source, "temperatura", getAccountData(konto, "temperatura")
else
setElementData(source, "temperatura", 36.6)
end
addEventHandler ( 'onPlayerLogin', getRootElement ( ), loginPlayer)


PS Nie testowane, bo mam do u?ytku jedynie lapka...
I te 2 funkcje oczywiscie po stronie serwer'a

Postaw piwo autorowi tego posta
 

 
Wysłany: 2015-07-06, 13:57


GamerHD11







Wiek: 24
Na forum: 4402 dni
Posty: 259
Nick w MP: SzokoHD

Piwa: 23

Respekt: 50

DestroY, nie pokazuje si? text. U?y?em tego twojego kodu po stronie serwera i tego mojego po stronie clienta z getElementData i nic.

Postaw piwo autorowi tego posta
 

 
Wysłany: 2015-07-06, 14:02


#404







Wiek: 27
Na forum: 4913 dni
Posty: 1438

Piwa: 2512

Respekt: 833,5
Respekt: 833,5Respekt: 833,5

Ostrzeżeń: 60%
Je?eli co? nie dzia?a, to podaj b??dy z db3 (/debugscript 3), wtedy jest znacznie pro?ciej rozwi?za? problem...
Ca?kiem mo?liwe, ?e ja co? porypa?em bo nawet nie mam jak tego przetestowa?

Postaw piwo autorowi tego posta
 

 
Wysłany: 2015-07-06, 14:08


GamerHD11







Wiek: 24
Na forum: 4402 dni
Posty: 259
Nick w MP: SzokoHD

Piwa: 23

Respekt: 50

Prosz? :)

ERROR:MTA-Temperatura/temp.lua:2: attempt to perform 'arthimetic' on global 'nar' (a nil value)

ERROR:MTA-Temperatura/temp.lua:13: bad argument #2 to 'format' ( number expected, got boolean )

Postaw piwo autorowi tego posta
 

 
Wysłany: 2015-07-06, 14:13


piotr172







Wiek: 27
Na forum: 4558 dni
Posty: 130

Piwa: 2329

Respekt: 105,3
Respekt: 105,3


function quitPlayer()
acc = getPlayerAccount(source)
setAccountData(acc, "temperatura", getElementData(source, "temperatura"))
end
addEventHandler ( "onPlayerQuit", getRootElement(), quitPlayer )



function loginPlayer(_, konto)
if getAccountData(konto, "temperatura") then
setElementData(source, "temperatura", getAccountData(konto, "temperatura"))
else
setElementData(source, "temperatura", 36.6)
end
end
addEventHandler ( "onPlayerLogin", getRootElement ( ), loginPlayer)



Brakowa?o kilku end?w i nawias?w.

Postaw piwo autorowi tego posta
 

 
Wysłany: 2015-07-06, 14:20


luki123luki123

Place Game






Wiek: 28
Na forum: 5416 dni
Posty: 1948
Nick w MP: LuKiO

Piwa: 6103

Respekt: 611
Respekt: 611Respekt: 611

GamerHD11, onPlayerLogin po stronie client.

Postaw piwo autorowi tego posta
 

 
Wysłany: 2015-07-06, 14:21


#404







Wiek: 27
Na forum: 4913 dni
Posty: 1438

Piwa: 2512

Respekt: 833,5
Respekt: 833,5Respekt: 833,5

Ostrzeżeń: 60%
"piotr172" napisał/a:


Brakowa?o kilku end?w i nawias?w.


Ehh w?a?nie tak si? dzieje jak si? nie jest u siebie i nie odpali edytora :P


PS: Kod musisz sobie ponownie przerobi? na elementDaty :P

Postaw piwo autorowi tego posta
 

 
Wysłany: 2015-07-06, 14:24


GamerHD11







Wiek: 24
Na forum: 4402 dni
Posty: 259
Nick w MP: SzokoHD

Piwa: 23

Respekt: 50

No tego clienta przerobi?em xD

Dalej nie dzia?a :(

Postaw piwo autorowi tego posta
 

 
Wysłany: 2015-07-06, 14:29


piotr172







Wiek: 27
Na forum: 4558 dni
Posty: 130

Piwa: 2329

Respekt: 105,3
Respekt: 105,3

Strona clienta:

local x, y = guiGetScreenSize()
local nar = getTickCount() 

function narastanie()
if getTickCount()-nar > 6000 then
nar = getTickCount()
local temp = getElementData(localPlayer, "temperatura") or 0
temp1 = temp + 0.1
setElementData(localPlayer, "temperatura", temp1)
end
end
addEventHandler("onClientRender", root, narastanie)

function wyswietl()
local temperatura = getElementData(localPlayer, "temperatura")
local temper1 = string.format("%.02f", temperatura) 
dxDrawText("Temperatura: "..temper1.." ?C ", x/1.80, y/6.5, 1209, 835, tocolor(255, 0, 0, 255), 1.00, "pricedown", "left", "top", false, false, false, false, false)  
end
addEventHandler("onClientRender", root, wyswietl)


Strona servera:

function quitPlayer()
acc = getPlayerAccount(source)
setAccountData(acc, "temperatura", getElementData(source, "temperatura"))
end
addEventHandler ( "onPlayerQuit", getRootElement(), quitPlayer )



function loginPlayer(_, konto)
if getAccountData(konto, "temperatura") then
setElementData(source, "temperatura", getAccountData(konto, "temperatura"))
else
setElementData(source, "temperatura", 36.6)
end
end
addEventHandler ( "onPlayerLogin", getRootElement ( ), loginPlayer)



Testowane, u mnie dzia?a.

Postaw piwo autorowi tego posta
 

 
Wysłany: 2015-07-06, 14:37


GamerHD11







Wiek: 24
Na forum: 4402 dni
Posty: 259
Nick w MP: SzokoHD

Piwa: 23

Respekt: 50

Dzi?kuje bardzo wszystkim co mi pomagali :) :piwo: Do zamkni?cia

Postaw piwo autorowi tego posta
 

 
Tagi: temperatura
Anonymous





Na forum: 245 dni
Posty: 1



Anonymous Koniecznie zajrzyj na:






Skocz do:  
Wyświetl posty z ostatnich:   
GTAONLINE.PL » JĘZYKI PROGRAMOWANIA » LUA Ten temat jest zablokowany bez możliwości zmiany postów lub pisania odpowiedzi

Nie możesz pisać nowych tematów
Nie możesz odpowiadać w tematach
Nie możesz zmieniać swoich postów
Nie możesz usuwać swoich postów
Nie możesz głosować w ankietach
Dodaj temat do Ulubionych
Wersja do druku