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
----------------
Lets Get Started With ScreenShot First
Then
-------------------
Ok Now C++ Codes
Open luascript.cpp
Find
Add This After It
find
Add After It
Open Luascript.h
Find
Add This After It
Now Compile C++ Part Done
------------
Open YourData/talkaction/scripts/create a new file called invite.lua
Add This
Create talkactions/scripts/join.lua
Add This
Now Talkactions.xml
-------------------------------------
Guild Players Invitation
Tested In 0.3.7 r5963 8.60
If you have any errors Tell me.Thanks
----------------
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
----------------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
----------------Don't Edit Anything Just Copy And Paste Unless you know what you are doing
How To Use InGame:
!invite PlayerName
!join PlayerName
----------------!invite PlayerName
!join PlayerName
Lets Get Started With ScreenShot First
Then
-------------------
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;
}
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: