Jump to content
  • 0
fireicesurfer

HOURLY ITEM REWARD SCRIPT for HERCULES

Question

2 answers to this question

Recommended Posts

  • 0

Try

-	script	asdfgh	FAKE_NPC,{
	OnPCLoginEvent:
		.players[getarraysize(.players)] = getcharid(CHAR_ID_ACCOUNT);
		end;
	OnPCLogoutEvent:
		.@i = callfunc("array_find", .players, getcharid(CHAR_ID_ACCOUNT));
		if (!(.@i < 0))
			deletearray .players[.@i], 1;
		end;
	OnMinute15:
		if (!.random_receiver) {
			.@i = 0;
			.@s = getarraysize(.players);
			while (.@i < .@s) {
				getitem Jellopy, 1, .players[.@i];
				.@i++;
			}
		} else getitem Jellopy, 1, .players[rand(getarraysize(.players))];
		end;
	OnInit:
		.random_receiver = 0; // 0 - all online players | 1 = random online player
		end;
}

PS : I am using below release so please plug that as well to your server to avoid any issues

 

Share this post


Link to post
Share on other sites
  • 0

If what you want is create a NPC that you can only interact with every 15 minutes you could do something similar to this:

// create a NPC template:
-	script	giver	FAKE_NPC,{
	// get the item name from the NPC name
	.@item$ = strnpcinfo(NPC_NAME_HIDDEN);

	// check when the player last obtained this item
	.@last = .obtained[playerattached()];

	if (.@last <= time_from_minutes(-15)) {
		// give the item
		getitem(.@item$, 1);

		// update the last obtained date
		.obtained[playerattached()] = now();

		mes("Enjoy!");
	} else {
		// calculate the difference
		.@seconds = .@last - time_from_minutes(-15);

		// tell the player to wait
		mesf("Don't be greedy! Try again %s.", FuzzyTime(time_from_seconds(.@seconds)));
		// This would print, ie: "Don't be greedy! Try again in 5 minutes and 32 seconds."
	}

	close;
}

// now make duplicates:
einbech,172,113,4	duplicate(giver)	new name#Jellopy	4_M_EINMAN
// ^ this would spawn a NPC named "new name" that gives a Jellopy every 15 minutes

This creates a template NPC that gets its parameters from the NPC name so you can create several duplicates that all give different items.

 

PS: to make it easier to read this script uses the Date and Time functions file

Share this post


Link to post
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.   Restore formatting

  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.

Loading...

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.