MoveEvent Summon monster, walking on tile (features: interval & storageid)

frankfarmer

who'r ninja now
Joined
Aug 5, 2008
Messages
1,472
Best answers
0
Reaction score
30
Location
swe?
Ok here it goes, please all pro's look at the script and see if there is something wrong. This is my first try to script ever. You have to change the "XXXX" in the script.

Code:
-- idea by frankfarmer/fragdonut and script by cykotitan
-- step on tile and summon monster

local t = {
	storage = 32000, --storageid
	interval = 60, --how many seconds until next
	monster = {"Demon", {x=100, y=100, z=7}}, -- monster and coords
	msg = "It's too quiet here..." -- message players get
}
function onStepIn(cid, item, position, fromPosition)
	if os.difftime(os.time(), getGlobalStorageValue(t.storage)) >= t.interval then       
		doCreatureSay(cid, t.msg, TALKTYPE_ORANGE_1)
		doSummonCreature(t.monster[1], t.monster[2])
		setGlobalStorageValue(t.storage, os.time())
	end
end
The script works as followed; Player walk in a dungeon, step on a tile, it sents a message in orange on the screen and at the same time it summons a demon at a specific location also added questvalue so that the player can only do this one time.

Edit: Script now has a delay function and if 4 players enters a dungeon then the first player stepping on the tile will get a message and it will summon a monster. The 3 other players will not do any summons/or text messages.. until delay is over.
 
Last edited:

Cykotitan

Experienced G'
Joined
Nov 4, 2008
Messages
16,894
Best answers
4
Reaction score
817
Code:
local t = {
	storage = 32000,
	monster = {"Demon", {x=100, y=100, z=7}},
	msg = "It's too quiet here..."
}
function onStepIn(cid, item, position, fromPosition)
	if getPlayerStorageValue(cid, t.storage) < 1 then       
		doCreatureSay(cid, t.msg, TALKTYPE_ORANGE_1)
		doSummonCreature(t.monster[1], t.monster[2])
		setPlayerStorageValue(cid, t.storage, 1)
	end
	return TRUE
end
You should always make your scripts configurable.

And try to use code tags instead of lua.
 
OP
frankfarmer

frankfarmer

who'r ninja now
Joined
Aug 5, 2008
Messages
1,472
Best answers
0
Reaction score
30
Location
swe?
Code:
local t = {
	storage = 32000,
	monster = {"Demon", {x=100, y=100, z=7}},
	msg = "It's too quiet here..."
}
function onStepIn(cid, item, position, fromPosition)
	if getPlayerStorageValue(cid, t.storage) < 1 then       
		doCreatureSay(cid, t.msg, TALKTYPE_ORANGE_1)
		doSummonCreature(t.monster[1], t.monster[2])
		setPlayerStorageValue(cid, t.storage, 1)
	end

end
You should always make your scripts configurable.

And try to use code tags instead of lua.
Thanks alot, did not know about that
Code:
local t = {
	storage = 32000,
	monster = {"Demon", {x=100, y=100, z=7}},
	msg = "It's too quiet here..."
}
thing :)

Thanks! Edited main post
 

Cykotitan

Experienced G'
Joined
Nov 4, 2008
Messages
16,894
Best answers
4
Reaction score
817
also there's no need to return anything in movements
 

cbrm

Top Class brunet scripter
Staff member
Global Moderator
Joined
Jan 6, 2009
Messages
6,585
Best answers
3
Reaction score
852
Location
Caribbean Sea
Lua:
 if getPlayerStorageValue(cid, t.storage) ~= 1 then   

or

 if getPlayerStorageValue(cid, t.storage) == -1 then
i know it isnt necessary but its more pro
it means: if the storage for this player doesnt exist then...
 

Fragdonut

Banned User
Joined
Jul 27, 2009
Messages
2,606
Best answers
0
Reaction score
0
Location
HDUXZZZ13387
nice
I'd love an version which could only be used each minute, like if I use this for a quest then all players would summon one monster and with an exhaust on it only one player would summon the monster
 

Cykotitan

Experienced G'
Joined
Nov 4, 2008
Messages
16,894
Best answers
4
Reaction score
817
Lua:
if getPlayerStorageValue(cid, t.storage) ~= 1 then
should be like that, i know it isnt necessary but its more pro
it means: if the storage for this player doesnt exist then...
that would be less pro
you mean
Code:
return true
?
no, you don't need to return anything
nice
I'd love an version which could only be used each minute, like if I use this for a quest then all players would summon one monster and with an exhaust on it only one player would summon the monster
Code:
local t = {
	storage = 32000,
	interval = 60,
	monster = {"Demon", {x=100, y=100, z=7}},
	msg = "It's too quiet here..."
}
function onStepIn(cid, item, position, fromPosition)
	if os.difftime(os.time(), getGlobalStorageValue(t.storage)) >= t.interval then       
		doCreatureSay(cid, t.msg, TALKTYPE_ORANGE_1)
		doSummonCreature(t.monster[1], t.monster[2])
		setGlobalStorageValue(t.storage, os.time())
	end
end
 
Last edited:
OP
frankfarmer

frankfarmer

who'r ninja now
Joined
Aug 5, 2008
Messages
1,472
Best answers
0
Reaction score
30
Location
swe?
Im fucking proud I actually made something.. rofl
 

chojrak

Banned User
Joined
Oct 25, 2008
Messages
5,832
Best answers
2
Reaction score
158
@Cyber:
The prost is:
Code:
if(getPlayerStorageValue(cid, t.storage) == EMPTY_STORAGE) then
 
Top