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

Itutorial's Scripting Service TFS 0.3.6-0.4-1.x

Itutorial

Legendary OT User
Joined
Dec 23, 2014
Messages
2,337
Solutions
68
Reaction score
1,018
As the title says.

Format:
-Distro
-explination of code needed as detailed as possible
-Pictures if required of map set up for code

I don't usually mess with C++ but if I know I can do something that you request I will.
 
Code:
int32_t LuaInterface::luaDoPlayerCancelTarget(lua_State* L)
{
    //doPlayerCancelTarget(cid, target)
    ScriptEnviroment* env = getEnv();
    Player* player = env->getCreatureByUID(popNumber(L));
    if(!player)
    {
        errorEx(getError(LUA_ERROR_CREATURE_NOT_FOUND));
        lua_pushboolean(L, false);
        return 1;
    }
   
    Creature* target = player->getTarget();
    if(!target)
    {
        errorEx(getError(LUA_ERROR_CREATURE_NOT_FOUND));
        lua_pushboolean(L, false);
        return 1;
    }
   
    player->sendCancelTarget();
    player->sendCreatureDisappear(target, target->getPosition().stackpos);
    player->sendCreatureAppear(target);
    lua_pushboolean(L, true);
    return 1;
}
 
I really hate c++

Code:
int32_t LuaInterface::luaDoPlayerCancelTarget(lua_State* L)
{
    //doPlayerCancelTarget(cid, target)
    ScriptEnviroment* env = getEnv();
    Creature* player = env->getCreatureByUID(popNumber(L));
    if(!player)
    {
        errorEx(getError(LUA_ERROR_CREATURE_NOT_FOUND));
        lua_pushboolean(L, false);
        return 1;
    }
 
    player->sendCancelTarget();
    player->setAttackedCreature(NULL);
    player->onAttackedCreatureDisappear(false);
    lua_pushboolean(L, true);
    return 1;
}
 
Last edited:
edited above

