zetibia
Member
- Joined
- Jun 23, 2013
- Messages
- 109
- Reaction score
- 11
Hello, I have a simple cast system putting its functions are in tfs 1.0, so I made the necessary alterations and managed to add the new TFS 1.1, however the talkactions are not functioning properly, it gives an error in the tfs window.
luascript.cpp
cast.lua
Error image:
http://prntscr.com/5foh58
luascript.cpp
Code:
int32_t LuaScriptInterface::luaDoPlayerSetCastState(lua_State* L)
{
//doPlayerSetCastState(cid, bool)
bool state = (bool)popBoolean(L);
Player * p = g_game.getPlayerByID(popNumber<int32_t>(L));
if (p)
{
if (state)
{
if (p->cast.mCastChannelId == -1)
{
ChatChannel * tmpchat = (g_chat.createChannel(*p, CHANNEL_CAST));
if (!tmpchat)
return 0;
tmpchat->addUser(*p);
p->cast.mCastChannelId = tmpchat->getId();
}
p->sendCreatePrivateChannel(p->cast.mCastChannelId, "Spectator Chat");
}
else
{
int id = p->cast.mCastChannelId;
p->kickCastViewers();
g_game.playerCloseChannel(p->id, id);
}
p->setCasting(state);
lua_pushboolean(L, true);
}
return 1;
}
int32_t LuaScriptInterface::luaGetPlayerCast(lua_State* L)
{
//getPlayerCast(cid)
if (Player* player = g_game.getPlayerByID(popNumber<int32_t>(L)))
{
lua_newtable(L);
setFieldBool(L, "status", player->getCastingState());
setField(L, "password", player->getCastingPassword());
}
else
{
reportErrorFunc(getErrorDesc(LUA_ERROR_PLAYER_NOT_FOUND));
lua_pushboolean(L, false);
}
return 1;
}
cast.lua
Code:
function onSay(cid, words, param)
local player = Player(cid)
if getPlayerCast(cid).status == true then
player:sendTextMessage(MESSAGE_INFO_DESCR, "You have stopped casting.")
doPlayerSetCastState(cid, false)
player:save()
return true
end
doPlayerSetCastState(player, true)
doPlayerSetCastPassword(player, param)
player:sendTextMessage(MESSAGE_INFO_DESCR, "You have started casting.")
player:save()
return false
end
Error image:
http://prntscr.com/5foh58
Last edited: