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

Wysłany: 2017-07-15, 10:02


BoCzKu

Mapper & Lua






Wiek: 25
Na forum: 3606 dni
Posty: 87
Nick w MP: BoKu

Piwa: 331

Respekt: 135
Respekt: 135

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:
:piwo:
R*
:+: Rep

[ Dodano: 2017-07-16, 13:00 ]
Ref, ?pieszy mi si? :/

Postaw piwo autorowi tego posta
 

 
Wysłany: 2017-07-16, 13:31


=DC=







Wiek: 36
Na forum: 4085 dni
Posty: 223
Nick w MP: =DC=

Piwa: 72

Respekt: 150
Respekt: 150Respekt: 150

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
, jeśli Ci pomogłem postaw mi :piwo: lub R* Dzięki!

Postaw piwo autorowi tego posta
 

 
Wysłany: 2017-07-16, 13:33


BoCzKu

Mapper & Lua






Wiek: 25
Na forum: 3606 dni
Posty: 87
Nick w MP: BoKu

Piwa: 331

Respekt: 135
Respekt: 135

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?.

Podpis
Postaw piwo autorowi tego posta
 

 
Wysłany: 2017-07-16, 13:34


=DC=







Wiek: 36
Na forum: 4085 dni
Posty: 223
Nick w MP: =DC=

Piwa: 72

Respekt: 150
Respekt: 150Respekt: 150

Ale nie bardzo rozumiem o co chodzi z tym GUI, opisz dok?adniej jaki jest problem

Podpis

Witaj
, jeśli Ci pomogłem postaw mi :piwo: lub R* Dzięki!

Postaw piwo autorowi tego posta
 

 
Wysłany: 2017-07-16, 13:46


Szymczu

Programista bo tak






Wiek: 27
Na forum: 3576 dni
Posty: 194
Nick w MP: Szymczu

Piwa: 36

Respekt: 120
Respekt: 120

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


Postaw piwo autorowi tego posta
 

 
Wysłany: 2017-07-16, 13:46


BoCzKu

Mapper & Lua






Wiek: 25
Na forum: 3606 dni
Posty: 87
Nick w MP: BoKu

Piwa: 331

Respekt: 135
Respekt: 135

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

Postaw piwo autorowi tego posta
 

 
Wysłany: 2017-07-16, 14:21


amited







Wiek: 26
Na forum: 3855 dni
Posty: 1233
Nick w MP: Amited

Piwa: 512

Respekt: 466
Respekt: 466

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:
Postaw piwo autorowi tego posta
 

 
Wysłany: 2017-07-16, 15:34


=DC=







Wiek: 36
Na forum: 4085 dni
Posty: 223
Nick w MP: =DC=

Piwa: 72

Respekt: 150
Respekt: 150Respekt: 150

Czyli mowa jest ?eby zamieni? w HUDzie pobieranie pieni?dzy zamiast getPlayerMoney na exportowan? funkcj? tak?

Podpis

Witaj
, jeśli Ci pomogłem postaw mi :piwo: lub R* Dzięki!

Postaw piwo autorowi tego posta
 

 
Wysłany: 2017-07-16, 17:07


BoCzKu

Mapper & Lua






Wiek: 25
Na forum: 3606 dni
Posty: 87
Nick w MP: BoKu

Piwa: 331

Respekt: 135
Respekt: 135

Dok?adnie.

[ Dodano: 2017-07-19, 17:58 ]
@ref

[ Dodano: 2017-07-20, 18:35 ]
ref

Podpis
Postaw piwo autorowi tego posta
 

 
Tagi: pieniądze :: get :: take :: giveplayermoney
Anonymous





Na forum: 245 dni
Posty: 1



Anonymous Koniecznie zajrzyj na:






Skocz do:  
Wyświetl posty z ostatnich:   
GTAONLINE.PL » JĘZYKI PROGRAMOWANIA » LUA » Pieniądze - get,take,givePlayerMoney 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