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

Feature Party Invitation

tetra20

DD
Joined
Jan 17, 2009
Messages
1,315
Solutions
4
Reaction score
323
Location
Egypt
Hi Again. i made this function because i was playing ascalon and i wanted to make a party and as we know tibia sux the player must be near you to invite him thats why i made this function to invite and join party from far away
----------------
Before I Start I want To Give Credits
1-TeckMan For The c++ Code.
2-Me For The Idea And Lua Codes + some edits in c++ code
----------------
Warning
Don't Edit Anything Just Copy And Paste Unless you know what you are doing
----------------
How To Use InGame:
!invite PlayerName
!join PlayerName
----------------
Lets Get Started With ScreenShot First
v6FqtB.png

Then
ucPL2U.png

-------------------
Ok Now C++ Codes

Open luascript.cpp

Find
Code:
int32_t LuaInterface::luaDoPlayerJoinParty(lua_State* L)
{
   //doPlayerJoinParty(cid, lid)
   ScriptEnviroment* env = getEnv();

   Player* leader = env->getPlayerByUID(popNumber(L));
   if(!leader)
   {
     errorEx(getError(LUA_ERROR_PLAYER_NOT_FOUND));
     lua_pushboolean(L, false);
   }

   Player* player = env->getPlayerByUID(popNumber(L));
   if(!player)
   {
     errorEx(getError(LUA_ERROR_PLAYER_NOT_FOUND));
     lua_pushboolean(L, false);
   }

   g_game.playerJoinParty(player->getID(), leader->getID());
   lua_pushboolean(L, true);
   return 1;
}
Add This After It
Code:
int32_t LuaInterface::luaDoPlayerInviteToParty(lua_State* L)
{
   //doPlayerInviteToParty(cid, pid)
   ScriptEnviroment* env = getEnv();
   Player* leader = env->getPlayerByUID(popNumber(L));
   if(!leader)
   {
     errorEx(getError(LUA_ERROR_PLAYER_NOT_FOUND));
     lua_pushboolean(L, false);
   }

   Player* player = env->getPlayerByUID(popNumber(L));
   if(!player)
   {
     errorEx(getError(LUA_ERROR_PLAYER_NOT_FOUND));
     lua_pushboolean(L, false);
   }
   if(player->getName() == leader->getName())
   {
     lua_pushboolean(L, false);
   }
   g_game.playerInviteToParty(player->getID(), leader->getID());
   lua_pushboolean(L, true);
   return 1;
}

find
Code:
//getTownName(townId)
    lua_register(m_luaState, "getTownName", LuaInterface::luaGetTownName);

Add After It

Code:
 //doPlayerInviteToParty(cid, pid)
    lua_register(m_luaState, "doPlayerInviteToParty", LuaInterface::luaDoPlayerInviteToParty);

Open Luascript.h

Find
Code:
        static int32_t luaSetCreatureName(lua_State* L);

Add This After It
Code:
static int32_t luaDoPlayerInviteToParty(lua_State* L);

Now Compile C++ Part Done
------------

Open YourData/talkaction/scripts/create a new file called invite.lua

Add This
Code:
function onSay(cid, words, param, channel)
local lid = getPlayerByName(""..param.."")
local pid = getPlayerByName(""..cid.."")
if(not(getPlayerByName(param))) then
doPlayerSendCancel(cid, "There is no such player nor it exists.")
doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
return true
end

if isInParty(lid) then
doPlayerSendCancel(cid, "The Target Player Is In Party")
doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
return true
end

if param == "" then
doPlayerSendCancel(cid, "Please Enter Player Name")
doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
return true
end

if(getCreatureCondition(cid, CONDITION_INFIGHT)) then
doPlayerSendCancel(cid, "You Are InFight")
doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
return true
end

if string.lower(getCreatureName(cid)) == string.lower(param) then
doPlayerSendCancel(cid, "Can't Invite Yourself")
doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
return true
end

    if isPlayer(cid) then
    doPlayerInviteToParty(cid,lid)
    doPlayerSetStorageValue(cid, 9001, 1)
    doPlayerSendTextMessage(lid, 27,"To Join Write (!join "..getCreatureName(cid)..").")
    end
    return true
    end

Create talkactions/scripts/join.lua

Add This
Code:
function onSay(cid, words, param, channel)
local lid = getPlayerByName(""..param.."")
local pid = getPlayerByName(""..cid.."")

if(not(getPlayerByName(param))) then
doPlayerSendCancel(cid, "There is no such player nor it exists.")
doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
return true
end

if not getPlayerStorageValue(cid, 9001) == 1 then
doPlayerSendCancel(cid, "You Aren't Invited To Any Party")
doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
return true
end

if param == "" then
doPlayerSendCancel(cid, "Invalid Param or Player Doesn't Exist")
doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
return true
end

if(getCreatureCondition(cid, CONDITION_INFIGHT)) then
doPlayerSendCancel(cid, "You Are InFight")
doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
return true
end

