• 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!

Script zioooom

BugaS

Donżuan
Joined
Mar 12, 2009
Messages
1,219
Reaction score
9
Location
NYC
Mam problem. Pewnie dostanę warna, luz.
Piszę tutaj bo tutaj najszybciej można liczyć na odpowiedź, związaną z topiciem, hejtem albo offtopiciem.

Mam takie cuś:


Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
	local config = {
		rewards = {1111, 2222, 3333, 4444, 5555, 6666, 0}, -- Id of items which surprise package can create (0 means nothing).
		amount = {1, 2}, -- Amount of create items (random).
		fire = 1, -- If random reward will 0 player will be burned (1 - true, 2 - false),
		effect = CONST_ME_EXPLOSIONHIT, -- Effect if player will be burned
		min = 20, -- Minimum hit if player will be burned
		max = 100 -- Maximum hit if player will be burned
	}
	
	-- Don't change this --
	local r, s, t, u = config.rewards[math.random(1, #config.rewards)], getItemNameById(r), amount[math.random(1, #config.amount)], getCreaturePosition(cid)
	-- ////////////////// --
	
	if(r == 0 && fire == 1) then
		doCreatureAddHealth(cid, -(math.random(config.min,config.max)))
		doSendMagicEffect(u, config.effect)
		doPlayerSendTextMessage(cid, 4, "It was a trap! Surprise package burned you!")
	elseif(r == 0 && fire == 0) then
		doPlayerSendTextMessage(cid, 4, "Suprice package was empty.")
	else
		doPlayerAddItem(cid, r, t)
		doSendMagicEffect(u, CONST_ME_GIFT_WRAPS)
		doPlayerSendTextMessage(cid, 4, "Surprise package gave you ".. t .."x of ".. s ..".")
	end
	doRemoveItem(item.uid, 1)
	return true
end

A wywala cuś takiego:

Code:
[20:57:02.359] data/actions/scripts/suprice_package.lua:15: ')' expected near '&

Anyone helps?
 
Spróbuj ale jestem amator więc nic nie obiecuje:

Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
	local config = {
		rewards = {1111, 2222, 3333, 4444, 5555, 6666, 0}, -- Id of items which surprise package can create (0 means nothing).
		amount = {1, 2}, -- Amount of create items (random).
		fire = 1, -- If random reward will 0 player will be burned (1 - true, 2 - false),
		effect = CONST_ME_EXPLOSIONHIT, -- Effect if player will be burned
		min = 20, -- Minimum hit if player will be burned
		max = 100 -- Maximum hit if player will be burned
	}
	
	-- Don't change this --
	local r, s, t, u = config.rewards[math.random(1, #config.rewards)], getItemNameById(r), amount[math.random(1, #config.amount)], getCreaturePosition(cid)
	-- ////////////////// --
	
	if(r == 0) && (fire == 1) then
		doCreatureAddHealth(cid, -(math.random(config.min,config.max)))
		doSendMagicEffect(u, config.effect)
		doPlayerSendTextMessage(cid, 4, "It was a trap! Surprise package burned you!")
	elseif(r == 0 && fire == 0) then
		doPlayerSendTextMessage(cid, 4, "Suprice package was empty.")
	else
		doPlayerAddItem(cid, r, t)
		doSendMagicEffect(u, CONST_ME_GIFT_WRAPS)
		doPlayerSendTextMessage(cid, 4, "Surprise package gave you ".. t .."x of ".. s ..".")
	end
	doRemoveItem(item.uid, 1)
	return true
end
 
Spróbuj ale jestem amator więc nic nie obiecuje:

Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
	local config = {
		rewards = {1111, 2222, 3333, 4444, 5555, 6666, 0}, -- Id of items which surprise package can create (0 means nothing).
		amount = {1, 2}, -- Amount of create items (random).
		fire = 1, -- If random reward will 0 player will be burned (1 - true, 2 - false),
		effect = CONST_ME_EXPLOSIONHIT, -- Effect if player will be burned
		min = 20, -- Minimum hit if player will be burned
		max = 100 -- Maximum hit if player will be burned
	}
	
	-- Don't change this --
	local r, s, t, u = config.rewards[math.random(1, #config.rewards)], getItemNameById(r), amount[math.random(1, #config.amount)], getCreaturePosition(cid)
	-- ////////////////// --
	
	if(r == 0) && (fire == 1) then
		doCreatureAddHealth(cid, -(math.random(config.min,config.max)))
		doSendMagicEffect(u, config.effect)
		doPlayerSendTextMessage(cid, 4, "It was a trap! Surprise package burned you!")
	elseif(r == 0 && fire == 0) then
		doPlayerSendTextMessage(cid, 4, "Suprice package was empty.")
	else
		doPlayerAddItem(cid, r, t)
		doSendMagicEffect(u, CONST_ME_GIFT_WRAPS)
		doPlayerSendTextMessage(cid, 4, "Surprise package gave you ".. t .."x of ".. s ..".")
	end
	doRemoveItem(item.uid, 1)
	return true
end

[21:14:29.063] data/actions/scripts/suprice_package.lua:15: 'then' expected near '&'

to wywaliło.
 
eksperymentuję, a to:
jak nie to sorry ale nie wiem

Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
	local config = {
		rewards = {1111, 2222, 3333, 4444, 5555, 6666, 0}, -- Id of items which surprise package can create (0 means nothing).
		amount = {1, 2}, -- Amount of create items (random).
		fire = 1, -- If random reward will 0 player will be burned (1 - true, 2 - false),
		effect = CONST_ME_EXPLOSIONHIT, -- Effect if player will be burned
		min = 20, -- Minimum hit if player will be burned
		max = 100 -- Maximum hit if player will be burned
	}
	
	-- Don't change this --
	local r, s, t, u = config.rewards[math.random(1, #config.rewards)], getItemNameById(r), amount[math.random(1, #config.amount)], getCreaturePosition(cid)
	-- ////////////////// --
	
	if (r == 0 and fire == 1) then
		doCreatureAddHealth(cid, -(math.random(config.min,config.max)))
		doSendMagicEffect(u, config.effect)
		doPlayerSendTextMessage(cid, 4, "It was a trap! Surprise package burned you!")
	elseif (r == 0 and fire == 0) then
		doPlayerSendTextMessage(cid, 4, "Suprice package was empty.")
	else
		doPlayerAddItem(cid, r, t)
		doSendMagicEffect(u, CONST_ME_GIFT_WRAPS)
		doPlayerSendTextMessage(cid, 4, "Surprise package gave you ".. t .."x of ".. s ..".")
	end
	doRemoveItem(item.uid, 1)
	return true
end
 
łap:

v1:

LUA:
function onUse(cid, item, fromPosition, itemEx, toPosition)
	local config = {
		rewards = {1111, 2222, 3333, 4444, 5555, 6666, 0}, -- Id of items which surprise package can create (0 means nothing).
		amount = {1, 2}, -- Amount of create items (random).
		fire = 1, -- If random reward will 0 player will be burned (1 - true, 2 - false),
		effect = CONST_ME_EXPLOSIONHIT, -- Effect if player will be burned
		min = 20, -- Minimum hit if player will be burned
		max = 100 -- Maximum hit if player will be burned
	}
	
	-- Don't change this --
	local r, s, t, u = config.rewards[math.random(1, #config.rewards)], if getItemNameById(r) ~= nil then getItemNameById(r) else "nazwy brak" end, amount[math.random(1, #config.amount)], getCreaturePosition(cid)
	-- ////////////////// --
	
	if (r == 0 and config.fire == 1) then
		doCreatureAddHealth(cid, -(math.random(config.min,config.max)))
		doSendMagicEffect(u, config.effect)
		doPlayerSendTextMessage(cid, 4, "It was a trap! Surprise package burned you!")
	elseif(r == 0 and config.fire == 0) then
		doPlayerSendTextMessage(cid, 4, "Suprice package was empty.")
	else
		doPlayerAddItem(cid, r, t)
		doSendMagicEffect(u, CONST_ME_GIFT_WRAPS)
		doPlayerSendTextMessage(cid, 4, "Surprise package gave you ".. t .."x of ".. s ..".")
	end
	doRemoveItem(item.uid, 1)
	return true
end


jeśli v1 nie działa to spróbuj v2:

LUA:
function onUse(cid, item, fromPosition, itemEx, toPosition)
	local config = {
		rewards = {1111, 2222, 3333, 4444, 5555, 6666, 0}, -- Id of items which surprise package can create (0 means nothing).
		amount = {1, 2}, -- Amount of create items (random).
		fire = 1, -- If random reward will 0 player will be burned (1 - true, 2 - false),
		effect = CONST_ME_EXPLOSIONHIT, -- Effect if player will be burned
		min = 20, -- Minimum hit if player will be burned
		max = 100 -- Maximum hit if player will be burned
	}
	
	-- Don't change this --
	local r, s, t, u = config.rewards[math.random(1, #config.rewards)], getItemNameById(r), amount[math.random(1, #config.amount)], getCreaturePosition(cid)
	-- ////////////////// --
	
	if(r == 0 and config.fire == 1) then
		doCreatureAddHealth(cid, -(math.random(config.min,config.max)))
		doSendMagicEffect(u, config.effect)
		doPlayerSendTextMessage(cid, 4, "It was a trap! Surprise package burned you!")
	elseif(r == 0 and config.fire == 0) then
		doPlayerSendTextMessage(cid, 4, "Suprice package was empty.")
	else
		doPlayerAddItem(cid, r, t)
		doSendMagicEffect(u, CONST_ME_GIFT_WRAPS)
		doPlayerSendTextMessage(cid, 4, "Surprise package gave you ".. t .."x of ".. s ..".")
	end
	doRemoveItem(item.uid, 1)
	return true
end




//// Seminari
 
Spróbuj zamienić:
Code:
if(r == 0 && fire == 1) then
na:
Code:
if(r == 0 and fire == 1) then

Z tego co się orientuję to operatorami logicznymi w LUA są "or", "and" i "not".
 
Spróbuj zamienić:
Code:
if(r == 0 && fire == 1) then
na:
Code:
if(r == 0 and fire == 1) then

Z tego co się orientuję to operatorami logicznymi w LUA są "or", "and" i "not".
orientujesz się po czym? bo do manuala nie zajrzałeś, co najwyżej na jakieś gówno polskojęzycznego tutorialmastera aka naucze cię programować w 3 posty. &&, || również są dopuszczane w LUA - na początku manuala masz napisane.


Przed napisaniem tamtego posta zajrzałem do tego manuala (bez upewnienia się bym go nie napisał):
Lua 5.1 Reference Manual

Oświeć mnie gdzie jest napisane o && i ||?

Przeczytaj cały, dalsza część się nauczysz przy okazji czegoś i znajdziesz odpowiedź na nurtujące ciebie pytanie, panie ciemny.
 
Last edited:
orientujesz się po czym? bo do manuala nie zajrzałeś, co najwyżej na jakieś gówno polskojęzycznego tutorialmastera aka naucze cię programować w 3 posty. &&, || również są dopuszczane w LUA - na początku manuala masz napisane.
Przed napisaniem tamtego posta zajrzałem do tego manuala (bez upewnienia się bym go nie napisał):
Lua 5.1 Reference Manual
2.5.3 – Logical Operators

The logical operators in Lua are and, or, and not. Like the control structures (see §2.4.4), all logical operators consider both false and nil as false and anything else as true.

The negation operator not always returns false or true. The conjunction operator and returns its first argument if this value is false or nil; otherwise, and returns its second argument. The disjunction operator or returns its first argument if this value is different from nil and false; otherwise, or returns its second argument. Both and and or use short-cut evaluation; that is, the second operand is evaluated only if necessary. Here are some examples:

10 or 20 --> 10
10 or error() --> 10
nil or "a" --> "a"
nil and 10 --> nil
false and error() --> false
false and nil --> false
false or nil --> nil
10 and 20 --> 20

(In this manual, --> indicates the result of the preceding expression.)
Oświeć mnie gdzie jest napisane o && i ||?
 
Back
Top