i podpi?c do niego funkcj?, kt?ra ustala w tabeli gracza 'false' (czyli, ?e gracz opu?ci? marker)
- w komendzie doda? warunek sprawdzaj?cy tabel? gracza, je?li zwr?ci TRUE - wykona? dalej funkcje.
Je?li zwr?ci FALSE - da? info o nie byciu w markerze.
Co? w stylu poni?szego kodu:
local markers = {
{2070.97+2, -1768.42, 13.56-1, -90, 0},
{1552.98, -1720.66-2, 13.55-1, 180, 0},
{492.58, -1756.82-2, 14.14-1, 180, -90}
}
local obecnosc = {}
for i,v in ipairs(markers) do
local m = createMarker(v[1], v[2], v[3], "cylinder", 0.5, 255, 0, 0, 125)
addEventHandler("onMarkerHit", m, function(el, md) if getElementType(el) == "player" and md then obecnosc[el] = true end end)
addEventHandler("onMarkerLeave", m, function(el, md) if getElementType(el) == "player" and md then obecnosc[el] = false end end)
end
function food(thePlayer, matchingDimension)
if obecnosc[thePlayer] == true then
local kasa = getPlayerMoney(thePlayer)
if (kasa > 19.999) then
takePlayerMoney(thePlayer, 20)
setElementHealth(thePlayer, getElementHealth(thePlayer) + 80)
end
else
outputChatBox("* Nie sta? ci? na jedzenie!", thePlayer, 255, 0, 0, true)
end
end
addCommandHandler("food", food)
Upewnij si? oczywi?cie, ?e pierwszy kod i drugi kod jest po stronie servera - jest to wa?ne.
PS. W z?ym miejscu postawi?e? jednego 'end'a w komendzie. ; )
Wilq, no niestety twoj kod nie dziala, teraz ciagle nie wazne czy stoje w markerze czy nie wywala blad po else (outputChatBox("* Nie sta? ci? na jedzenie!", thePlayer, 255, 0, 0, true)
function food(thePlayer, matchingDimension)
if isElementWithinMarker(thePlayer, resourceRoot) then
local kasa = getPlayerMoney(thePlayer)
if (kasa > 19.999) then
takePlayerMoney(thePlayer, 20)
setElementHealth(thePlayer, getElementHealth(thePlayer) + 80)
else
outputChatBox("* Nie sta? ci? na jedzenie!", thePlayer, 255, 0, 0, true)
end
end
end
addCommandHandler("food", food)
Tak jak Gpla wspomnia?, markery za nisko i trzeba wej?? centralnie na ?rodek.
Proponuj? rozwi?zanie z colSphere, gotowy kod poni?ej.
local markers = {
{2070.97+2, -1768.42, 13.56-1},
{1552.98, -1720.66-2, 13.55-1},
{492.58, -1756.82-2, 14.14-1}
}
local obecnosc = {}
for i,v in ipairs(markers) do
createMarker(v[1], v[2], v[3], "cylinder", 1, 255, 0, 0, 125)
local colshape = createColSphere(v[1], v[2], v[3]+1, 0.7)
addEventHandler("onColShapeHit", colshape, function(el, md) if getElementType(el) == "player" and md then obecnosc[el] = true end end)
addEventHandler("onColShapeLeaveLeave", colshape, function(el, md) if getElementType(el) == "player" and md then obecnosc[el] = false end end)
end
function food(thePlayer, command)
if obecnosc[thePlayer] then
if (getPlayerMoney(thePlayer) > 19.999) then
takePlayerMoney(thePlayer, 20)
setElementHealth(thePlayer, getElementHealth(thePlayer) + 80)
else
outputChatBox("* Nie sta? ci? na jedzenie!", thePlayer, 255, 0, 0, true)
end
else
--ewentualne info o markerze
end
end
addCommandHandler("food", food)
Ewentualnie mo?esz da? colShape na ca?? budk? i usun?? markery, wystarczy podej?? do budki i voilà.
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