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

[TALKACTION OR SPELL] Player are realy invisible for 5 seconds (like /ghost)

raelpsf

Member
Joined
Jul 3, 2010
Messages
166
Reaction score
5
Hi guys..

I need one script for players, if player hava a X storage (quest complete), he can say "utito mort" and stay realy invisible (= /ghost) for 5 seconds..

In this "ghost" time.. player do not atack..

The "spell" only be used again in 10 minutes.

If is possible, change outfit (5 seconds) for a ghost outfit.

But i do not like to change the group for players..

Tkx for you help.
 
You need to modify sources:
talkaction.cpp
[cpp]bool TalkAction::ghost(Creature* creature, const std::string&, const std::string&)
{
Player* player = creature->getPlayer();
if(!player)
return false;

if(player->hasFlag(PlayerFlag_CannotBeSeen))
{
player->sendTextMessage(MSG_INFO_DESCR, "Command disabled for players with special, invisibility flag.");
return true;
}

SpectatorVec::iterator it;
SpectatorVec list = g_game.getSpectators(player->getPosition());
Player* tmpPlayer = NULL;

Condition* condition = NULL;
if((condition = player->getCondition(CONDITION_GAMEMASTER, CONDITIONID_DEFAULT, GAMEMASTER_INVISIBLE)))
{
player->sendTextMessage(MSG_INFO_DESCR, "You are visible again.");
IOLoginData::getInstance()->updateOnlineStatus(player->getGUID(), true);
for(AutoList<Player>::iterator pit = Player::autoList.begin(); pit != Player::autoList.end(); ++pit)
{
if(!pit->second->canSeeCreature(player))
pit->second->notifyLogIn(player);
}

for(it = list.begin(); it != list.end(); ++it)
{
if((tmpPlayer = (*it)->getPlayer()) && !tmpPlayer->canSeeCreature(player))
tmpPlayer->sendMagicEffect(player->getPosition(), MAGIC_EFFECT_TELEPORT);
}

player->removeCondition(condition);
g_game.internalCreatureChangeVisible(creature, VISIBLE_GHOST_APPEAR);
}
else if((condition = Condition::createCondition(CONDITIONID_DEFAULT, CONDITION_GAMEMASTER, -1, 0, false, GAMEMASTER_INVISIBLE)))
{
player->addCondition(condition);
g_game.internalCreatureChangeVisible(creature, VISIBLE_GHOST_DISAPPEAR);
for(it = list.begin(); it != list.end(); ++it)
{
if((tmpPlayer = (*it)->getPlayer()) && !tmpPlayer->canSeeCreature(player))
tmpPlayer->sendMagicEffect(player->getPosition(), MAGIC_EFFECT_POFF);
}

for(AutoList<Player>::iterator pit = Player::autoList.begin(); pit != Player::autoList.end(); ++pit)
{
if(!pit->second->canSeeCreature(player))
pit->second->notifyLogOut(player);
}

IOLoginData::getInstance()->updateOnlineStatus(player->getGUID(), false);
if(player->isTrading())
g_game.internalCloseTrade(player);

player->clearPartyInvitations();
if(player->getParty())
player->getParty()->leave(player);

player->sendTextMessage(MSG_INFO_DESCR, "You are now invisible.");
}

return true;
}[/cpp]

Make it check if access is greater than 2 then unlimited, else if access 2 or less then check cooldown, if out of cooldown then allow invisibility for 5 seconds.

And change:
XML:
<talkaction log="yes" words="/ghost" access="3" event="function" value="ghost"/>

Remove "access="3" and talkaction log so the result will just be:

XML:
<words="/ghost" event="function" value="ghost"/>

Basic programming knowledge is required.
 
Hum.. i have 2 questions..

1) my server is yourots.. where is the talkaction.cpp...

2) where i configure only for players with a storage XXX (quest).?

Tkx..
 
Ok, I must have overestimated you. :P

You need to find the source code your using. talkaction.cpp is used to compile your .exe file.
You have to figure out which TFS version your yourots is based on, you can download fresh sources here:
Subversion

I just made some cooldown counter in lua: (However these are using global storages, not playerstorages. Easy to fix).
LUA:
secondswait = 3600 -- Exhausted time. [How long waiting time until you can release script again]
unusedstorage1 = 30010 -- Just put a random storage value your not using.
unusedstorage2 = 30011 -- Just put a random storage value your not using.
function yourscript()
 -- your script goes here. 
	doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "ITS A TRAP!!!")
	return true
end
timee = getStorage(unusedstorage2) -- will store current time after first run of script.
	if getStorage(unusedstorage1) == -1 then
		addEvent(yourscript,0)
		doSetStorage(unusedstorage2,(os.time()+secondswait))
		doSetStorage(unusedstorage1,1)
		return true
	end
	if os.time() >= timee then
		addEvent(yourscript,0)
		doSetStorage(unusedstorage2,(os.time()+secondswait))
	else
doPlayerSendCancel(cid, "This talkaction is still on cooldown.")

end

However I suck in c++. :P
 
Last edited:
LUA:
addEvent(function(c) if isPlayer(c) then doCreatureExecuteTalkAction(c, '/ghost', true) end end, 5000, cid)
 
Back
Top