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

Scripting

XxDeathAvenger

New Member
Joined
May 5, 2011
Messages
95
Reaction score
2
How do you script? I know that's a bad question, I just look at the scripts and they confuse me because I know nothing about it. Could someone give me a really quick explanation?
 
Code:
local time = 5 -- minutes
local function doSendPlayerTimeMessage(cid)
  if isPlayer(cid) then
  doPlayerSendTextMessage(cid, MESSAGE_STATUS_WARNING, "Thirty seconds until your disguise breaks!")
  end
  return true
end

function onUse(cid, item, fromPosition, itemEx, toPosition)
   doRemoveItem(item.uid, 1)
   doSetMonsterOutfit(cid, "necromancer costume", time * 1000 * 60)
   doPlayerSendTextMessage(cid, MESSAGE_STATUS_WARNING, "Five minutes until your disguise breaks!")
   -- doPlayerSendTextMessage(cid, 20, "Five minutes until your disguise breaks!")
   addEvent(doSendPlayerTimeMessage, 4.5 * 60 * 1000, cid)
   return true
end

--[[

function is basically telling the server to 'run' this thing.. which is located in source.
In this case it's a onUse script.. the rest is just stuff to easily call things in the script.
cid = the player or creature using the object.
item, is the item being used
fromPosition/toPosition is based on location of cid/item
itemEx is used when you use an item on something. (a shovel on the ground.. a rune on a player)

Inside the main function you can call pre-made functions and stuff

doRemoveItem.. does exactly what is says.. .uid stand for uniqueID .. which every object has a different uid.

Most of the rest is simply trial and error if your just starting out

Idk how to explain it.. but if you want to learn more, look online for lua tutorials, or coding tutorials in general.

]]--
 
Back
Top