Wysłany: 2017-07-15, 10:02
BoCzKu
Mapper & Lua
Wiek: 24 Na forum: 3465 dni Posty: 87
Nick w MP: BoKu
Piwa : 331
Witam, tak jak w temacie. Mam pewien problem i nie umiem go rozwi?za?. Chodzi o to, ?e chcia?bym zamiast "UstawKase" by?o po prostu getPlayerMoney + nawi?zanie do Bazy danych MySQL, "DodajKase", givePlayerMoney, "ZabierzKase" takePlayerMoney, i "PobierzKase"
function PobierzKase ( player )
local player = player or source
if not player then return end
local UID = getElementData ( player , "UID" )
if not UID then return end
local ACC = getAccountName ( getPlayerAccount ( player ))
if not ACC then return end
local gh = dbQuery ( DB , "SELECT * FROM Ev_Konta WHERE UID=?" , tostring ( UID ))
local result1 = dbPoll ( gh , - 1 )
dbFree ( gh )
if #result1 ~= 0 then
local q1 = dbQuery ( DB , "SELECT Kasa FROM Ev_Konta WHERE UID=?" , tostring ( UID ))
dbFree ( q1 )
return result1 [ 1 ][ 'Kasa' ]
else
local q2 = dbQuery ( DB , "INSERT INTO Ev_Konta SET UID=?, Login=?, Kasa=?, Bank=?" , UID , ACC , 0 , 0 )
dbFree ( q2 )
return 0
end
end
-----------------------------------------------------------------------------
function DodajKase ( player , Wartosc )
local player = player or source
if not player then return end
local UID = getElementData ( player , "UID" )
if not UID then return end
local ACC = getAccountName ( getPlayerAccount ( player ))
if not ACC then return end
local Bank = 0
if not Wartosc then return end
local Wartosc = tonumber ( Wartosc )
if not Wartosc then return end
local Stan = exports . Ev_MySQL : PobierzKase ( player )
local Nowy = Stan + Wartosc
setElementData ( player , "Kasa" , Nowy )
local gh = dbQuery ( DB , "SELECT * FROM Ev_Konta WHERE UID=?" , tostring ( UID ))
local result1 = dbPoll ( gh , - 1 )
if #result1 ~= 0 then
local q1 = dbQuery ( DB , "UPDATE Ev_Konta SET Kasa=? WHERE UID=?" , Nowy , tostring ( UID ))
dbFree ( q1 )
else
local q2 = dbQuery ( DB , "INSERT INTO Ev_Konta SET UID=?, Konto=?, Kasa=?, Bank=?" , UID , ACC , Nowy , Bank )
dbFree ( q2 )
end
end
--------------------------------------------------
function ZabierzKase ( player , Wartosc )
local player = player or source
if not player then return end
local UID = getElementData ( player , "UID" )
if not UID then return end
local ACC = getAccountName ( getPlayerAccount ( player ))
if not ACC then return end
local Bank = 0
if not Wartosc then return end
local Wartosc = tonumber ( Wartosc )
if not Wartosc then return end
local Stan = exports . Ev_MySQL : PobierzKase ( player )
local Nowy = Stan - Wartosc
setElementData ( player , "Kasa" , Nowy )
local gh = dbQuery ( DB , "SELECT * FROM Ev_Konta WHERE UID=?" , tostring ( UID ))
local result1 = dbPoll ( gh , - 1 )
if #result1 ~= 0 then
local q1 = dbQuery ( DB , "UPDATE Ev_Konta SET Kasa=? WHERE UID=?" , Nowy , tostring ( UID ))
dbFree ( q1 )
else
local q2 = dbQuery ( DB , "INSERT INTO Ev_Konta SET UID=?, Konto=?, Kasa=?, Bank=?" , UID , ACC , Nowy , Bank )
dbFree ( q2 )
end
end
-------------------------------------------------
function UstawKase ( player , Wartosc )
local player = player or source
if not player then return end
local UID = getElementData ( player , "UID" )
if not UID then return end
local ACC = getAccountName ( getPlayerAccount ( player ))
if not ACC then return end
local Bank = 0
if not Wartosc then return end
local Wartosc = tonumber ( Wartosc )
if not Wartosc then return end
setElementData ( player , "Kasa" , Wartosc )
local gh = dbQuery ( DB , "SELECT * FROM Ev_Konta WHERE UID=?" , tostring ( UID ))
local result1 = dbPoll ( gh , - 1 )
if #result1 ~= 0 then
local q1 = dbQuery ( DB , "UPDATE Ev_Konta SET Kasa=? WHERE UID=?" , Wartosc , tostring ( UID ))
dbFree ( q1 )
else
local q2 = dbQuery ( DB , "INSERT INTO Ev_Konta SET UID=?, Konto=?, Kasa=?, Bank=?" , UID , ACC , Wartosc , Bank )
dbFree ( q2 )
end
end
Nagradzam:
Rep
[ Dodano : 2017-07-16, 13:00 ]
Ref, ?pieszy mi si?
Wysłany: 2017-07-16, 13:31
=DC=
Wiek: 35 Na forum: 3944 dni Posty: 223
Nick w MP: =DC=
Piwa : 72
A nie prosciej bedzie wyexportowa? te funkcje i uzywa? w innych skryptach tak:
exports["nazwa_skryptu"]:PobierzKase (player)
exports["nazwa_skryptu"]:ZabierzKase (player, Wartosc)
exports["nazwa_skryptu"]:DodajKase (player, Wartosc)
wszystko po stronie server
Podpis
Witaj
[you]
, jeśli Ci pomogłem postaw mi lub Dzięki!
Wysłany: 2017-07-16, 13:33
BoCzKu
Mapper & Lua
Wiek: 24 Na forum: 3465 dni Posty: 87
Nick w MP: BoKu
Piwa : 331
Aktualnie tak mam, ale nie chodzi mi o to ?eby by?o "pro?ciej". Chce u?ywa? Standardowego GUI, lecz nie mo?na poniewa? owe GUI jest wbudowane w MTA i innaczej si? tego nie da zrobi?.
Wysłany: 2017-07-16, 13:34
=DC=
Wiek: 35 Na forum: 3944 dni Posty: 223
Nick w MP: =DC=
Piwa : 72
Ale nie bardzo rozumiem o co chodzi z tym GUI, opisz dok?adniej jaki jest problem
Podpis
Witaj
[you]
, jeśli Ci pomogłem postaw mi lub Dzięki!
Wysłany: 2017-07-16, 13:46
Szymczu
Programista bo tak
Wiek: 27 Na forum: 3435 dni Posty: 194
Nick w MP: Szymczu
Piwa : 36
Sprawd?.
function PobierzKase ( player )
local player = player or source
if not player then return end
local UID = getElementData ( player , "UID" )
if not UID then return end
local ACC = getAccountName ( getPlayerAccount ( player ))
if not ACC then return end
local gh = dbQuery ( DB , "SELECT * FROM Ev_Konta WHERE UID=?" , tostring ( UID ))
local result1 = dbPoll ( gh , - 1 )
dbFree ( gh )
if #result1 ~= 0 then
local q1 = dbQuery ( DB , "SELECT Kasa FROM Ev_Konta WHERE UID=?" , tostring ( UID ))
dbFree ( q1 )
return result1 [ 1 ][ 'Kasa' ]
else
local q2 = dbQuery ( DB , "INSERT INTO Ev_Konta SET UID=?, Login=?, Kasa=?, Bank=?" , UID , ACC , 0 , 0 )
dbFree ( q2 )
return 0
end
end
-----------------------------------------------------------------------------
function DodajKase ( player , Wartosc )
local player = player or source
if not player then return end
local UID = getElementData ( player , "UID" )
if not UID then return end
local ACC = getAccountName ( getPlayerAccount ( player ))
if not ACC then return end
local Bank = 0
if not Wartosc then return end
local Wartosc = tonumber ( Wartosc )
if not Wartosc then return end
local Stan = exports . Ev_MySQL : PobierzKase ( player )
local Nowy = Stan + Wartosc
setElementData ( player , "Kasa" , Nowy )
givePlayerMoney ( plr , tonumber ( Nowy ))
local gh = dbQuery ( DB , "SELECT * FROM Ev_Konta WHERE UID=?" , tostring ( UID ))
local result1 = dbPoll ( gh , - 1 )
if #result1 ~= 0 then
local q1 = dbQuery ( DB , "UPDATE Ev_Konta SET Kasa=? WHERE UID=?" , Nowy , tostring ( UID ))
dbFree ( q1 )
else
local q2 = dbQuery ( DB , "INSERT INTO Ev_Konta SET UID=?, Konto=?, Kasa=?, Bank=?" , UID , ACC , Nowy , Bank )
dbFree ( q2 )
end
end
--------------------------------------------------
function ZabierzKase ( player , Wartosc )
local player = player or source
if not player then return end
local UID = getElementData ( player , "UID" )
if not UID then return end
local ACC = getAccountName ( getPlayerAccount ( player ))
if not ACC then return end
local Bank = 0
if not Wartosc then return end
local Wartosc = tonumber ( Wartosc )
if not Wartosc then return end
local Stan = exports . Ev_MySQL : PobierzKase ( player )
local Nowy = Stan - Wartosc
setElementData ( player , "Kasa" , Nowy )
givePlayerMoney ( player , tonumber ( Nowy ))
local gh = dbQuery ( DB , "SELECT * FROM Ev_Konta WHERE UID=?" , tostring ( UID ))
local result1 = dbPoll ( gh , - 1 )
if #result1 ~= 0 then
local q1 = dbQuery ( DB , "UPDATE Ev_Konta SET Kasa=? WHERE UID=?" , Nowy , tostring ( UID ))
dbFree ( q1 )
else
local q2 = dbQuery ( DB , "INSERT INTO Ev_Konta SET UID=?, Konto=?, Kasa=?, Bank=?" , UID , ACC , Nowy , Bank )
dbFree ( q2 )
end
end
-------------------------------------------------
function UstawKase ( player , Wartosc )
local player = player or source
if not player then return end
local UID = getElementData ( player , "UID" )
if not UID then return end
local ACC = getAccountName ( getPlayerAccount ( player ))
if not ACC then return end
local Bank = 0
if not Wartosc then return end
local Wartosc = tonumber ( Wartosc )
if not Wartosc then return end
setElementData ( player , "Kasa" , Wartosc )
givePlayerMoney ( player , tonumber ( Wartosc ))
local gh = dbQuery ( DB , "SELECT * FROM Ev_Konta WHERE UID=?" , tostring ( UID ))
local result1 = dbPoll ( gh , - 1 )
if #result1 ~= 0 then
local q1 = dbQuery ( DB , "UPDATE Ev_Konta SET Kasa=? WHERE UID=?" , Wartosc , tostring ( UID ))
dbFree ( q1 )
else
local q2 = dbQuery ( DB , "INSERT INTO Ev_Konta SET UID=?, Konto=?, Kasa=?, Bank=?" , UID , ACC , Wartosc , Bank )
dbFree ( q2 )
end
end
Wysłany: 2017-07-16, 13:46
BoCzKu
Mapper & Lua
Wiek: 24 Na forum: 3465 dni Posty: 87
Nick w MP: BoKu
Piwa : 331
Problem jest taki, ?e chcia?bym mie? standardowe GUI od MTA.
Czyli:
Kasa
Czas
Bro?
Hp
Armor
Lecz nie mog? jego u?y? ( Kasa ) poniewa? jest to wbudowane w MTA jako getPlayerMoney, a ja mam to zrobione na "UstawKase". I chcia?bym ?eby to zamieni?.
Nie widzia?em tego @up.. Ju? sprawdzam
[ Dodano : 2017-07-16, 13:55 ]
"Szymczu" napisał/a :Sprawd?.
function PobierzKase ( player )
local player = player or source
if not player then return end
local UID = getElementData ( player , "UID" )
if not UID then return end
local ACC = getAccountName ( getPlayerAccount ( player ))
if not ACC then return end
local gh = dbQuery ( DB , "SELECT * FROM Ev_Konta WHERE UID=?" , tostring ( UID ))
local result1 = dbPoll ( gh , - 1 )
dbFree ( gh )
if #result1 ~= 0 then
local q1 = dbQuery ( DB , "SELECT Kasa FROM Ev_Konta WHERE UID=?" , tostring ( UID ))
dbFree ( q1 )
return result1 [ 1 ][ 'Kasa' ]
else
local q2 = dbQuery ( DB , "INSERT INTO Ev_Konta SET UID=?, Login=?, Kasa=?, Bank=?" , UID , ACC , 0 , 0 )
dbFree ( q2 )
return 0
end
end
-----------------------------------------------------------------------------
function DodajKase ( player , Wartosc )
local player = player or source
if not player then return end
local UID = getElementData ( player , "UID" )
if not UID then return end
local ACC = getAccountName ( getPlayerAccount ( player ))
if not ACC then return end
local Bank = 0
if not Wartosc then return end
local Wartosc = tonumber ( Wartosc )
if not Wartosc then return end
local Stan = exports . Ev_MySQL : PobierzKase ( player )
local Nowy = Stan + Wartosc
setElementData ( player , "Kasa" , Nowy )
givePlayerMoney ( plr , tonumber ( Nowy ))
local gh = dbQuery ( DB , "SELECT * FROM Ev_Konta WHERE UID=?" , tostring ( UID ))
local result1 = dbPoll ( gh , - 1 )
if #result1 ~= 0 then
local q1 = dbQuery ( DB , "UPDATE Ev_Konta SET Kasa=? WHERE UID=?" , Nowy , tostring ( UID ))
dbFree ( q1 )
else
local q2 = dbQuery ( DB , "INSERT INTO Ev_Konta SET UID=?, Konto=?, Kasa=?, Bank=?" , UID , ACC , Nowy , Bank )
dbFree ( q2 )
end
end
--------------------------------------------------
function ZabierzKase ( player , Wartosc )
local player = player or source
if not player then return end
local UID = getElementData ( player , "UID" )
if not UID then return end
local ACC = getAccountName ( getPlayerAccount ( player ))
if not ACC then return end
local Bank = 0
if not Wartosc then return end
local Wartosc = tonumber ( Wartosc )
if not Wartosc then return end
local Stan = exports . Ev_MySQL : PobierzKase ( player )
local Nowy = Stan - Wartosc
setElementData ( player , "Kasa" , Nowy )
givePlayerMoney ( player , tonumber ( Nowy ))
local gh = dbQuery ( DB , "SELECT * FROM Ev_Konta WHERE UID=?" , tostring ( UID ))
local result1 = dbPoll ( gh , - 1 )
if #result1 ~= 0 then
local q1 = dbQuery ( DB , "UPDATE Ev_Konta SET Kasa=? WHERE UID=?" , Nowy , tostring ( UID ))
dbFree ( q1 )
else
local q2 = dbQuery ( DB , "INSERT INTO Ev_Konta SET UID=?, Konto=?, Kasa=?, Bank=?" , UID , ACC , Nowy , Bank )
dbFree ( q2 )
end
end
-------------------------------------------------
function UstawKase ( player , Wartosc )
local player = player or source
if not player then return end
local UID = getElementData ( player , "UID" )
if not UID then return end
local ACC = getAccountName ( getPlayerAccount ( player ))
if not ACC then return end
local Bank = 0
if not Wartosc then return end
local Wartosc = tonumber ( Wartosc )
if not Wartosc then return end
setElementData ( player , "Kasa" , Wartosc )
givePlayerMoney ( player , tonumber ( Wartosc ))
local gh = dbQuery ( DB , "SELECT * FROM Ev_Konta WHERE UID=?" , tostring ( UID ))
local result1 = dbPoll ( gh , - 1 )
if #result1 ~= 0 then
local q1 = dbQuery ( DB , "UPDATE Ev_Konta SET Kasa=? WHERE UID=?" , Wartosc , tostring ( UID ))
dbFree ( q1 )
else
local q2 = dbQuery ( DB , "INSERT INTO Ev_Konta SET UID=?, Konto=?, Kasa=?, Bank=?" , UID , ACC , Wartosc , Bank )
dbFree ( q2 )
end
end
Nie dzia?a
Wysłany: 2017-07-16, 14:21
amited
Wiek: 26 Na forum: 3714 dni Posty: 1233
Nick w MP: Amited
Piwa : 512
powiesz mi co to jest?
local player = player or source
?
[ Dodano : 2017-07-16, 14:23 ]
I powiedz dok?adnie jak ma to wygl?da? bo ja ciebie nie rozumiem...
Podpis
"amited" napisał/a :
Wysłany: 2017-07-16, 15:34
=DC=
Wiek: 35 Na forum: 3944 dni Posty: 223
Nick w MP: =DC=
Piwa : 72
Czyli mowa jest ?eby zamieni? w HUDzie pobieranie pieni?dzy zamiast getPlayerMoney na exportowan? funkcj? tak?
Podpis
Witaj
[you]
, jeśli Ci pomogłem postaw mi lub Dzięki!
Wysłany: 2017-07-16, 17:07
BoCzKu
Mapper & Lua
Wiek: 24 Na forum: 3465 dni Posty: 87
Nick w MP: BoKu
Piwa : 331
Dok?adnie.
[ Dodano : 2017-07-19, 17:58 ]
@ref
[ Dodano : 2017-07-20, 18:35 ]
ref
Tagi: pieniądze :: get :: take :: giveplayermoney
Anonymous
Na forum: 245 dni
Posty: 1
Anonymous Koniecznie zajrzyj na: