Jump to content
  • 0

Hourly Points as long as player is in the map


PandaLovesHamster

Question


  • Group:  Members
  • Topic Count:  51
  • Topics Per Day:  0.01
  • Content Count:  452
  • Reputation:   33
  • Joined:  12/18/14
  • Last Seen:  

I'd like to request an npc where it would give you points every hour as long as the player remains inside the map.

Warping out will cause the timer to reset back to 0, character select or disconnection results to timer reset as well.

Thank you sirs.

Link to comment
Share on other sites

2 answers to this question

Recommended Posts

  • 0

  • Group:  Members
  • Topic Count:  31
  • Topics Per Day:  0.01
  • Content Count:  283
  • Reputation:   31
  • Joined:  07/08/14
  • Last Seen:  

Do you want it to prevent 'reloadscript' from reseting the timer?

-	script	hour_points	-1,{ function AddPlayer;
OnInit:
	setarray .maps$ , "morocc"; //maps where the system is active
	.points = 1; //number of points get after one hour

	for (.@i = 0 ; .@i < getarraysize(.maps$) ; .@i++)
		if (!getmapflag(.maps$[.@i],mf_loadevent)) setmapflag .maps$[.@i],mf_loadevent;
	initnpctimer;
	end;

OnPCLoadMapEvent:
	for (.@i = 0 ; .@i < getarraysize(.maps$) ; .@i++) {
		if (.maps$[.@i] == strcharinfo(3)) {
			dispbottom "You entered a special zone and will now receive points every hour you spend there.";
			dispbottom "Please note that warping out of the map will reset your timer.";
			AddPlayer(strcharinfo(0),strnpcinfo(0));
		}
	}
	end;

OnTimer1000: //will check very second if player is still on the map
	for (.@i = 0 ; .@i < .player_amount ; .@i += 3) {
		if (!attachrid(getcharid(3,.players$[.@i])) || strcharinfo(3) != .players$[.@i+1]) { deletearray .players$[.@i],3 ; .player_amount -= 3; }
	}
	for (.@i = 0 ; .@i < .player_amount ; .@i += 3) {
		setarray .players$[.@i+2] , ""+(atoi(.players$[.@i+2]) + 1)+"";
		if (atoi(.players$[.@i+2]) >= 10 && attachrid(getcharid(3,.players$[.@i]))) {
			MapPoints += .points;
			dispbottom "You stayed one hour in this map and so earned "+.points+" map point"+(.points>1?"s":"")+".";
			dispbottom "Your total points : "+MapPoints;
			setarray .players$[.@i+2] , "0";
		}
	}
	initnpctimer;

function	AddPlayer	{ //player name , npc name
	for (.@i = 0 ; .@i < getvariableofnpc(.player_amount,getarg(1)) ; .@i += 3)
		if (getvariableofnpc(.players$[.@i],getarg(1)) == getarg(0)) return;
	setarray getvariableofnpc(.players$[getvariableofnpc(.player_amount,getarg(1))],getarg(1)) , getarg(0) , strcharinfo(3) , "0";
	set getvariableofnpc(.player_amount,getarg(1)) , getvariableofnpc(.player_amount,getarg(1)) + 3;
	return;
}

}

this one doesn't support reloadscript and will reset all timers, it also won't start them back if players doesn't warp in the map again.

 

don't forget to edit these:

setarray .maps$ , "morocc"; //maps where the system is active
	.points = 1; //number of points get after one hour
Edited by Kurofly
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  36
  • Topics Per Day:  0.01
  • Content Count:  383
  • Reputation:   121
  • Joined:  03/31/12
  • Last Seen:  

 

Do you want it to prevent 'reloadscript' from reseting the timer?

-	script	hour_points	-1,{ function AddPlayer;
OnInit:
	setarray .maps$ , "morocc"; //maps where the system is active
	.points = 1; //number of points get after one hour

	for (.@i = 0 ; .@i < getarraysize(.maps$) ; .@i++)
		if (!getmapflag(.maps$[.@i],mf_loadevent)) setmapflag .maps$[.@i],mf_loadevent;
	initnpctimer;
	end;

OnPCLoadMapEvent:
	for (.@i = 0 ; .@i < getarraysize(.maps$) ; .@i++) {
		if (.maps$[.@i] == strcharinfo(3)) {
			dispbottom "You entered a special zone and will now receive points every hour you spend there.";
			dispbottom "Please note that warping out of the map will reset your timer.";
			AddPlayer(strcharinfo(0),strnpcinfo(0));
		}
	}
	end;

OnTimer1000: //will check very second if player is still on the map
	for (.@i = 0 ; .@i < .player_amount ; .@i += 3) {
		if (!attachrid(getcharid(3,.players$[.@i])) || strcharinfo(3) != .players$[.@i+1]) { deletearray .players$[.@i],3 ; .player_amount -= 3; }
	}
	for (.@i = 0 ; .@i < .player_amount ; .@i += 3) {
		setarray .players$[.@i+2] , ""+(atoi(.players$[.@i+2]) + 1)+"";
		if (atoi(.players$[.@i+2]) >= 10 && attachrid(getcharid(3,.players$[.@i]))) {
			MapPoints += .points;
			dispbottom "You stayed one hour in this map and so earned "+.points+" map point"+(.points>1?"s":"")+".";
			dispbottom "Your total points : "+MapPoints;
			setarray .players$[.@i+2] , "0";
		}
	}
	initnpctimer;

function	AddPlayer	{ //player name , npc name
	for (.@i = 0 ; .@i < getvariableofnpc(.player_amount,getarg(1)) ; .@i += 3)
		if (getvariableofnpc(.players$[.@i],getarg(1)) == getarg(0)) return;
	setarray getvariableofnpc(.players$[getvariableofnpc(.player_amount,getarg(1))],getarg(1)) , getarg(0) , strcharinfo(3) , "0";
	set getvariableofnpc(.player_amount,getarg(1)) , getvariableofnpc(.player_amount,getarg(1)) + 3;
	return;
}

}

this one doesn't support reloadscript and will reset all timers, it also won't start them back if players doesn't warp in the map again.

 

don't forget to edit these:

setarray .maps$ , "morocc"; //maps where the system is active
	.points = 1; //number of points get after one hour

 

 

How to 'prevent or support from reloadscript for this script?

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...