if isInParty(lid) and string.lower(getCreatureName(lid)) == string.lower(param) then
doPlayerJoinParty(cid, lid)
doSendMagicEffect(getPlayerPosition(cid), CONST_ME_MAGIC_BLUE)
doPlayerSendTextMessage(lid, 27,getCreatureName(cid).." Have Joined Your Party.")
doPlayerSetStorageValue(cid, 9001, -1)
end
return true
end

Now Talkactions.xml
Code:
<talkaction log="yes" words="!invite" event="script" value="invite.lua"/>
<talkaction log="yes" words="!join" event="script" value="join.lua"/>
-------------------------------------
Guild Players Invitation
Code:
function onSay(cid, words, param, channel)
local time = 50 -- in seconds
local lid = getPlayerByName(""..param.."")
local pid = getPlayerByName(""..cid.."")
local playerGuild = getPlayerGuildId(cid)
if exhaustion.check(cid, 6008) then
doPlayerSendCancel(cid, "You Must Wait "..exhaustion.get(cid, 6008).." to invite Again")
return true
end

if not getPlayerGuildRank(cid) == 3 then
doPlayerSendCancel(cid, "You Aren't A Leader")
return true
end

    if(playerGuild == 0) then
        doPlayerSendCancel(cid, "Sorry, you're not in a guild.")
          return true
    end
     
        local players = getPlayersOnline()
                local members = 0
        for i, tid in ipairs(players) do
            if(getPlayerGuildId(tid) == playerGuild and cid ~= tid) then
    doPlayerInviteToParty(cid,tid)
    doPlayerSetStorageValue(cid, 9002, 1)
    doPlayerSendTextMessage(tid, 27, "You Have Been Invited to Party By Guild Master.Please Say !join "..getPlayerName(cid).."")
    doPlayerSendTextMessage(cid, 27,members.." has Been Invited")
    exhaustion.set(cid, 6008, time * 1000)
        end
members = members + 1
    end
    return true
    end

Tested In 0.3.7 r5963 8.60

If you have any errors Tell me.Thanks
 
Last edited:
This part isn't working:

Code:
if getCreatureName(cid) == param then
doPlayerSendCancel(cid, "Can't Invite Yourself")
doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
return false
end

Change to:
Code:
if string.lower(getCreatureName(cid)) == string.lower(param) then
   doPlayerSendCancel(cid, "Can't Invite Yourself")
   doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
return true
end

Your idea/code is awesome, thanks you for this!
 
This part isn't working:

Code:
if getCreatureName(cid) == param then
doPlayerSendCancel(cid, "Can't Invite Yourself")
doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
return false
end

Change to:
Code:
if string.lower(getCreatureName(cid)) == string.lower(param) then
   doPlayerSendCancel(cid, "Can't Invite Yourself")
   doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
return true
end

Your idea/code is awesome, thanks you for this!
Thanks For The Reply Cthugha.
Gonna fix the first post
 
Thanks For The Reply Cthugha.
Gonna fix the first post
You could use the string.lower function to the join section too, so you can just type "!join blabla" without all the uppercases/capital letter of the name :p
 
You could use the string.lower function to the join section too, so you can just type "!join blabla" without all the uppercases/capital letter of the name :p
I Fixed it in my server and forgot to fix it here.:)
so when you join you don't have to type !join Captial Name just !join name

Sorry for misunderstanding

Done Here Too
 
Last edited:
with join.lua line 17 change
if param == ""
for
if param == "" then
 
Really good man!
With this function is possible to make a script to a guild leader invite all of your guild's player
So useful! Better than click-by-click party invitation :D

Thanks :)
 
Really good man!
With this function is possible to make a script to a guild leader invite all of your guild's player
So useful! Better than click-by-click party invitation :D

Thanks :)
Np Bro! i was thinking about item auto share when someone killed a monster item is shared randomly among them
 
Np Bro! i was thinking about item auto share when someone killed a monster item is shared randomly among them

Omg, this is really good!!
Will be so good to quests or even player killing in a war, oh you have a lot ideas, perfect!
 
Hey, i found somebugs on scripts to invite a player and the script to invite all guild member's.

Invite guild members:
[22:26:48.743] [Error - TalkAction Interface]
[22:26:48.743] data/talkactions/scripts/ptguild.lua:eek:nSay
[22:26:48.743] Description:
[22:26:48.743] data/lib/034-exhaustion.lua:4: field 'day' missing in date table
[22:26:48.743] stack traceback:
[22:26:48.743] [C]: in function 'time'
[22:26:48.743] data/lib/034-exhaustion.lua:4: in function 'check'
[22:26:48.743] data/talkactions/scripts/ptguild.lua:6: in function <data/talkactions/scripts/ptguild.lua:1>

When you try to invite a offline player, the server crash :D
 
