Skip to content

Hooking into failure to rest?

Is there a way to run a script on failure to rest? I'd like to explain to the player -why- there is no rest allowed in specific areas when they hit the rest button and find out they can't, either with a speak string or via an npc.

Comments

  • DJ_WoWDJ_WoW Member Posts: 51
    If this is what you were asking for - put this in the OnPlayerRest Event in Module Properties

    void main(){
    object oPC = GetLastPCRested();
    if (!GetIsPC(oPC)) return;
    object oArea = GetArea(oPC);
    switch(GetLastRestEventType())
    {case REST_EVENTTYPE_REST_STARTED:
    // Put your norest condition here ie
    {int iNOREST = GetLocalInt(oArea, "NOREST");
    // or whatever you are using to determine resting condition
    if (iNOREST == TRUE) AssignCommand(oPC, ClearAllActions());
    break;}
    case REST_EVENTTYPE_REST_CANCELLED:
    {SendMessageToPC(oPC, "No rest explanation.");
    // or - FloatingTextStringOnCreature("No rest explanation.", oPC);
    break;}
    }
    }


    Best to ya,

    DJ_WoW
  • GTBGTB Member Posts: 2
    edited November 2018
    You are the wind beneath my wings.

    Edit: Yep, that works perfectly. Thanks!
    Post edited by GTB on
  • TarotRedhandTarotRedhand Member Posts: 1,481
    edited November 2018
    @DJ_WoW Just a couple of things. You can preserve your code formatting in here. Highlight your code, press the down-arrow next to the EOL symbol in the above editing menu (6th from the left starting at 'B') and select code. The other is that the braces that you use inside your case statements are unnecessary.
    void main()
    {
    	object oPC = GetLastPCRested();
    	
    	if (!GetIsPC(oPC)) 
    		return;
    	
    	object oArea = GetArea(oPC);
    	
    	switch(GetLastRestEventType())
    	{
    		case REST_EVENTTYPE_REST_STARTED:
    		
    			// Put your norest condition here ie
    			
    			int iNOREST = GetLocalInt(oArea, "NOREST"); 
    			
    			// or whatever you are using to determine resting condition
    			
    			if (iNOREST == TRUE) 
    				AssignCommand(oPC, ClearAllActions());
    			
    			break;
    			
    		case REST_EVENTTYPE_REST_CANCELLED:
    			SendMessageToPC(oPC, "No rest explanation.");
    			
    			// or - FloatingTextStringOnCreature("No rest explanation.", oPC);
    			
    			break;
    	}
    }
    
    TR
    Post edited by TarotRedhand on
Sign In or Register to comment.