Player leave server, and player afk, hide players name.
nwninterested
Member Posts: 6
Can someone give me an on player leave server, and on player afk script? I am making a murder mystery / avoid the killer type game, and if the killer player leaves, or is afk it needs to pick someone else.
It also needs to detect a variable on the player ( but can it do that after he has already left?)
Or is there maybe a better way to go about doing this?
EDIT: Is there a way to hide players name? Or maybe if he takes control of a monster hide their name?
It also needs to detect a variable on the player ( but can it do that after he has already left?)
Or is there maybe a better way to go about doing this?
EDIT: Is there a way to hide players name? Or maybe if he takes control of a monster hide their name?
1
Comments
// afktimer.nss void main() { object oPC = OBJECT_SELF; int timer = GetLocalInt(oPC, "AFK_TIMER") + 1; // check if player moved: location loc = GetLocation(oPC); if (loc != GetLocalLocation(oPC, "LAST_LOCATION")) { SetLocalLocation(oPC, "LAST_LOCATION", loc); timer = 0; // reset the timer } // If player is in combat, they're not AFKing: if (GetIsInCombat(oPC)) timer = 0; // If they did nothing noteworthy for 10 rounds, they are AFK if (timer > 10) { HandlePlayerAFK(); // Player is AFK, do something. } else { SetLocalInt(oPC, "AFK_TIMER", timer); DelayCommand(6.0f /*seconds*/, ExecuteScript("afktimer")); } }
There are more cases to handle. Such as, OnPlayerChat, you should call SetLocalInt(oPC, "AFK_TIMER", 0); to reset it if they are chatting, etc.
Hiding player names requires NWNX.
(Obviously out of date now as we are building a new Newcastle, but you may get a few ideas from it. It refers to other systems too - I left those snippets there to show you how you can patch in your other systems.)
// Trials of Newcastle OnClientLeave Event // Last Updated Dorrian and Milliorn June 2007 // Other contributors over time and versions: Elwoodini, Mask, Scarface and Driller // Patched for Funky's Simtools #include "inc_anticheat" #include "inc_color" //#include "inc_newc_subs" #include "fky_chat_clexit" #include "inc_givemaxhp" //Town Portal System void DestroyPortal(object oPC) { string sUniquePCID = GetLocalString(oPC,"PC_CD_KEY"); object oPortalE = GetObjectByTag("PE"+sUniquePCID); object oPortalX = GetObjectByTag("PX"+sUniquePCID); int i = GetLocalInt(oPortalX,"WP"); SetLocalInt(GetModule(),"WP_Portal"+IntToString(i),0); SetPlotFlag(oPortalE,FALSE); DestroyObject(oPortalE); SetPlotFlag(oPortalX,FALSE); DestroyObject(oPortalX); SetLocalInt(oPC,"ActivePortal",0); } //End Town Portal System void main() { object oPC = GetExitingObject(); string Script = GetLocalString(oPC, "LetoScript"); //Minimise the exit for DMs if (GetIsDM(oPC)) { SendMessageToAllDMs(Color_Text("red", "A DM has exited the game.")); return; } //Bye-bye // SimTools FunkyOCE(oPC); //Subraces SubraceLeave(oPC); //Leto and Scarface stuff if( Script != "" ) { SetLocalString(oPC, "LetoScript", ""); Leto(Script); } MaxHitPointsPCExit(GetExitingObject()); //End Leto and Scarface //PC ID retrieval and exit reporting //These strings are set OnEnter and used in several systems. string sID = GetLocalString(oPC, "sAccount"), sNAME = GetLocalString(oPC, "sPC"), sKEY = GetLocalString(oPC, "sSCD"), sIP= GetLocalString(oPC, "sIP"), sReport = (Color_Text("red", " Character: ")+ sNAME + Color_Text("red", ". Account: ") + sID + Color_Text("red", ". CD Key: ") + sKEY + Color_Text("red", ". IP: ") + sIP); SendMessageToAllDMs(sReport + Color_Text("red", "has exited the game.")); //End PC ID //Book of Portals if (GetLocalObject(oPC, "portal_creator") != OBJECT_INVALID) {AssignCommand(GetLocalObject(oPC, "portal_creator"), SetIsDestroyable(TRUE)); DestroyObject(GetLocalObject(oPC, "portal_creator"), 1.0f);} DestroyPortal(oPC); object oArea = GetLocalObject(oPC,"PW_AREA"); // stored by area's OnEnter // Note: the oPC object is not a true PC object anymore // GetIsPC does not work here (or in the area's OnExit) // The only thing reliable is GetName(oPC) store HPs, spells, feats StorePlayerInfo(oPC); // apply anti-cheat code }