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

Wysłany: 2018-11-30, 17:32


ohdude







Wiek: 14
Na forum: 2868 dni
Posty: 60
Nick w MP: ohdude

Piwa: 124

Respekt: 70,5

siema, mam problem na db3 wywala mi taki b??d: https://i.imgur.com/BBLWYEz.png
o to kod:

local markers = {
{2070.97+2, -1768.4213.56-1, -900}, 
{1552.98, -1720.66-213.55-11800}, 
{492.58, -1756.82-214.14-1180, -90} 
}

for i,v in ipairs(markers) do
local m createMarker(v[1], v[2], v[3], "cylinder"0.525500125)
end


function food(thePlayermatchingDimension)
    if isElementWithinMarker(thePlayermthen  
       local kasa getPlayerMoney(thePlayer)                               
          if (kasa 19.999then 
           takePlayerMoney(thePlayer20)
           setElementHealth(thePlayergetElementHealth(thePlayer) + 80)
    else
       outputChatBox("* Nie sta? ci? na jedzenie!"thePlayer25500true)
        end
    end
end
addCommandHandler("food"food)


za pomoc :piwo: :piwo: :piwo:

Podpis
Discord - ohdude#5133
Postaw piwo autorowi tego posta
 

 
Wysłany: 2018-11-30, 18:55


Query

SyndicateMTA






Wiek: 24
Na forum: 3072 dni
Posty: 319
Nick w MP: Query

Piwa: 5257

Respekt: 141
Respekt: 141

Drugi argument jest z?y

Podpis
Postaw piwo autorowi tego posta
 

 
Wysłany: 2018-11-30, 19:10


ohdude







Wiek: 14
Na forum: 2868 dni
Posty: 60
Nick w MP: ohdude

Piwa: 124

Respekt: 70,5

darecky02, czytac umiem - nie umiem tego naprawic

Podpis
Discord - ohdude#5133
Postaw piwo autorowi tego posta
 

 
Wysłany: 2018-11-30, 21:26


Wilq







Wiek: 24
Na forum: 4428 dni
Posty: 3410

Piwa: 739

Respekt: 1225,8
Respekt: 1225,8

Zacznijmy od tego, ?e masz 'local' przy zmiennej markeru.
Z ka?dym stworzeniem markeru, marker si? nadpisuje i tylko ten ostatni jest pod zmienn? 'm'.

Proponowa?bym zrobi? to:
- doda? event,

Więcej informacji znajdziesz w Wikipedii MTA:

onMarkerHit

i podpi?? do niego funkcj?, kt?ra ustala w tabeli gracza 'true' (czyli, ?e gracz si? w markerze)
- doda? event,

Więcej informacji znajdziesz w Wikipedii MTA:

onMarkerLeave

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.4213.56-1, -900}, 
{1552.98, -1720.66-213.55-11800}, 
{492.58, -1756.82-214.14-1180, -90} 
}

local obecnosc = {}

for i,v in ipairs(markers) do
    local m createMarker(v[1], v[2], v[3], "cylinder"0.525500125)
    addEventHandler("onMarkerHit"m, function(elmd) if getElementType(el) == "player" and md then obecnosc[el] = true end end)
    addEventHandler("onMarkerLeave"m, function(elmd) if getElementType(el) == "player" and md then obecnosc[el] = false end end)    
end


function food(thePlayermatchingDimension)
    if obecnosc[thePlayer] == true then  
       local kasa getPlayerMoney(thePlayer)                               
          if (kasa 19.999then 
           takePlayerMoney(thePlayer20)
           setElementHealth(thePlayergetElementHealth(thePlayer) + 80)
        end           
    else
       outputChatBox("* Nie sta? ci? na jedzenie!"thePlayer25500true)
    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. ; )

Postaw piwo autorowi tego posta
 

 
Wysłany: 2018-11-30, 21:38


TeeNekk

Cienzaruwka :v






Wiek: 23
Na forum: 3210 dni
Posty: 264
Nick w MP: TeeNekk.

Piwa: 919

Respekt: 110,5
Respekt: 110,5

A nie lepiej przy wej?ciu do markera dodawa? komend?

a po wyj?ciu j? usuwa?? (removeCommandHandler)

