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

Solved Start raid command

strutZ

Australian OT Member {AKA Beastn}
Joined
Nov 16, 2014
Messages
1,393
Solutions
7
Reaction score
552
Hey otland,

I'm working on my next modal window script for TFS 1.1 - 1.2, The idea is the player can either use an item or put money/item on a table use lever and he can select a raid from a modalwindow and start it.

I cant seem to find the command to start a raid? i have found this in my command.cpp


Code:
void Commands::forceRaid(Player& player, const std::string& param)
{
   Raid* raid = g_game.raids.getRaidByName(param);
   if (!raid || !raid->isLoaded()) {
     player.sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "No such raid exists.");
     return;
   }

   if (g_game.raids.getRunning()) {
     player.sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Another raid is already being executed.");
     return;
   }

   g_game.raids.setRunning(raid);

   RaidEvent* event = raid->getNextRaidEvent();
   if (!event) {
     player.sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "The raid does not contain any data.");
     return;
   }

   raid->setState(RAIDSTATE_EXECUTING);

   uint32_t ticks = event->getDelay();
   if (ticks > 0) {
     g_scheduler.addEvent(createSchedulerTask(ticks, std::bind(&Raid::executeRaidEvent, raid, event)));
   } else {
     g_dispatcher.addTask(createTask(std::bind(&Raid::executeRaidEvent, raid, event)));
   }

   player.sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Raid started.");
}

But i have no clue how to use it.. I'm starting to think that i will need to edit sources if i want this to happen? any help would be awesome. Thanks.
 
Hey otland,

I'm working on my next modal window script for TFS 1.1 - 1.2, The idea is the player can either use an item or put money/item on a table use lever and he can select a raid from a modalwindow and start it.

I cant seem to find the command to start a raid? i have found this in my command.cpp


Code:
void Commands::forceRaid(Player& player, const std::string& param)
{
   Raid* raid = g_game.raids.getRaidByName(param);
   if (!raid || !raid->isLoaded()) {
     player.sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "No such raid exists.");
     return;
   }

   if (g_game.raids.getRunning()) {
     player.sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Another raid is already being executed.");
     return;
   }

   g_game.raids.setRunning(raid);

   RaidEvent* event = raid->getNextRaidEvent();
   if (!event) {
     player.sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "The raid does not contain any data.");
     return;
   }

   raid->setState(RAIDSTATE_EXECUTING);

   uint32_t ticks = event->getDelay();
   if (ticks > 0) {
     g_scheduler.addEvent(createSchedulerTask(ticks, std::bind(&Raid::executeRaidEvent, raid, event)));
   } else {
     g_dispatcher.addTask(createTask(std::bind(&Raid::executeRaidEvent, raid, event)));
   }

   player.sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Raid started.");
}

But i have no clue how to use it.. I'm starting to think that i will need to edit sources if i want this to happen? any help would be awesome. Thanks.
To start a raid on your GOD character > /raid RAID_NAME_HERE

Start a raid, inside a script file.
https://github.com/otland/forgotten...725e735368ee1c74bd118/src/luascript.cpp#L4828
 
To start a raid on your GOD character > /raid RAID_NAME_HERE

Start a raid, inside a script file.
https://github.com/otland/forgotten...725e735368ee1c74bd118/src/luascript.cpp#L4828
Thanks for reply man. I'm wanting players to start the raid not GODS.

This
Code:
int LuaScriptInterface::luaGameStartRaid(lua_State* L)
{
    // Game.startRaid(raidName)
    const std::string& raidName = getString(L, 1);

    Raid* raid = g_game.raids.getRaidByName(raidName);
    if (raid) {
        raid->startRaid();
        pushBoolean(L, true);
    } else {
        lua_pushnil(L);
    }
    return 1;
}
is what i'm having trouble with. I don't understand how to use that in a lua.
 
SOLVED:

Code:
local raidName = "Orcs"

function onUse(cid, item, fromPosition, itemEx, toPosition)
Game.startRaid(raidName)
doCreatureSay(cid, "I start ".. raidName .." raid now!", TALKTYPE_ORANGE_1)
doRemoveItem(item.uid, 1)
end

Forgot the capital R.. zzzz
 
SOLVED:

Code:
local raidName = "Orcs"

function onUse(cid, item, fromPosition, itemEx, toPosition)
Game.startRaid(raidName)
doCreatureSay(cid, "I start ".. raidName .." raid now!", TALKTYPE_ORANGE_1)
doRemoveItem(item.uid, 1)
end

Forgot the capital R.. zzzz
Sorry, went to bed :P

Glad you figured it out yourself.
If you need, you can find other useful stuff in luascript.cpp file.
 
Sorry, went to bed :p

Glad you figured it out yourself.
If you need, you can find other useful stuff in luascript.cpp file.
No good enough man. How dare you sleep!

In all serious though, Thanks for the point in the right direction ;) I knew there was a file in my sources somewhere that would tell me just didnt know where haha so thanks for that again ;)
 
Back
Top