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

Easy to use LMS

gigastar

Member
Joined
Jan 25, 2009
Messages
252
Reaction score
15
I know there are 100 out there. I just wanted to give out an easy configurable one.

Code:
local access = 3

local LMS_STARTED = 33231
local LMS_PLAYER = 33232
local LMS_PLAYERS = 33233

local max_players = 50
local min_players = 15

local LMS_top_left, LMS_bottom_right = {x = 1000, y = 1000, z = 1000}, {x = 1000, y  = 1000, z = 7}
local LMS_area = LMS_top_left, LMS_bottom_right

local minutes_to_start = 5

local time_start_after_not_enough_players = 20 -- time in minutes.

local server_normal_deathloss_percent = 10

function onSay(cid, words, param, channel)
------------START LMS----------------
if (words == "!lms start!") then
   if getPlayerAccess(cid) < access then
     doPlayerSendCancel(cid, "you cannot execute this talkaction.")
   return false
   end
   else
 
   if getGlobalStorageValue(LMS_STARTED) == 0 then
     doBroadcastMessage("LMS has started! type !lms to join the game. It will start in " ..minutes_to_start.. " minutes.", 1)
     setGlobalStorageValue(LMS_STARTED, 1)
     addEvent(startLMS, minutes_to_start * 60 * 1000)
   else
     doPlayerSendCancel(cid, "LMS is already going.")
     return false
   end
-------------STOP LMS WITHOUT WINNER---------------
elseif (words == "!lms stop") then
   if getPlayerAccess(cid) < access then
     doPlayerSendCancel(cid, "You cannot execute this talkaction.")
   end
   if getGlobalStorageValue(LMS_STARTED) == 1 then
     setGlobalStorageValue(LMS_STARTED, 0)
     setGlobalStorageValue(LMS_PLAYERS, 0)
     for i, pid in ipairs(getThingFromPos(LMS_area).uid) do
       if isPlayer(pid) then
         doTeleportThing(pid, getCreatureMasterTownId(pid))
         doPlayerSendTextMessage(pid, 22, "A staff member has ended the event.")
         setPlayerStorageValue(pid, LMS_PLAYER, 0)
       end
     end
   else
     doPlayerSendCancel(cid, "LMS is not going.")
   return false
   end
-------------JOIN LMS AS PLAYER--------------
elseif (words == "!lms") then
   if getGlobalStorageValue(LMS_STARTED) == 1 then
     if getGlobalStorageValue(LMS_PLAYERS) < max_players then
       if getPlayerStorageValue(cid, LMS_PLAYER) ~= 1 then
         setPlayerStorageValue(cid, LMS_PLAYER, 1)
         doPlayerSendTextMessage(cid, 22, "You are queued in LMS.")
         setGlobalStorageValue(LMS_PLAYERS +1)
         doPlayerSetLossPercent(cid, 1, 0)
       else
         doPlayerSendCancel(cid, "You are already qeued in LMS.")
       return false
       end
     else
     doPlayerSendCancel(cid, "The queue is full.")
     return false
     end
   else
     doPlayerSendCancel(cid, "LMS is not going.")
   return false
   end
end
end

------------LMS STARTS UP---------------
local function startLMS()
-------------NOT ENOUGH PLAYERS---------------
if getGlobalStorageValue(LMS_PLAYERS) < min_players then
   setGlobalStorageValue(LMS_STARTED, 0)
   setGlobalStorageValue(LMS_PLAYERS, 0)
for i, pid in ipairs(getPlayersOnline()) do
   if getPlayerStorageValue(pid, LMS_PLAYER) > 0 then
     doSetPlayerStorageValue(pid, LMS_PLAYER, 0)
     doPlayerSendTextMessage(pid, 22, "There were not enough players in LMS for it to start.")
   return false
   end
end
doBroadcastMessage("LMS will start after " ..time_start_after_not_enough_players.. " minutes.", 1)
addEvent(openLMS, time_start_after_not_enough_players * 60 * 1000)

else
----------ENOUGH PLAYERS-----------------
for i, pid in ipairs(getPlayersOnline()) do
   if getPlayerStorageValue(pid, LMS_PLAYER) == 1 then
     local rand_tiles = math.random(getThingFromPos(LMS_AREA))
     local rand_tiles2 = getThingFromPos(rand_tiles).uid
     if isTile(rand_tiles) and not isPlayer(rand_tiles2) then
       doTeleportThing(pid, rand_tiles)
     end
   end
end
doBroadcastMessage("LMS has started!, 1")
addEvent(stopLMS, 30 * 1000)
end
end
--------LMS FINISH--------------
local function stopLMS()
if getGlobalStorageValue(LMS_PLAYERS) == 1 then
   for i, pid in ipairs(getPlayersOnline()) do
     if getPlayerStorageValue(pid, LMS_PLAYER) == 1 then
       doTeleportThing(pid, getPlayerMasterTownId(pid))
       doBroadcastMessage("Player " ..getPlayerName(pid).. " has won the LMS event!", 1)
       setPlayerStorageValue(pid, LMS_PLAYER, 0)
       setGlobalStorageValue(LMS_PLAYERS, 0)
       setGlobalStorageValue(LMS_STARTED, 0)
     end
   end
else
addEvent(stopLMS, 30 * 1000)
end
end


CreatureScript
Code:
function onKill(cid, target)
if getPlayerStorageValue(target, LMS_PLAYER) == 1 then
   setPlayerStorageValue(target, LMS_PLAYER, 0)
   doTeleportThing(target, getPlayerMasterTownId(target))
   doPlayerSendTextMessage(target, 22, "You have died during the LMS event. Better luck next time.")
   setGlobalStorageValue(LMS_PLAYERS - 1)
end
end
 
Last edited:
Code:
doPlayerSendTextMessage(cid, 22, "You have died during the LMS event. Better luck next time.")
this code is in creaturescript.it should be "target" not "cid" since you are using "onkill" not "onpreparedeath"

Anyway thanks for your contribution
 
Where do i put the First code?

-------------------
Editing this 6 months later:

What a noob I use to be... and still am :(
 
Last edited:
Back
Top