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

Lua Some Scripts.

Elexonic

Well-Known Member
Joined
Jun 18, 2008
Messages
1,920
Reaction score
59
Need help scrtip some I do not work well, others to see if it can optimize and repair.

1º-> when you sell to a npc gives me this error-... --- Fixed


2º-> this script I want to see if you can do simpler or change some code to work better.

Code:
function onUse(cid, item, frompos, item2, topos)

if getPlayerLevel(cid) > 1 then
if (os.time() - getPlayerStorageValue(cid,4826) > 10*1) then
arena = {x=1151, y=1377, z=5}
doSummonCreature("wyvern", {x=1147, y=1379, z=5})
doTeleportThing(cid,arena,0)
doSendMagicEffect(arena,10)
setPlayerStorageValue(cid,4826,os.time())
else
doPlayerSendCancel(cid,'Wait.')
doSendMagicEffect(topos,2)
end
else
doSendMagicEffect(topos,2)
end

return 1
end

3º>

-Fixed By Strack!

4ºError in position :S --- Fixed By VirrageS

6º In ALL npc, when I say trade, bye ... Fixed

7ºwhen I open a door once the Pirmez works well ... but when you give the sec might not work.
The problem is that id is changed and I think that is why the problem.
Anyone know how to fix it?


FIxed



Bye!
 