Podpis
Pomogłem Ci
? Może zostawiłbyś za to piwko, lub respekt? Dzięki!
Mój projekt:
?
Postaw piwo autorowi tego posta
 

 
Wysłany: 2018-11-30, 23:48


ohdude







Wiek: 14
Na forum: 2868 dni
Posty: 60
Nick w MP: ohdude

Piwa: 124

Respekt: 70,5

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)

Podpis
Discord - ohdude#5133
Postaw piwo autorowi tego posta
 

 
Wysłany: 2018-12-01, 00:02


Wilq







Wiek: 24
Na forum: 4428 dni
Posty: 3410

Piwa: 739

Respekt: 1225,8
Respekt: 1225,8

Jaki dok?adnie b??d? Screen?

Postaw piwo autorowi tego posta
 

 
Wysłany: 2018-12-01, 01:50


Gpla

Loading...






Wiek: 26
Na forum: 3853 dni
Posty: 84
Nick w MP: Loading...

Piwa: 174

Respekt: 55,3

Nie lepiej tak?
Kod:


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)


Postaw piwo autorowi tego posta
 

 
Wysłany: 2018-12-01, 10:47


ohdude







Wiek: 14
Na forum: 2868 dni
Posty: 60
Nick w MP: ohdude

Piwa: 124

Respekt: 70,5

Wilq, b??du w db3 nie ma zandego

[ Dodano: 2018-12-01, 11:00 ]
Gpla, taki error wyskakuje na db3 z twoim kodem: https://www.upload.ee/fil...-46_LI.jpg.html

Podpis
Discord - ohdude#5133
Postaw piwo autorowi tego posta
 

 
Wysłany: 2018-12-01, 11:30


Gpla

Loading...






Wiek: 26
Na forum: 3853 dni
Posty: 84
Nick w MP: Loading...

Piwa: 174

Respekt: 55,3

Hmm no to cos mi sie pomylilo, uzyj kodu Wilq'a i ustaw wyzej marker

Postaw piwo autorowi tego posta
 

 
Wysłany: 2018-12-01, 11:39


ohdude







Wiek: 14
Na forum: 2868 dni
Posty: 60
Nick w MP: ohdude

Piwa: 124

Respekt: 70,5

Gpla, ale jego kod nie dziala xD

Podpis
Discord - ohdude#5133
Postaw piwo autorowi tego posta
 

 
Wysłany: 2018-12-01, 11:50


Gpla

Loading...






Wiek: 26
Na forum: 3853 dni
Posty: 84
Nick w MP: Loading...

Piwa: 174

Respekt: 55,3

Nie dziala dlatego ?e masz markery za nisko

Postaw piwo autorowi tego posta
 

 
Wysłany: 2018-12-01, 12:17


Wilq







Wiek: 24
Na forum: 4428 dni
Posty: 3410

Piwa: 739

Respekt: 1225,8
Respekt: 1225,8

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.4213.56-1}, 
{1552.98, -1720.66-213.55-1}, 
{492.58, -1756.82-214.14-1} 
}

local obecnosc = {}

for i,v in ipairs(markers) do
    createMarker(v[1], v[2], v[3], "cylinder"125500125)
    local colshape createColSphere(v[1], v[2], v[3]+10.7)
    addEventHandler("onColShapeHit"colshape, function(elmd) if getElementType(el) == "player" and md then obecnosc[el] = true end end)
    addEventHandler("onColShapeLeaveLeave"colshape, function(elmd) if getElementType(el) == "player" and md then obecnosc[el] = false end end)   
end

function food(thePlayercommand)
    if obecnosc[thePlayerthen  
        if (getPlayerMoney(thePlayer) > 19.999then 
            takePlayerMoney(thePlayer20)
            setElementHealth(thePlayergetElementHealth(thePlayer) + 80)
        else
            outputChatBox("* Nie sta? ci? na jedzenie!"thePlayer25500true)
        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à.

Kod testowany, zero problem?w.

Postaw piwo autorowi tego posta
 

 
Więcej szczegółów
Wystawiono 1 piw(a):
Gpla
Tagi: iselementwithinmarker
Anonymous





Na forum: 245 dni
Posty: 1



Anonymous Koniecznie zajrzyj na:






Skocz do:  
Wyświetl posty z ostatnich:   
GTAONLINE.PL » JĘZYKI PROGRAMOWANIA » LUA » if isElementWithinMarker 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