Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

New Premium Module: Tyrants of the Moonsea! Read More
Attention, new and old users! Please read the new rules of conduct for the forums, and we hope you enjoy your stay!

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: 15
    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

    GTB
  • 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
    Sylvus_Moonbow
  • TarotRedhandTarotRedhand Member Posts: 787
    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.