Witam wszystkie osoby tu zebrane, chcia?bym otrzyma? pomoc w sprawie skryptu na salon. Skrypt powinien pokazywa?, ?e kto? nie ma tyle PLN, gdy kto? nie ma Z? i ?e zakupi? pojazd, ale ?adna z tych informacji si? nie pojawia. W DB3 tylko taki b??d: https://i.imgur.com/XYl1hEV.png
Kod z linijki 22 z b??du:
Teraz ?adnego b??du niema. Powracaj?c do drugiej sprawy dlaczego nie pojawia mi si? informacje ?e zakupi?em auto albo ?e nie mam wystarczaj?ca pieni?dzy. ?adnego DB3 nie ma.
Podpis
Jeśli nie możesz czegoś zrobić dobrze, przynajmniej spraw, żeby wyglądało dobrze.
tekst si? wy?wietla. Jest to dziwne poniewa? notyfikacje wsz?dzie dzia?aj? tylko nie tu.
Kod na robienie notyfikacji przez RCON: To dzia?a
addCommandHandler("notification", function(plr,cmd,tyr,...)
if getAdmin(plr,3) or getAdmin(plr,4) then
if not ... or not tyr then triggerClientEvent(plr,"addNotification",root,"Wpisz /notification [error/success/warning/info] (tekst) ","error") return end
local text=table.concat({...}, " ")
for _, p in pairs(getElementsByType('player')) do
triggerClientEvent(p,"addNotificatione",root,text,tyr)
end
end
end)
Kod tworzenia notyfikacji przy kupnie auta: To ju? nie dzia?a
addCommandHandler('kuppojazd', function(plr, cmd)
local data=plr:getData('vehsell:info')
if not data then return end
if getPlayerMoney(plr) < data.cost then
triggerClientEvent(plr,"addNotification",root,"Nie posiadasz wystarczajacej kwoty pieni?dzy!","error")
return
end
local vehicle=plr:getOccupiedVehicle()
if vehicle then
removePedFromVehicle(vehicle)
end
local cost=data.cost
local model=data.model
local mileage=data.mileage
local uid=getElementData(plr,'player:uid') or 0
takePlayerMoney(plr, cost)
if mileage <= 2000 then
exports["ogrpg-db"]:dbSet("INSERT INTO ogrpg_vehicles (model,ownedPlayer,mileage,registered,parking) VALUES (?,?,?,?,1)", model, getElementData(plr,"player:uid"),mileage,"false")
else
exports["ogrpg-db"]:dbSet("INSERT INTO ogrpg_vehicles (model,ownedPlayer,mileage,registered,parking) VALUES (?,?,?,?,1)", model, getElementData(plr,"player:uid"),mileage,"true")
end
triggerClientEvent(plr,"addNotification",root,string.format("Zakupi?e? sw?j pojazd "..getVehicleNameFromModel(model)..", znajdziesz go w przechowywalni."),"info")
end)
local cFunc={}
local cSetting={}
NTSClient={}
NTSClient.__index=NTSClient
--
addEvent('onClientAddNotification', true)
--
-- send to client - triggerClientEvent(player, 'onClientAddNotification', player, text, 'type')
-- send to all clients - triggerClientEvent(root, 'onClientAddNotification', root, text, 'type')
function NTSClient:new(...)
local obj=setmetatable({}, {__index=self})
if obj.constructor then
obj:constructor(...)
end
return obj
end
function NTSClient:render()
local now = getTickCount()
if now >= self.tick then
self.tick = getTickCount()+20
self.count = self.count-2
end
local bg_x, bg_y=937, 186
local x=self.sx/2-(bg_x/self.zoom)/2
if self.count==20 and self.nts[1] then
self.fadeOut=self.nts[1]
table.remove(self.nts, 1)
end
if self.count<=20 and self.count>0 then
self.pos_y=6/self.zoom+self.count/self.zoom
self.posTXT_y=4/self.zoom+self.count/self.zoom
elseif self.count==0 then
self.pos_y=6/self.zoom
self.posTXT_y=4/self.zoom
self.count=280
end
if self.fadeOut then
self.fadeOut.alpha=math.max(self.fadeOut.alpha-0.05, 0)
dxDrawImage(x, self.pos_y, bg_x/self.zoom, bg_y/self.zoom, self.textures[tostring(self.fadeOut.type)], 0, 0, 0, tocolor(255, 255, 255, 255*self.fadeOut.alpha), true)
dxDrawText(self.fadeOut.msg, x+(bg_x/6.25/self.zoom), self.posTXT_y, x+(bg_x/7/self.zoom)+bg_x/self.zoom-bg_x/5/self.zoom, self.posTXT_y+(bg_y/self.zoom), tocolor(255, 255, 255, 255*self.fadeOut.alpha), 0.5, self.font1, 'center', 'center', true, true, true)
if self.fadeOut.alpha==0 then
self.fadeOut=nil
end
end
for i,v in pairs(self.nts) do
if i>3 then return end
v.alpha=math.min(v.alpha+0.05, 1)
dxDrawImage(x, self.pos_y+((i-1)*150)/self.zoom, bg_x/self.zoom, bg_y/self.zoom, self.textures[tostring(v.type)], 0, 0, 0, tocolor(255, 255, 255, 255*v.alpha), true)
dxDrawText(v.msg, x+(bg_x/6.25/self.zoom), self.posTXT_y+((i-1)*150)/self.zoom, x+(bg_x/7/self.zoom)+bg_x/self.zoom-bg_x/5/self.zoom, self.posTXT_y+(bg_y/self.zoom)+((i-1)*150)/self.zoom, tocolor(255, 255, 255, 255*v.alpha), 0.5, self.font1, 'center', 'center', true, true, true)
end
end
function NTSClient:add(msg, type)
if #self.nts==0 then
self.count=280
end
outputConsole("["..string.upper(type).."] "..msg)
table.insert(self.nts, {
msg=msg,
type=type,
alpha=0,
tick=getTickCount()
})
-- ZAKOMENTOWANO DO STARTU SERWERA!
local snd=playSound('s/' ..type.. '.mp3')
setSoundVolume(snd, 0.3)
end
function NTSClient:onAddNTS(data, type)
if not data then return end
if not type then return end
NTSClass:add(data, type)
end
-- wywolywanie klasy
function NTSClient:constructor(...)
self.count=280
self.fadeOut=nil
self.nts={}
local sx,sy=guiGetScreenSize()
self.sx, self.sy=sx, sy
self.zoom=2.4
self.lu_start=getTickCount()
self.pos_y, self.posTXT_y=6/self.zoom, 4/self.zoom
-- notifications textures
self.textures={
['warning']=dxCreateTexture('i/nts_warning.png', 'dxt5', false, 'wrap'),
['error']=dxCreateTexture('i/nts_error.png', 'dxt5', false, 'wrap'),
['success']=dxCreateTexture('i/nts_success.png', 'dxt5', false, 'wrap'),
['info']=dxCreateTexture('i/nts_info.png', 'dxt5', false, 'wrap'),
}
--
-- font
self.font=dxCreateFont('f/myriad_prop.ttf', 20)
self.font1=dxCreateFont('f/archivo_narrow.ttf', 20)
--
self.funcAddNTS=function(data, type) self:onAddNTS(data, type) end
addEventHandler('onClientAddNotification', root, self.funcAddNTS)
self.renderFunc=function() self:render() end
addEventHandler('onClientRender', root, self.renderFunc)
self.tick = 10
--outputDebugString('[calling] NTSClient: constructor')
end
NTSClass=NTSClient:new()
2 System:
local displayWidth, displayHeight = guiGetScreenSize();
local notificationData = {};
local notificationFont = dxCreateFont('files/fonts/roboto.ttf', 12 * 2, false);
local iconsFont = dxCreateFont('files/fonts/icons.ttf', 12 * 2, false);
addEventHandler('onClientRender', root,
function()
for k, v in pairs(notificationData) do
if (v.State == 'fadeIn') then
local alphaProgress = (getTickCount() - v.AlphaTick) / 650;
local alphaAnimation = interpolateBetween(0, 0, 0, 255, 0, 0, alphaProgress, 'Linear');
if (alphaAnimation) then
v.Alpha = alphaAnimation;
else
v.Alpha = 255;
end
if (alphaProgress > 1) then
v.Tick = getTickCount();
v.State = 'openTile';
end
elseif (v.State == 'fadeOut') then
local alphaProgress = (getTickCount() - v.AlphaTick) / 650;
local alphaAnimation = interpolateBetween(255, 0, 0, 0, 0, 0, alphaProgress, 'Linear');
if (alphaAnimation) then
v.Alpha = alphaAnimation;
else
v.Alpha = 0;
end
if (alphaProgress > 1) then
notificationData = {};
end
elseif (v.State == 'openTile') then
local tileProgress = (getTickCount() - v.Tick) / 350;
local tilePosition = interpolateBetween(v.StartX, 0, 0, v.EndX, 0, 0, tileProgress, 'Linear');
local tileWidth = interpolateBetween(0, 0, 0, v.Width, 0, 0, tileProgress, 'Linear');
if (tilePosition and tileWidth) then
v.CurrentX = tilePosition;
v.CurrentWidth = tileWidth;
else
v.CurrentX = v.EndX;
v.CurrentWidth = v.Width;
end
if (tileProgress > 1) then
v.State = 'fixTile';
setTimer(function()
v.Tick = getTickCount();
v.State = 'closeTile';
end, string.len(v.Text) * 45 + 5000, 1);
end
elseif (v.State == 'closeTile') then
local tileProgress = (getTickCount() - v.Tick) / 350;
local tilePosition = interpolateBetween(v.EndX, 0, 0, v.StartX, 0, 0, tileProgress, 'Linear');
local tileWidth = interpolateBetween(v.Width, 0, 0, 0, 0, 0, tileProgress, 'Linear');
if (tilePosition and tileWidth) then
v.CurrentX = tilePosition;
v.CurrentWidth = tileWidth;
else
v.CurrentX = v.StartX;
v.CurrentWidth = 0;
end
if (tileProgress > 1) then
v.AlphaTick = getTickCount();
v.State = 'fadeOut';
end
elseif (v.State == 'fixTile') then
v.Alpha = 255;
v.CurrentX = v.EndX;
v.CurrentWidth = v.Width;
end
roundedRectangle(v.CurrentX, 20, 25 + v.CurrentWidth, 25, tocolor(0, 0, 0, 150 * v.Alpha / 255), _, true);
dxDrawRectangle(v.CurrentX, 20, 25, 25, tocolor(0, 0, 0, 255 * v.Alpha / 255), true);
if (v.Alpha == 255) then
dxDrawText(v.Text, v.CurrentX + 25 + 10, 20, v.CurrentX + 25 + 10 + v.CurrentWidth - 20, 20 + 25, tocolor(255, 255, 255, 255), 0.40, notificationFont, 'center', 'center', true, false, true);
end
if (v.Type == 'error') then
dxDrawText('', v.CurrentX + 5, 20, v.CurrentX + 5 + 25 - 10, 20 + 25, tocolor(215, 90, 90, v.Alpha), 0.50, iconsFont, 'center', 'center', false, false, true);
elseif (v.Type == 'warning') then
dxDrawText('', v.CurrentX + 5, 20, v.CurrentX + 5 + 25 - 10, 20 + 25, tocolor(220, 180, 80, v.Alpha), 0.50, iconsFont, 'center', 'center', false, false, true);
elseif (v.Type == 'info') then
dxDrawText('', v.CurrentX + 5, 20, v.CurrentX + 5 + 25 - 10, 20 + 25, tocolor(85, 180, 245, v.Alpha), 0.50, iconsFont, 'center', 'center', false, false, true);
elseif (v.Type == 'success') then
dxDrawText('', v.CurrentX + 5, 20, v.CurrentX + 5 + 25 - 10, 20 + 25, tocolor(80, 205, 105, v.Alpha), 0.50, iconsFont, 'center', 'center', false, false, true);
end
end
end
)
function addNotification(text, type)
if (text and type) then
if (notificationData ~= nil) then
table.remove(notificationData, #notificationData);
end
table.insert(notificationData,
{
StartX = (displayWidth / 2) - (25 / 2),
EndX = (displayWidth / 2) - ((dxGetTextWidth(text, 0.40, notificationFont) + 20 + 25) / 2),
Text = text,
Width = dxGetTextWidth(text, 0.40, notificationFont) + 20,
Alpha = 0,
State = 'fadeIn',
Tick = 0,
AlphaTick = getTickCount(),
CurrentX = (displayWidth / 2) - (25 / 2),
CurrentWidth = 0,
Type = type or 'info'
}
);
playSoundFrontEnd(11);
end
end
function roundedRectangle(x, y, w, h, borderColor, bgColor, postGUI)
if (x and y and w and h) then
if (not borderColor) then
borderColor = tocolor(0, 0, 0, 200);
end
if (not bgColor) then
bgColor = borderColor;
end
--> Background
dxDrawRectangle(x, y, w, h, bgColor, postGUI);
--> Border
dxDrawRectangle(x + 2, y - 1, w - 4, 1, borderColor, postGUI); -- top
dxDrawRectangle(x + 2, y + h, w - 4, 1, borderColor, postGUI); -- bottom
dxDrawRectangle(x - 1, y + 2, 1, h - 4, borderColor, postGUI); -- left
dxDrawRectangle(x + w, y + 2, 1, h - 4, borderColor, postGUI); -- right
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