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

[Actions] ítem - monster

samuelav3

Member
Joined
Aug 18, 2014
Messages
95
Reaction score
5
Hey anyone help me pls i need an item That i need to make item click this becomes a random monster
 
You can make a table with the monsters.
Code:
local monsters = {"Snake", "Rat", "Sheep"}

To remove the item and create the random monster.
Code:
Item(item.uid):remove()
Game.createMonster(monsters[math.random(#monsters)], toPosition)
 
I would assume it would be an action script.

Try to find a similar script, and edit it it yourself.
Or try to code it yourself using this terrible code!

Code:
local monster = {"blah", "blah"}
Function onUse (cid blah blah)
send player message "omg a monster!"
remove item
create monster
return true
end
 
Only thing you have to do is add the main function onUse with return true end like Xikini posted, but then with right parameters :p
 
I get an error
qyxQx_k.png


Code:
local monster = {"rat", "pig"}
function onUse(cid, item, toPosition)
doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, "omg a monster!")  --send player message "omg a monster!"
Item(item.uid):remove() --remove item
Game.createMonster(monsters[math.random(#monsters)], toPosition) --create monster
return true
end
 
Change local monster to local monsters.
The parameters of the main function onUse in TFS 1.0 are this.
Code:
function onUse(cid, item, fromPosition, itemEx, toPosition, isHotkey)
 
ok there is no problem with the console but still not the monster is created

Code:
local monster = {"rat", "pig"}

function onUse(cid, item, fromPosition, itemEx, toPosition, isHotkey)
doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, "omg a monster!")
Item(item.uid):remove() 
Game.createMonster(monster[math.random(#monster)], toPosition)
return true
end
 
I get an error
qyxQx_k.png


Code:
local monster = {"rat", "pig"}
function onUse(cid, item, toPosition)
doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, "omg a monster!")  --send player message "omg a monster!"
Item(item.uid):remove() --remove item
Game.createMonster(monsters[math.random(#monsters)], toPosition) --create monster
return true
end
a useful shortcut to remember if you want to get a screenshot of a certain window is
Code:
ctrl+alt+shift+Prt Sc
This will 'Print Screen' the current window, and will save you countless seconds. :)
Also good work in your first attempt at the script. :p
 
Back
Top