Witam pr?buje zrobi? ?eby da?o si? dodawa? auta do organizacji, gdy przepisuje auto ca?y czas mam komunikat ?e nie jestem w organizacji pr?bowa?em pozmienia? moj? baz? danych ale nie wychodzi.
Dobra ogarn??em to zmieniaj?c skrypt tylko ?e ma inne Element daty i gdy wychodze z serwera nie zapisuje pr?bowa?em doda?, ale na nic.
Skrypt odpowiedzialny za zapis
--[[
Resource: OURGame v2
Developers: Split <split.programista@gmail.com>
You have no right to use this code without my permission.
(c) 2015 <split.programista@gmail.com>. All rights reserved.
]]
function loadPlayerData(plr)
local result=exports["tiyl-db"]:dbGet("SELECT * FROM tiyl_gracze WHERE id=?", getElementData(plr,"player:uid"))
if result and #result > 0 then
local v=result[1]
setPlayerMoney(plr,v.money)
setElementModel(plr,v.skin)
setElementData(plr,"status","Aktywny")
setElementData(plr,"user:nickname",v.login1)
setElementData(plr,"player:logged",true)
setElementData(plr,"player:license:pjA",v.pjA)
setElementData(plr,"player:license:pjB",v.pjB)
setElementData(plr,"player:license:pjC",v.pjC)
setElementData(plr,"player:license:pjL",v.pjL)
setElementData(plr,"player:reputation",v.reputation)
setElementData(plr,"player:workinjob",v.worker)
setElementData(plr,"player:registerdate",v.registered)
setElementData(plr,"player:hours",v.hours)
setElementData(plr,"user:oranga",v.orank)
setElementData(plr,"user:org",v.org)
setElementData(plr,"p:title",v.rp_tytul)
setElementData(plr,"player:scorespedytor", v.scorespedytor)
setElementData(plr,"nanky:x",v.nankyx)
setElementData(plr,"nanky:y",v.nankyy)
setElementData(plr,"nanky:z",v.nankyz)
local queryA=string.format("SELECT * FROM tiyl_gracze WHERE id=%d AND vipdate>NOW() LIMIT 1", getElementData(plr,"player:uid"))
local resultA=exports["tiyl-db"]:pobierzWyniki(queryA)
if (resultA) then
setElementData(plr,"player:vip",true)
setElementData(plr,"player:vipdate",v.vipdate)
setPlayerName(plr,"#FFD700"..getPlayerName(plr))
else
setElementData(plr,"player:vip",false)
end
local queryA=string.format("SELECT * FROM tiyl_gracze WHERE id=%d AND svipdate>NOW() LIMIT 1", getElementData(plr,"player:uid"))
local resultA=exports["tiyl-db"]:pobierzWyniki(queryA)
if (resultA) then
setElementData(plr,"player:svip",true)
setElementData(plr,"player:svipdate",v.svipdate)
setPlayerName(plr,"#FFBF00"..getPlayerName(plr))
else
setElementData(plr,"player:svip",false)
end
setElementData(plr,"player:skin",v.skin)
local org=exports["tiyl-db"]:dbGet("SELECT * FROM tiyl_gracze WHERE org=? LIMIT 1", getElementData(plr,"player:uid")) -- pobieramy tylko JEDEN rekord
if org and #org > 0 then
setElementData(plr,"organizacja",org[1].code)
exports['tiyl-db']:dbSet("UPDATE organizacje SET actived=curdate() WHERE uid=?", getElementData(plr,"player:uid"))
end
return true
end
return false
end
function savePlayerData(plr,quitType)
local uid=getElementData(plr,"player:uid")
if not uid then return end
local money=getPlayerMoney(plr)
local reputation=getElementData(plr,"player:reputation")
local licensea=getElementData(plr,"player:license:pjA")
local licenseb=getElementData(plr,"player:license:pjB")
local licensec=getElementData(plr,"player:license:pjC")
local licensel=getElementData(plr,"player:license:pjL")
local minuty=getElementData(plr,"player:hours")
local minutyduty=getElementData(plr,"player:workinjob")
local rypy=getElementData(plr,"p:title")
local scorespedytor=getElementData(plr,"player:scorespedytor")
local x, y, z = getElementPosition(plr)
local query=exports["tiyl-db"]:dbSet("UPDATE tiyl_gracze SET money=?, reputation=?, pjA=?, pjB=?, pjC=?, pjL=?, hours=?, worker=?, rp_tytul=?, scorespedytor=?, nankyx=?, nankyy=?, nankyz=? WHERE id=?", money, reputation, licensea, licenseb, licensec, licensel, minuty, minutyduty, rypy, scorespedytor, x, y, z, uid)
if quitType then
exports["tiyl-db"]:dbSet("INSERT INTO Logi_wyjscie_serwer (uid,nick,quitType,serial,date,saved) VALUES (?,?,?,?,NOW(),?)", uid, getPlayerName(plr), quitType, getPlayerSerial(plr), "zapisano")
outputDebugString("Zapisano statystyki gracza "..getPlayerName(plr)..", pow?d wyj?cia: "..string.lower(quitType))
else
exports["tiyl-db"]:dbSet("INSERT INTO Logi_wyjscie_serwer (uid,nick,quitType,serial,date,saved) VALUES (?,?,?,?,NOW(),?)", uid, getPlayerName(plr), "brak powodu wyj?cia", getPlayerSerial(plr), "zapisano")
outputDebugString("Zapisano statystyki gracza "..getPlayerName(plr))
end
end
addEventHandler("onPlayerQuit", root, function() savePlayerData(source) end)
addEvent("antyLost", true)
addEventHandler("antyLost", root, function()
local result=exports["tiyl-db"]:dbGet("SELECT * FROM tiyl_gracze WHERE id=?", getElementData(client, "player:uid"))
if result[1].login2 == false then
setPlayerName(client,result[1].login)
else
setPlayerName(client, result[1].login2)
end
loadPlayerData(client)
end)
Oraz jak dany gracz dolacza to ca?y serwer tez P
addEvent("oDodaj", true)
addEventHandler("oDodaj", root, function(p, p2)
if not p and not p2 then return end
local graczhere = findPlayer(p, p2)
if not graczhere then
exports["np-notyfikacje"]:noti("Nie znaleziono podanego gracza.", p)
return
end
if getElementData(graczhere, "org") then
exports["np-notyfikacje"]:noti("Podany gracz posiada organizacje.", p)
return
end
exports["np-notyfikacje"]:noti("Wys?ano zaproszenie o do??czenie do organizacji graczu "..getPlayerName(graczhere), p)
setElementData(graczhere, "zaproszenie", {
["id"] = getElementData(p, "org"),
["nazwa"] = getElementData(p, "organizacja"),
["dodany"] = p,
})
outputChatBox("Otrzyma?e? zaproszenie do orgnizacji "..getElementData(p, "organizacja"), graczhere)
outputChatBox("Aby do??czy? u?yj: /dolacz "..getElementData(p, "org"), graczhere)
setTimer(function()
setElementData(graczhere, "zaproszenie", false)
end, 30000, 1)
end)
addCommandHandler("dolacz", function(player, cmd, idd)
local zaproszenie = getElementData(player, "zaproszenie")
if zaproszenie then
if not idd then
exports["np-notyfikacje"]:noti("Poprawne u?ycie: /"..cmd.." <id organizacji>", player)
return
end
outputChatBox(getPlayerName(player).." przyj?? zaproszenie do organizacji.", p)
exports["np-notyfikacje"]:noti("Przyj??e? zaproszenie do organizacji "..zaproszenie.nazwa, player)
setElementData(player, "oranga", 1)
setElementData(player, "org", zaproszenie.id)
setElementData(player, "organizacja", zaproszenie.nazwa)
exports.mysql:wykonaj("UPDATE tiyl_gracze SET org=? WHERE id=?", zaproszenie.id, getElementData(player, "id"))
setElementData(player, "zaproszenie", false)
else
exports["np-notyfikacje"]:noti("Nie posiadasz zaproszenia do organizacji.", player)
end
end)
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