Last edited:
4th script, not tested, done asleep in few time (i've not understood perfectly what u want it to do...)
Lua:
local tpPos1 = {x=33078,y=31080,z= 13}
local tpPos2 = {x=33082,y=31110,z= 2}

function onUse(cid, item, fromPosition, itemEx, toPosition)

local Ppos = getCreaturePosition(cid)

if item.itemid == 1946 then
	return doTransformItem(item.uid, item.itemid - 1)
end

if item.itemid == 1945 then
	if item.actionid == 23232 then
		if Ppos ~= tpPos1 then
			return doPlayerSendCancel(cid, 'no estas en la posicion correcta') and false
		end
		doTeleportThing(cid, tpPos2)
	elseif item.actionid == 23233 then
		if Ppos ~= tpPos2 then
			return doPlayerSendCancel(cid, 'no estas en la posicion correcta') and false
		end
		doTeleportThing(cid, tpPos1)
	end
doTransformItem(item.uid, item.itemid + 1)
end
return true
end
 
yeah... it should work.... strack's script....
lol
Ustedes 2 hablan español y lo saben, ya q participan en otserv.es y mas encima se reponden en ingles??? jajajajaj xDDD

@Elexonic: tu primer error lo mas probable es q sea por eso... si tuvieras el trade abierto y dices bye, se mantiene abierto... entonces intentas vender algo, pero como ya dijiste bye, el npc no tiene focused al player, por lo q lanza un errror de no reconocimiento del player (no hay player) ^^

Otra cosa: si hay un script de npc's por default, el primero podria ser un error en ese script ^^

El segundo creo q no se puede simplificar, aunq podrias ponerle unos locales para hacerlo mas configurable....

Para el tercero: no revise

Y el cuarto deberia servir el de strack como dije antes ^^
 
Last edited:
Script # 2
Lua:
local arena, pos = {
  --[{Min Level, Max Level}] = { Monster Name, Position}
	[{1, 20}] = {"troll", {x=1147, y=1379, z=5}},
	[{21, 40}] = {"wyvern", {x=1147, y=1379, z=5}}
	}, {x=1151, y=1377, z=5}
function checkPlayer(fromPosition, toPosition)
	for x = fromPosition.x, toPosition.x do
		for y = fromPosition.y, toPosition.y do
			local pid = getThingFromPos({x = x, y = y, z = fromPosition.z, stackpos = STACKPOS_TOP_CREATURE}).uid
			if isPlayer(pid) then
				return true
			end
		end
	end
return false
end	
function onUse(cid, item, frompos, item2, topos)
	if checkPlayer({x = 1000, y = 1000, z = 7}--[[change this position to the top left position of the arena.]], {x = 1000, y = 1000, z = 7}--[[change this position to the bottom right position of the arena.]]) == true then
		doPlayerSendCancel(cid, 'There is a player having a battle right now, please wait.')
		return false
	end	
	for l, i in pairs(arena) do
		if getPlayerLevel(cid) >= l[1] and getPlayerLevel(cid) <= l[2] then
			if (os.time() - getPlayerStorageValue(cid,4826) > 10*1) then
				doSummonCreature(i[1], i[2])
				doTeleportThing(cid, pos,0)
				doSendMagicEffect(pos,10)
				setPlayerStorageValue(cid,4826,os.time())
			else
				doPlayerSendCancel(cid,'Wait.')
				doSendMagicEffect(topos,2)
			end
		else
			doSendMagicEffect(topos,2)
		end
	end
return true
end
read some of the comments inside the script and make the changes that it requires, this script summons the monster based on the your level.
 
Dantarix: here can not speak Spanish unless you are in the Spanish forum. if you can not give you warning xDD [ya me paso xd]

The error of the NPC is rare and when you say bye .. be accrued to close the windows .. I'll try to change the lib and then see if it worked.

Monster on sumon stick, I want to do things that put local and out and remove the lines that no longer serve.
Up: I want to simplify this or a similar one, I do not have levels or anything

thanks also :D
 
Uppppp!


edit: strack don`t work you scrtip :S

always say you're not in the position
 
Last edited:
seems i forgot some about lua, xcuse me :p

corrected (was an error comparing variables, not positions, seems so) :
Lua:
local tpPos1 = {x=33078,y=31080,z= 13}
local tpPos2 = {x=33082,y=31110,z= 2}
 
function onUse(cid, item, fromPosition, itemEx, toPosition)

local Ppos = getCreaturePosition(cid)
 
if item.itemid == 1946 then
	return doTransformItem(item.uid, item.itemid - 1)
end
 
if item.itemid == 1945 then
	if item.actionid == 23232 then
		if Ppos.x ~= tpPos1.x or Ppos.y ~= tpPos1.y or Ppos.z ~= tpPos1.z then
			return doPlayerSendCancel(cid, 'no estas en la posicion correcta') and false
		end
		doTeleportThing(cid, tpPos2)
	elseif item.actionid == 23233 then
		if Ppos.x ~= tpPos2.x or Ppos.y ~= tpPos2.y or Ppos.z ~= tpPos2.z then
			return doPlayerSendCancel(cid, 'no estas en la posicion correcta') and false
		end
		doTeleportThing(cid, tpPos1)
	end
doTransformItem(item.uid, item.itemid + 1)
end
return true
end
 
script #3:
Lua:
---CONFIGURABLE PART---
local pos = {
[1] = {pos ={x=1001, y=1001, z=7}, item = 2269, q=1},
[2] = {pos ={x=999, y=1001, z=7}, item = 2345, q=1},
[3] = {pos ={x=1001, y=999, z=7}, item = 2160, q=2},
[4] = {pos ={x=999, y=999, z=7}, item = 2268, q=5}
}

local monst = {
[1] = {name = 'Demon', pos = {x=1000, y=1009, z=7}},
[2] = {name = 'Demon', pos = {x=1000, y=1009, z=7}},
[3] = {name = 'Demon', pos = {x=1000, y=1009, z=7}},
[4] = {name = 'Demon', pos = {x=1000, y=1009, z=7}}
}
---END OF CONFIGURABLE PART---


function getPosItemCount(pos, itemid) -- it counts top items, not all in the tile

local q = 0
while (getTileThingByPos({x=pos.x, y=pos.y, z=pos.z, stackpos=1}).itemid == itemid) do
	doRemoveItem(getTileThingByPos({x=pos.x, y=pos.y, z=pos.z, stackpos=1}).uid, 1)
	q=q+1
end
if q>0 then
	doCreateItem(itemid, q, {x=pos.x, y=pos.y, z=pos.z})
end
return q
end

function onUse(cid, item, frompos, item2, topos) 

for i=1, #pos do --CHECKING ITEMS FROM POS
	if(getPosItemCount(pos[i].pos, pos[i].item) < pos[i].q) then 
		return doPlayerSendCancel(cid, "Sorry, not enought items.") and false
	end
end

for i=1, #pos do --REMOVING ITEMS FROM TILEPOS
	doRemoveItem(getTileThingByPos({x=pos[i].pos.x, y=pos[i].pos.y, z=pos[i].pos.z, stackpos=1}).uid, pos[i].q)
end

for i=1, #monst do --SUMMNING MONSTERS
	doCreateMonster(monst[i].name, monst[i].pos)
end
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "well done!")
return true
end

not fully tested

it may have some errors/bugs
 
Last edited:
Add new scrtip-
gives me error in position =S
I want to tell me the position where the player but I get error: s
how I can fix it?

local position = getCreaturePosition(cid)

function onSay(cid, words, param, channel)

-- !report
-- by Maxi (Shawak)

level = 10 -- level to post an error

if getPlayerLevel(cid) >= level then
Log = io.open(getDataDir().."logs/Reports (!report).txt", "a+")
Log:write("Date: "..os.date("%d/%m/%y").."\n")
Log:write("From position: X = "..position.x.." | Y = "..position.y.." | Z = "..position.z.."\n")
Log:write(""..getPlayerName(cid)..": "..param.."\n\n")
Log:close()
doPlayerSendTextMessage(cid,TALKTYPE_ORANGE_1,"Report Manager: Report have successfully sent.")
else
doPlayerSendTextMessage(cid,TALKTYPE_ORANGE_1,"Report Manager: You have to be level "..level.." to post an error.")
end
return TRUE
end
 
Lua:
function onSay(cid, words, param, channel)
	local position, level, storage = getCreaturePosition(cid), 10, 5564
	if exhaustion.check(cid, storage) == false then
		if getPlayerLevel(cid) >= level then
			Log = io.open(getDataDir()..'logs/Reports (!report).txt', 'a+')
			Log:write('Date: '..os.date('%d/%m/%y')..'\n')
			Log:write('From position: X = ' .. position.x .. ' | Y = ' .. position.y .. ' | Z = ' .. position.z .. '\n')
			Log:write('' .. getPlayerName(cid) .. ': ' .. param .. '\n\n')
			Log:close()
			doPlayerSendTextMessage(cid,TALKTYPE_ORANGE_1, 'Report Manager: Report have successfully sent.')
			exhaustion.set(cid, storage, 15)
		else
			doPlayerSendTextMessage(cid,TALKTYPE_ORANGE_1, 'Report Manager: You have to be level ' .. level .. ' to post an error.')
		end
	else
		doPlayerSendCancel(cid, 'You should wait ' ..exhaustion.get(cid, storage)..' sec to write report again.')
	end
	return TRUE
end
 
Last edited:
Back
Top Bottom