These commands allow the manipulation of the script's RID#Usage player. While attachrid allows attaching of a different player
by using it's AID for the parameter rid , detachrid makes
the following commands run, as if the script was never invoked by a player.
In case, that the player cannot be attached, such as, when the player went
offline in the mean time, attachrid returns 0, otherwise 1.
[Mes] "Enter a name of a player.";
[Next];
[Input] .@playername$;
[Set] .@playerid,[Getcharid](3,.@playername$); // retrieve rid of another player
set .@invokeid,getcharid(3); // retrieve rid of the current player
detachrid; // detaches the current player,
// although not necessary before attachrid
[If](.@playerid && attachrid(.@playerid)) // playerid is 0, if player is offline
{
[Dispbottom] "Hello! *^__^*";
}
else
{
set .@playerid,0; // indicate attachrid failure
}
if(attachrid(.@invokeid)) // attach back to the first player
{
if(.@playerid)
{
mes "I have said hello to "+.@playername$+".";
}
else
{
mes "I was not able to reach "+.@playername$+".";
}
[Close];
}
[End];
This will allow one player to specify the name of an another, which is then
greeted by the script. Afterwards the invoking player is informed, whether or
not the player was told "hello". The return value of attachrid should be
always checked for success, otherwise the script terminates on the next
command, which requires an attached player, on failure.