Wysłany: 2021-11-07, 19:01
Nexusovskyy
Autorski Projekt
Wiek: 22 Na forum: 2964 dni Posty: 49
Nick w MP: Nexusovskyy
Piwa : 739
Cze??, wr?ci?em do lua, aktualnie zajmuj? si? prac?..
mam wypisane w tabeli punkty (markery do oddawania list?w) i nie wiem jak zrobi? by wybra?o tylko 3 markery.
local punktyListonosza = {
tutaj wypisane punkty
}
-- reszta kodu
local rand = math . random ( 1 , punktyListonosza )
local markerList = createMarker ( punktyListonosza [ rand ][ 1 ], punktyListonosza [ rand ][ 2 ], punktyListonosza [ rand ][ 3 ]- .9 , "cylinder" , 3.2 , 255 , 0 , 0 , 80 )
Czy m?g?by kto? mi to wyt?umaczy? ewentualnie poprawi? mnie?
Kod nie tworzy punkt?w, gdy wpisze v1 v2 v3 z pliku to tworzy wszystkie markery z pliku.
Wysłany: 2021-11-08, 13:56
Matikmontana
Modern Stories
Wiek: 22 Na forum: 2473 dni Posty: 423
Nick w MP: Mazeusz*
Piwa : 1015
local rand = math.random(1, #punktyListonosza)
Wysłany: 2021-11-08, 19:21
Nexusovskyy
Autorski Projekt
Wiek: 22 Na forum: 2964 dni Posty: 49
Nick w MP: Nexusovskyy
Piwa : 739
Dobra teraz mi respi duzo punkt?w nie losowe 3 punkty.
Jak zaradzi??
[ Dodano : 2021-11-09, 14:44 ]
ktos cos?
Wysłany: 2021-11-10, 00:03
BykuHD
Wiek: 28 Na forum: 2167 dni Posty: 10
Piwa : 3
Sprawd? co? takiego:
ilosc = 5
if ilosc then
local data = {}
repeat
local found = false
local rand = punktyListonosza [ math . random ( 1 , #punktyListonosza)]
for k , v in ipairs ( data ) do
if v == rand then
found = true
end
end
if not found then
table . insert ( data , rand )
end
until #data == ilosc
for i , v in ipairs ( data ) do
local markerList = createMarker ( v [ 1 ], v [ 2 ], v [ 3 ]- .9 , "cylinder" , 3.2 , 255 , 0 , 0 , 80 )
end
end
Wysłany: 2021-11-10, 01:04
_jvneczek
Wiek: 22 Na forum: 4326 dni Posty: 1513
Nick w MP: _jvneczek
Piwa : 3949
local punktyListonosza = {
tutaj wypisane punkty
}
-- reszta kodu
for i = 1 , 3 do
local rand = math . random ( 1 , #punktyListonosza)
local markerList = createMarker ( punktyListonosza [ rand ][ 1 ], punktyListonosza [ rand ][ 2 ], punktyListonosza [ rand ][ 3 ]- .9 , "cylinder" , 3.2 , 255 , 0 , 0 , 80 )
end
Wysłany: 2021-11-10, 07:33
Nexusovskyy
Autorski Projekt
Wiek: 22 Na forum: 2964 dni Posty: 49
Nick w MP: Nexusovskyy
Piwa : 739
Po po?udniu wr?c? i sprawdz?.
[ Dodano : 2021-11-10, 15:13 ]
Dalej respi wszystkie punkty jakie s? wpisane w local punktyListonosza = {
[ Dodano : 2021-11-10, 15:15 ]
Tak wygl?da aktualny kod:
bindKey ( "mouse1" , "down" , function()
if not getElementData ( localPlayer , "gui:listonosz" ) or getElementData ( localPlayer , "gui:listonosz" ) ~= true then return end
if isMouseIn ( 404 * px , 447 * py , 227 * px , 38 * py ) then
if getElementData ( localPlayer , "praca" ) then outputChatBox ( "Posiadasz aktywn? prac?!" , 255 , 0 , 0 ) return end
zrobione = 0
triggerServerEvent ( "create:listonosz" , localPlayer )
outputChatBox ( "Rozpoczynasz prac? listonosza." , 0 , 255 , 0 )
outputChatBox ( "Wynagrodzenie otrzymujesz po rozwiezieniu wszystkich list?w." , 0 , 255 , 0 )
showCursor ( false )
setElementData ( localPlayer , "gui:listonosz" , nil )
setElementData ( localPlayer , "praca" , "listonosz" )
for i , v in ipairs ( punktyListonosza ) do
for i = 1 , 3 do
local rand = math . random ( 1 , #punktyListonosza)
local markerList = createMarker ( punktyListonosza [ rand ][ 1 ], punktyListonosza [ rand ][ 2 ], punktyListonosza [ rand ][ 3 ]- .9 , "cylinder" , 3.2 , 255 , 0 , 0 , 80 )
local blipList = createBlipAttachedTo ( markerList , 41 )
addEventHandler ( "onClientMarkerHit" , markerList , function( hit )
if hit ~= localPlayer then return end
if isPedInVehicle ( localPlayer ) then outputChatBox ( "Nie mo?esz siedzie? w poje?dzie!" , 255 , 0 , 0 ) return end
zrobione = zrobione + 1
destroyElement ( source )
destroyElement ( blipList )
outputChatBox ( "Odniesiono list do skrzynki." )
if zrobione == #punktyListonosza then
if getElementData ( localPlayer , "player:premium" ) then
triggerServerEvent ( "hajs:premium" , localPlayer )
setElementData ( localPlayer , "praca" , nil )
else
triggerServerEvent ( "hajs:listonosz" , localPlayer )
setElementData ( localPlayer , "praca" , nil )
end
return
end
end )
end
end
end
Wysłany: 2021-11-10, 18:23
Matikmontana
Modern Stories
Wiek: 22 Na forum: 2473 dni Posty: 423
Nick w MP: Mazeusz*
Piwa : 1015
Spr?buj usun?? pierwsz? p?tle for
Wysłany: 2021-11-10, 20:23
xyzzz^
A nic
Wiek: 18 Na forum: 1993 dni Posty: 319
Nick w MP: Aspyk21
Piwa : 308
?le to masz totalnie zrobione
local zrobione = 0
for i = 1 , 3 do
if zrobione == 3 then return false end
zrobione = zrobione + 1
end
Tagi: math.random :: pracy
Anonymous
Na forum: 245 dni
Posty: 1
Anonymous Koniecznie zajrzyj na: