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

Monster by switches

MrSlisk

Slirre
Joined
Sep 10, 2008
Messages
33
Reaction score
0
Location
Sweden
I wounder if there is someone who could explain step-by-step
how to get a monster to be summoned by a switch
like.. When I use the switch the monster get summoned.
I'd respect if you would not write just the code, please explain it to :D


And yes, i am very new to this kinda stuffs,
so please don't call me a 'noob' or something like that, do something useful instead ;s
 
In your map editor, place the switch on the map, right click on it and give it an unique ID. Next, go to your data/actions/scripts/ folder and create a new script using the onUse function *onUse(cid, item, fromPosition, itemEx, toPosition)*. Once you finish your script go back to the actions folder, open actions.xml in a text editor (ie. notepad) and add the action somewhere in this form *<action uniqueid="uuuu" script="ssss.lua" />*. uuuu = the unique ID you gave the switch, ssss = the name of the script you made. If you put the script inside of one of the folders (ie. other) use script="other/ssss.lua". I hope I explained that good enough.

*NOTE* - You can check the annihilator script in the quest folder to get an idea how to use the onUse function, since it uses a switch also.

Jo3
 
Thanks, i get the most now :)
but.. what do you mean with "..and give it an unique ID"?
Do you mean the monster ID or just any ID?
 
Last edited:
Go to data/actions/scripts/other and make a new text file and name it summonBySwitch.lua, or whatever you want, and put this code:
Code:
local cPos = {x = 123, y = 456, z = 7}

function onUse(cid, item, fromPosition, itemEx, toPosition)
	if item.uid == 12345 and item.itemid == 1945 then
		doSummonCreature("Rat", cPos)
	end
end
The only thing you'll need to change is cPos coordinates and 12345 to the unique ID of the switch. (Make sure the switch you add to the map is the switch with ID 1945, else change the switch or the ID in the script.)
Now go back to the actions folder, open actions.xml and add this line some where:
Code:
<action uniqueid="12345" script="other/summonBySwitch.lua" />
Of course change 12345 to the unique ID of the switch.

*NOTE* - I didn't test it, but it should work

Jo3
 
I would just use the same script and do like this:
Code:
local aPos = {x = 123, y = 456, z = 7}
local bPos = {x = 890, y = 123, z = 4}
local cPos = {x = 567, y = 890, z = 1}

function onUse(cid, item, fromPosition, itemEx, toPosition)
	if item.uid == 12345 and item.itemid == 1945 then
		doSummonCreature("Rat", aPos)
	elseif item.uid == 67890 and item.itemid == 1945 then
		doSummonCreature("Cave Rat", bPos)
	elseif item.uid == 24680 and item.itemid == 1945 then
		doSummonCreature("Bat", cPos)
	end
end

Jo3
 
It worked, thanks! ;)
It would be nice if you can explain how to put monster positions and how to make it exhaust like.. 10sec or something, if you understand what i mean :)
 
Back
Top