In static member function `static int32_t LuaInterface::luaDoPlayerCancelTarget(lua_State*)':
....trunk.r3884\luascript.cpp invalid conversion from `Creature*' to `Player*'
....trunk.r3884\dev-cpp\Makefile.win [Build Error] [obj//luascript.o] Error 1
 
Try it now, this is giving me a head ache.

I imagine hahaha

erro:
In static member function `static int32_t LuaInterface::luaDoPlayerCancelTarget(lua_State*)':
...luascript.cpp 'class Creature' has no member named 'sendCancelTarget'
...trunk.r3884\dev-cpp\Makefile.win [Build Error] [obj//luascript.o] Error 1
 
Code:
int32_t LuaInterface::luaDoPlayerCancelTarget(lua_State* L)
{
    //doPlayerCancelTarget(cid, target)
    ScriptEnviroment* env = getEnv();
    Player* player = env->getPlayerByUID(popNumber(L));
    if(!player)
    {
        errorEx(getError(LUA_ERROR_CREATURE_NOT_FOUND));
        lua_pushboolean(L, false);
        return 1;
    }

    player->sendCancelTarget();
    player->setAttackedCreature(NULL);
    player->onAttackedCreatureDisappear(false);
    lua_pushboolean(L, true);
    return 1;
}
 

Compile this part successfully. I'll wait finish the compilation and test the spell, so I'll comeback to say if the spell worked or not.
 
@Itutorial are you able to work on this:
a barrel that you use with action and it explode in area like GFB rune? the area cannot be squared, that is the thing that can't reproduce yet, the area should be configurable, as area_circle3x3 or circle_4x4
 
I need a script, which for example has 3 players in my view, when I use Spell, they attack me.
TFS 1.3
 
Last edited:
@Huntre use inglês, você está num fórum que tem como linguagem principal o inglês, talvez o cara nem entenda

eng version:
use english, you're in forum that uses english as main language, maybe the guy don't understand
 
You want it to send a message to where? To the location they teleported? or send a message where they teleported from?

To the location they teleported, like "you were teleported to XXX"

PS. and when the player gets teleported, close the modalwindow, right now it stands open when the player is teleported
 
Last edited:
@Itutorial are you able to work on this:
a barrel that you use with action and it explode in area like GFB rune? the area cannot be squared, that is the thing that can't reproduce yet, the area should be configurable, as area_circle3x3 or circle_4x4

Please make sure to include your distro.
 
To the location they teleported, like "you were teleported to XXX"

PS. and when the player gets teleported, close the modalwindow, right now it stands open when the player is teleported

Change this in your creaturescript

Lua:
local teleports = {
    [0x00] = {cost = 0, pos = {x = 314, y = 102, z = 7}, text = "Rotworms"},
    [0x01] = {cost = 0, pos = {x = 675, y = 245, z = 7}, text = "Hero Fortress"},
    [0x02] = {cost = 0, pos = {x = 765, y = 451, z = 7}, text = "Asura Palace"},
    [0x03] = {cost = 0, pos = {x = 862, y = 598, z = 7}, text = "Mistrock"},
    [0x04] = {cost = 0, pos = {x = 846, y = 456, z = 6}, text = "Yielothax"},
    [0x05] = {cost = 0, pos = {x = 1387, y = 1798, z = 7}, text = "Roshamuul"},
    [0x06] = {cost = 0, pos = {x = 69, y = 771, z = 7}, text = "Wind Temple"},
    [0x07] = {cost = 0, pos = {x = 54, y = 711, z = 7}, text = "Wind Depot"},
    [0x08] = {cost = 0, pos = {x = 73, y = 733, z = 6}, text = "Magic Shop"},
    [0x09] = {cost = 0, pos = {x = 35, y = 791, z = 7}, text = "Distance Shop"},
    [0x10] = {cost = 0, pos = {x = 86, y = 755, z = 7}, text = "Rashid"},
    [0x11] = {cost = 0, pos = {x = 229, y = 689, z = 7}, text = "Wrrm"},
    [0x12] = {cost = 0, pos = {x = 276, y = 658, z = 7}, text = "Behemoth"},
    [0x13] = {cost = 0, pos = {x = 468, y = 448, z = 7}, text = "Neutral Nation"},
    [0x14] = {cost = 0, pos = {x = 950, y = 1082, z = 12}, text = "Glooth Bandit"},
    [0x15] = {cost = 0, pos = {x = 872, y = 933, z = 6}, text = "Oramond"},
    [0x16] = {cost = 0, pos = {x = 607, y = 603, z = 10}, text = "Fire Temple"},
    [0x17] = {cost = 0, pos = {x = 586, y = 603, z = 10}, text = "Fire Depot"},
    [0x18] = {cost = 0, pos = {x = 611, y = 637, z = 7}, text = "Magic Shop"},
    [0x19] = {cost = 0, pos = {x = 554, y = 653, z = 7}, text = "Distance Shop"},
    [0x20] = {cost = 0, pos = {x = 559, y = 589, z = 7}, text = "Rashid"},
    [0x21] = {cost = 0, pos = {x = 367, y = 198, z = 7}, text = "Rotworms"},
    [0x22] = {cost = 0, pos = {x = 750, y = 451, z = 7}, text = "Asura Palace"},
    [0x23] = {cost = 0, pos = {x = 827, y = 943, z = 4}, text = "Oramond"},
    [0x24] = {cost = 0, pos = {x = 1351, y = 1789, z = 7}, text = "Roshamuul"},
    [0x25] = {cost = 0, pos = {x = 858, y = 599, z = 7}, text = "Mistrock"},
    [0x26] = {cost = 0, pos = {x = 282, y = 419, z = 7}, text = "Dragons"},
    [0x27] = {cost = 0, pos = {x = 488, y = 440, z = 6}, text = "Neutral Nation"},
    [0x28] = {cost = 0, pos = {x = 672, y = 241, z = 7}, text = "Hero Fortress"},
    [0x29] = {cost = 0, pos = {x = 871, y = 965, z = 12}, text = "Glooth Bandits"},
    [0x30] = {cost = 0, pos = {x = 681, y = 487, z = 8}, text = "Earth Temple"},
    [0x31] = {cost = 0, pos = {x = 700, y = 494, z = 7}, text = "Earth Depot"},
    [0x32] = {cost = 0, pos = {x = 660, y = 426, z = 7}, text = "Magic Shop"},
    [0x33] = {cost = 0, pos = {x = 599, y = 402, z = 6}, text = "Distance Shop"},
    [0x34] = {cost = 0, pos = {x = 696, y = 478, z = 6}, text = "Rashid"},
    [0x35] = {cost = 0, pos = {x = 274, y = 194, z = 6}, text = "Rotworms"},
    [0x36] = {cost = 0, pos = {x = 695, y = 360, z = 8}, text = "Medusa Tower"},
    [0x37] = {cost = 0, pos = {x = 827, y = 191, z = 7}, text = "Serpent Spawn"},
    [0x38] = {cost = 0, pos = {x = 774, y = 449, z = 7}, text = "Asura Palace"},
    [0x39] = {cost = 0, pos = {x = 846, y = 941, z = 6}, text = "Oramond"},
    [0x40] = {cost = 0, pos = {x = 1366, y = 1799, z = 7}, text = "Roshamuul"},
    [0x41] = {cost = 0, pos = {x = 856, y = 605, z = 7}, text = "Mistrock"},
    [0x42] = {cost = 0, pos = {x = 586, y = 400, z = 7}, text = "Earth Elemental"},
    [0x43] = {cost = 0, pos = {x = 953, y = 1089, z = 12}, text = "Glooth Bandit"},
    [0x44] = {cost = 0, pos = {x = 472, y = 463, z = 7}, text = "Neutral Nation"},
    [0x45] = {cost = 0, pos = {x = 667, y = 251, z = 7}, text = "Hero Fortress"}


}
function onModalWindow(player, modalWindowId, buttonId, choiceId)
    if modalWindowId ~= 1860 then return true end
    if buttonId == 0x01 then return true end
    local CHOICE = teleports[choiceId]
    if not CHOICE then return true end
    if player:removeMoney(CHOICE.cost) then
        player:teleportTo(CHOICE.pos)
        player:say(CHOICE.text, TALKTYPE_MONSTER_SAY, 0, 1, player:getPosition())
    else
        player:sendCancelMessage("This teleport costs "..CHOICE.cost.." to use.")
    end
return true
end
 
I am not sure what you are talking about, and I don't believe you completely understand what your talking about either. The id's that are given to each choice isn't relevant it can be anything.
 
Back
Top