Try This One
Code:
function onSay(cid, words, param, channel)
local time = 50 -- in seconds
local lid = getPlayerByName(""..param.."")
local pid = getPlayerByName(""..cid.."")
local playerGuild = getPlayerGuildId(cid)
if getPlayerStorageValue(cid, 9003) == 1 then
doPlayerSendCancel(cid, "CoolDown System")
return true
end

if not getPlayerGuildRank(cid) == 3 then
doPlayerSendCancel(cid, "You Aren't A Leader")
return true
end

if(playerGuild == 0) then
  doPlayerSendCancel(cid, "Sorry, you're not in a guild.")
  return true
end
     
        local players = getPlayersOnline()
                local members = 0
        for i, tid in ipairs(players) do
            if(getPlayerGuildId(tid) == playerGuild and cid ~= tid) and tid then
    doPlayerInviteToParty(cid,tid)
    doPlayerSetStorageValue(cid, 9002, 1)
    doPlayerSendTextMessage(tid, 27, "You Have Been Invited to Party By Guild Master.Please Say !join "..getPlayerName(cid).."")
    doPlayerSendTextMessage(cid, 27,members.." has Been Invited")
    doPlayerSetStorageValue(cid, 9003, 1)
    addEvent(doPlayerSetStorageValue,cid, 9003, -1)
        end
              members = members + 1
    end
    return true
    end
 
Oh sorry for the wait time, but is i'm using windows right now and i have to test on linux, but really thanks for the help!!!!!

EDIT: Now work's perfectly!!! Really thanks man!

And about the chanceexp, i'm add in source the function "onGainExp" and now working really perfectly, but know i'm using as base your script!

Thanks for the all help man! Thanks!
 
Last edited:
And mine version of that script, without many bugs that you make.
invite:
Code:
function onSay(cid, words, param, channel)
local time = 30 -- in seconds
local lid = getPlayerByName(""..param.."")
local pid = getPlayerByName(""..cid.."")
local playerGuild = getPlayerGuildId(cid)
if exhaustion.check(cid, 6007) then
    doPlayerSendCancel(cid, "You Must Wait "..exhaustion.get(cid, 6007).." seconds to invite Again")
    doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
    return true
end
if(playerGuild == 0) then
    doPlayerSendCancel(cid, "Sorry, you're not in a guild.")
    doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
    return true
end
if(getCreatureCondition(cid, CONDITION_INFIGHT)) then
    doPlayerSendCancel(cid, "You Are InFight")
    doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
    return true
end

exhaustion.set(cid, 6007, time)
local players = getPlayersOnline()
local members = 0
local ifAny = false
    for i, tid in ipairs(players) do
        if(getPlayerGuildId(tid) == playerGuild and cid ~= tid and not isInParty(tid)) then
        doPlayerInviteToParty(cid,tid)
        doPlayerSetStorageValue(cid, 9001, 1)
        doPlayerSendTextMessage(tid, 27, "You Have Been Invited to Guild Party.Please Say /partyjoin "..getPlayerName(cid).."")
        ifAny = true
        members = members + 1
    end
    end
    if not ifAny then
        doPlayerSendCancel(cid, "There is no guild members that you can invite.")
        doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
        return true
    end
    doPlayerSendTextMessage(cid, 27,members.." members has been invited")
    return true
end

join:
Code:
function onSay(cid, words, param, channel)
local lid = getPlayerByName(""..param.."")
local pid = getPlayerByName(""..cid.."")
local players = getPlayersOnline()

if isInParty(cid) then
doPlayerSendCancel(cid, "You are already in party.")
doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
return true
end

if not getPlayerStorageValue(cid, 9001) == 1 then
doPlayerSendCancel(cid, "You Aren't Invited To Any Party")
doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
return true
end

if(not(getPlayerByName(param))) then
doPlayerSendCancel(cid, "There is no such player nor it exists.")
doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
return true
end

if param == "" then
doPlayerSendCancel(cid, "Invalid Param or Player Doesn't Exist")
doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
return true
end

if(getCreatureCondition(cid, CONDITION_INFIGHT)) then
doPlayerSendCancel(cid, "You Are InFight")
doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
return true
end

if isInParty(lid) and string.lower(getCreatureName(lid)) == string.lower(param) and getPlayerGuildId(lid) == getPlayerGuildId(cid) then
doPlayerJoinParty(cid, lid)
doSendMagicEffect(getPlayerPosition(cid), CONST_ME_MAGIC_BLUE)
doPlayerSetStorageValue(cid, 9001)
for i, tid in ipairs(players) do
    if(getPlayerGuildId(tid) == getPlayerGuildId(cid) and cid ~= tid and isInParty(tid)) then
        doPlayerSendTextMessage(tid, 27,getCreatureName(cid).." Have Joined Your Party.")
    end
end
else
doPlayerSendCancel(cid, "Unable to join to party")
doPlayerSetStorageValue(cid, 9001)
doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
end
return true
end

Anyways thx for C++ code
 
Back
Top