Jump to content
  • 0

Stoptimer when player leaves map


ran0120

Question


  • Group:  Members
  • Topic Count:  15
  • Topics Per Day:  0.04
  • Content Count:  25
  • Reputation:   0
  • Joined:  05/18/23
  • Last Seen:  

I'm doing an item evolution script wherein when a player stays on the map for a specific time while a certain item is equipped, said item will evolve to another item. The script works as advertises but it still runs even if the player leaves the map. I would like for the timer to stop if the player leaves the designated map. How can I modify the script to do just that?

 

-	script	Fire Wings Evolution	-1,{

OnPCLoadMapEvent:

	while ( isequipped(30058) && strcharinfo(3) == "thor_03" ) goto start_fire_time;

start_fire_time:
	
	set fire_wings_evo,1;
	attachnpctimer;
	initnpctimer;
	end;

OnTimer10000:

	if ( fire_wings_evo > 0 ) {
		unequip EQI_HEAD_LOW;
		getitem 30035,1;
		sleep2 100;
		delitem 30058,1;
		equip 30035;
		stopnpctimer;
		detachnpctimer;
		end;
	}
		end;

		
OnPCDieEvent:

	if ( fire_wings_evo > 0 ) {
		set fire_wings_evo,0;
		end;
	}
}

thor_v03	mapflag	loadevent

 

Link to comment
Share on other sites

1 answer to this question

Recommended Posts

  • 0

  • Group:  Members
  • Topic Count:  1
  • Topics Per Day:  0.00
  • Content Count:  235
  • Reputation:   87
  • Joined:  06/30/18
  • Last Seen:  

Hello,

try it like this:

-	script	Fire Wings Evolution	-1,{
    OnPCLoadMapEvent:
        if (strcharinfo(3) != .map$ || !isequipped(.starterItem)) end;

        fire_wings_evo = 1;

        for(.@i = 0; .@i < .duration; .@i++) {
            if(strcharinfo(3) != .map$)
                end;

            sleep2(.duration * 100);
        }

        if (fire_wings_evo == 0) end;
                                     
		unequip EQI_HEAD_LOW;
		getitem .nextItem, 1;
		sleep2 100;
		delitem .starterItem, 1;
		equip .nextItem;
    end;

    OnPCDieEvent:
        if (fire_wings_evo > 0)
            fire_wings_evo = 0;
    end;

    OnInit:
        .starterItem = 30058;
        .nextItem = 30035;
        .map$ = "thor_03";
        .duration = 10;
}

thor_03 mapflag loadevent

 

Edited by Winterfox
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...