• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!
  • 2026 staff recruitment is open! Check it out and consider applying!

Funkcja lua pomocy!

Erazma

Banned User
Joined
Sep 3, 2012
Messages
265
Reaction score
4
Witam jest mozliwe zrobienie takiej funkcji która sprawdza czy mam 5 z 8 storgów obojętnie w jakiej kolejności podam przykład bo nie wiem jak takie coś zrobić czy to wg możliwe?

getPlayerStorageValue(cid,1) == 1 and getPlayerStorageValue(cid,2) == 1 and getPlayerStorageValue(cid,3) == 1 and getPlayerStorageValue(cid,4) == 1 and getPlayerStorageValue(cid,5) == 1 and getPlayerStorageValue(cid,6) == 1 and
getPlayerStorageValue(cid,7) == 1 and getPlayerStorageValue(cid,8) == 1 >= 5


albo getPlayerStorageValue(cid,1,2,3,4,5,6,7,8) == 1 >= 3 ??? nie wiem jesli ktos wie jak tkaie cos zrobic to prosze o odpowiedz wazne :P
 
Code:
function f(cid, ...)
	for i = 1, #arg do
		if getCreatureStorage(cid, arg[i][1]) < arg[i][2] then
			return false
		end
	end

	return true
end

Uzycie:
Code:
f(cid, {key, value}, {key, value}, ...)

@Edit:
Aktualnie, zle doczytalem. Dodaj sobie zmienna z counterem i zmien operator < na > i wtedy podnos o 1 jesli sie zgadza, a na koncu zwracaj return n > 5.
 
Last edited:
local count = 0
for i = 1,10 do
if getPlayerStorageValue(cid, storage + i) >= 1 then
count = count + 1
end
end
if count >= 5 then
dobrze
 
LUA:
function f(cid, required, ...)
	if (not isCreature(cid)) then
		return false
	end
	
	local counter = 0
	for i = 1, #arg do
		if (getCreatureStorage(cid, arg[i][1]) > arg[i][2]) then
			counter = counter + 1
		end
	end
	return counter >= required
end
-- f(cid, 2, {{1000, 1}, {1001, 2}, {1002, 3}, {1004, 4}})
Nie sprawdziłem czy działa, ale wygląda w porządku.
 
Last edited:
LUA:
function f(cid, required, ...)
	if (not isCreature(cid)) then
		return false
	end
	
	local counter = 0
	for i = 3, #arg do
		if (getCreatureStorage(cid, arg[i][1]) > arg[i][2]) then
			counter = counter + 1
		end
	end
	return counter >= required
end
-- f(cid, 2, {{1000, 1}, {1001, 2}, {1002, 3}, {1004, 4}})
Nie sprawdziłem czy działa, ale wygląda w porządku.

Po arg od 1 powinien zaczac isc bo ta tablica zawiera tylko argumenty z ... :p
 
Back
Top