Wysłany: 2020-03-19, 14:21
Shinnowaty
Wiek: 24 Na forum: 2311 dni Posty: 25
Nick w MP: Kirotsune
Piwa : 1
Dzie? Dobry/Dobry wiecz?r mam pewien problem, a mianowicie podczas rozpocz?cia napadu mimo i? s? SAPD pokazuje, ?e musi by? na s?u?bie przynajmniej jeden SAPD(nic w debugu nie wywala). Drugi b??d jest taki, jak chce rozpocz?? napad i celuje na ped'a wywala taki b??d w debugu: https://imgur.com/a/xDvlL8A
Tutaj kod:
Kod: --[[
author: NyAngel (© 2019)
discord: NyAngel#9094
all rights reserved.
]]
local sx, sy = guiGetScreenSize()
local zoom = 1920/sx
-- // Przydatna funkcja do animacji
local anims, animID = { }, 0
local rendering = false
local function renderAnimations( )
local now = getTickCount( )
for k,v in ipairs(anims) do
v.onChange(interpolateBetween(v.from, 0, 0, v.to, 0, 0, (now - v.start) / v.duration, v.easing))
if now >= v.start+v.duration then
table.remove(anims, k)
if type(v.onEnd) == "function" then
v.onEnd( )
end
if #anims == 0 then
rendering = false
removeEventHandler("onClientRender", root, renderAnimations)
end
end
end
end
function animate(f, t, easing, duration, onChange, onEnd)
if #anims == 0 and not rendering then
addEventHandler("onClientRender", root, renderAnimations)
rendering = true
end
assert(type(f) == "number", "Bad argument @ 'animate' [expected number at argument 1, got "..type(f).."]")
assert(type(t) == "number", "Bad argument @ 'animate' [expected number at argument 2, got "..type(t).."]")
assert(type(easing) == "string", "Bad argument @ 'animate' [Invalid easing at argument 3]")
assert(type(duration) == "number", "Bad argument @ 'animate' [expected number at argument 4, got "..type(duration).."]")
assert(type(onChange) == "function", "Bad argument @ 'animate' [expected function at argument 5, got "..type(onChange).."]")
animID = animID+1
table.insert(anims, {id=animID, from = f, to = t, easing = easing, duration = duration, start = getTickCount( ), onChange = onChange, onEnd = onEnd})
return animID
end
function finishAnimation(anim)
for k, v in ipairs(anims) do
if v.id == anim then
v.onChange(v.to)
if v.onEnd then v.onEnd() end
v.start = 0
return true
end
end
end
function deleteAnimation(anim)
for k, v in ipairs(anims) do
if v.id == anim then
table.remove(anims, k)
break
end
end
end
function secondsToTimeDesc( seconds )
if seconds then
local results = {}
local sec = ( seconds %60 )
local min = math.floor ( ( seconds % 3600 ) /60 )
local hou = math.floor ( ( seconds % 86400 ) /3600 )
local day = math.floor ( seconds /86400 )
if day > 0 then table.insert( results, day .. ( day == 1 and " dzie?" or " dni" ) ) end
if hou > 0 then table.insert( results, hou .. ( hou == 1 and " godzina" or " godzin" ) ) end
if min > 0 then table.insert( results, min .. ( min == 1 and " minuta" or " minut" ) ) end
if sec > 0 then table.insert( results, sec .. ( sec == 1 and " sekunda" or " sekund/y" ) ) end
return string.reverse ( table.concat ( results, ", " ):reverse():gsub(" ,", " i ", 1 ) )
end
return ""
end
local ProgressBar = {}
ProgressBar.value = 0 -- nie zmieniaj
ProgressBar.animationTime = 10 -- czas w sekundach
function ProgressBar.render()
dxDrawRectangle(sx/2-200/zoom, sy/2-25/zoom, 400/zoom, 50/zoom, tocolor(0, 0, 0, 200))
dxDrawRectangle(sx/2-200/zoom, sy/2-25/zoom, 400/zoom * ProgressBar.value, 50/zoom, tocolor(115, 191, 43, 255))
dxDrawText((math.floor(ProgressBar.value * 100) or 0).."%", sx/2-200/zoom, sy/2-25/zoom, sx/2-200/zoom+400/zoom, sy/2-25/zoom+50/zoom, tocolor(255, 255, 255, 255), 1.25, "default-bold", "center", "center")
end
function ProgressBar.create()
addEventHandler("onClientRender", root, ProgressBar.render)
ProgressBar.value = 0
animate(0, 1, "Linear", ProgressBar.animationTime * 1000,
function(progress)
ProgressBar.value = progress
end,
function()
ProgressBar.destroy()
setElementFrozen(el, false)
triggerServerEvent("Robbery.money", resourceRoot)
end
)
end
function ProgressBar.destroy()
removeEventHandler("onClientRender", root, ProgressBar.render)
end
addEvent("ProgressBar.start", true)
addEventHandler("ProgressBar.start", resourceRoot, function()
ProgressBar.create()
end)
local TimeCounter = {}
TimeCounter.time = 60 -- czas w sekundach
TimeCounter.value = 0
TimeCounter.tick = getTickCount()
function TimeCounter.render()
if getTickCount() - TimeCounter.tick >= 1000 then
TimeCounter.value = TimeCounter.value + 1
TimeCounter.tick = getTickCount()
end
if TimeCounter.value >= TimeCounter.time then
TimeCounter.destroy()
triggerServerEvent("Robbery.stop", resourceRoot)
end
dxDrawText(secondsToTimeDesc(TimeCounter.value), sx/2-50/zoom, 25/zoom, sx/2-50/zoom+100/zoom, 25/zoom+50/zoom, tocolor(255, 255, 255, 255), 2, "default-bold", "center", "center")
end
function TimeCounter.create()
TimeCounter.value = 0
addEventHandler("onClientRender", root, TimeCounter.render)
end
function TimeCounter.destroy()
removeEventHandler("onClientRender", root, TimeCounter.render)
end
addEvent("TimeCounter.start", true)
addEventHandler("TimeCounter.start", resourceRoot, function()
TimeCounter.create()
end)
addEventHandler("onClientPlayerTarget", getRootElement(), function(target)
if not target then return end
if getElementType(target) == "ped" and (getPedWeapon(el) == 30) then
local data = getElementData(target, "robbery")
local playerData = getElementData(el, "stealing_money")
toggleControl(el, "aim_weapon ", false)
toggleControl(el, "fire", false)
local count = 0
local players = getElementsByType("player")
for k, v in ipairs(players) do
if getElementData(v, "player:duty") == "SAPD" then
count = count + 1
end
end
if data and not playerData then
if count >= 1 then
triggerServerEvent("Robbery.start", resourceRoot)
local id = getElementData(el, "robbery_point")
if not id then
return
end
triggerServerEvent("Ped.setAnimation", resourceRoot, id, "ped", "handsup")
else
outputChatBox("* Nie mo?esz rozpocz?? napadu, poniewa? nie ma ?adnego policjanta na s?u?bie")
end
end
end
end)
[/code]
Wysłany: 2020-03-19, 14:36
Wilq
Wiek: 24 Na forum: 4428 dni Posty: 3410
Piwa : 739
1. Policjanci maj? element dat? "player:duty" ustawion? na "SAPD"? Jeste? tego pewny?
2. Wska? 156 linijk?, w funkcji getPedWeapon w #1 argumencie musisz poda? zmienn? peda a nic nie wprowadzi?e?.
Wysłany: 2020-03-19, 17:38
Shinnowaty
Wiek: 24 Na forum: 2311 dni Posty: 25
Nick w MP: Kirotsune
Piwa : 1
Kod: if getElementType(target) == "ped" and (getPedWeapon(el) == 30) then
Tutaj 156 linijka
[ Dodano : 2020-03-19, 19:02 ]
Uda?o si? zrobi? tamt? linijk?, lecz b??d wywala teraz w
toggleControl(localPlayer, "aim_weapon ", false)
toggleControl(localPlayer, "fire", false)
Expected string at argument 1, got nil
Wysłany: 2020-03-20, 20:42
kamison
Przyszły programista .lua
Wiek: 25 Na forum: 3302 dni Posty: 391
Nick w MP: kamison
Piwa : 594
To jest napewno po stronie klienta?
Wysłany: 2020-03-21, 05:42
Maniekxx
Amator
Wiek: 24 Na forum: 2894 dni Posty: 232
Nick w MP: Maniekxx
Piwa : 225
Spr?buj tak
Server :
toggleControl ( client , "aim_weapon " , false )
toggleControl ( client , "fire" , false )
Client :
toggleControl ( "aim_weapon " , false )
toggleControl ( "fire" , false )
W zale?no?ci od tego po kt?rej stronie (clienta czy servera) znajduje si? zas?b, w przypadku gdy jest on po stronie clienta nie musisz w nim definiowa? gracza.
Tagi: zły :: argument :: quotpedquot
Anonymous
Na forum: 245 dni
Posty: 1
Anonymous Koniecznie zajrzyj na: