Jump to content
  • 0

Daily Donation Script


Question

Posted

Hi Team,

Good day. May I request for a script in which a GM will talk to the NPC, then input the Item Code as donation everyday, then all the list from the previous days will be on record, so players can still buy the donation, the list will cover up to 30 days maximum. Thank you.

Same with Daily Reward, but in reverse, we add the Item code today, and it will still be available tomorrow for donation.

6 answers to this question

Recommended Posts

  • 0
Posted

i don't understand exactly what you need.

so the GM enters an item code, then what? so is the GM donating this item to every player everyday? please elaborate, thanks.

  • 0
Posted
51 minutes ago, Mastagoon said:

i don't understand exactly what you need.

so the GM enters an item code, then what? so is the GM donating this item to every player everyday? please elaborate, thanks.

It basically records daily input by the GM into an NPC, and will keep that in the list for 30 days, after 30 days it will be removed. Basically and item-recording selling npc.

  • 0
Posted (edited)
5 minutes ago, mawjustin said:

It basically records daily input by the GM into an NPC, and will keep that in the list for 30 days, after 30 days it will be removed. Basically and item-recording selling npc.

and what happens if the GM skips a day ?

also are you able to record more than 1 item per day?

Edited by Mastagoon
  • 0
Posted
Just now, Mastagoon said:

and what happens if the GM skips a day ?

also are you able to record more than 1 item per day?

It should, or it doesn't matter really, as long as the item will be recorded into the NPC, and will last for 30 days., and after 30 days it will be removed.

  • 0
Posted (edited)
prontera,100,100,4	script	item_recording_npc	789,{
	if(getgmlevel() < 99) end;
	mes "Enter the ID of today's item.";
	input .@itemId;
	next;
	mes "You're adding the item "+getitemname(.@itemId)+" to your list. continue?";
	if(select("Yes:No") -1 ) close;
	.@duration = gettimetick(2) + 30 * 24 * 60 * 60;
	query_sql("INSERT INTO `recorded_items`(item_id, time) VALUES ("+.@itemId+", "+.@duration+")");
	mes "item added succesfully!";
	close;

OnClock0000:
	query_sql("SELECT id , record_time FROM `recorded_items`", .@ids, .@time);
	for(.@i = 0; .@i < getarraysize(.@ids); .@i++) {
		if(gettimetick(2) > .@time[.@i]) {
			setarray .@deleteitems[getarraysize(.@deleteitems)], .@ids[.@i];
		}
	}
	for(.@i = 0; .@i < getarraysize(.@deleteitems); .@i++) {
		query_sql("DELETE FROM `recorded_items` WHERE id = "+.@deleteitems[.@i]);
	}
	end;
OnInit:
	.@sql$ = "CREATE TABLE IF NOT EXISTS `recorded_items`(id int(11) PRIMARY KEY AUTO_INCREMENT, item_id int(11), record_time int(11)";
	query_sql(.@sql$);
	end;
}

this npc allows a GM to add an item id to a table in the database, and checks every night at 12:00AM for any expired items (items that have been recorder more than 30 days ago) and deletes them from the database.

there might be an easier way to do this, but maybe this  will work for you.

please note that this code is untested.

Edited by Mastagoon
  • 0
Posted
1 hour ago, Mastagoon said:

prontera,100,100,4	script	item_recording_npc	789,{
	if(getgmlevel() < 99) end;
	mes "Enter the ID of today's item.";
	input .@itemId;
	next;
	mes "You're adding the item "+getitemname(.@itemId)+" to your list. continue?";
	if(select("Yes:No") -1 ) close;
	.@duration = gettimetick(2) + 30 * 24 * 60 * 60;
	query_sql("INSERT INTO `recorded_items`(item_id, time) VALUES ("+.@itemId+", "+.@duration+")");
	mes "item added succesfully!";
	close;

OnClock0000:
	query_sql("SELECT id , record_time FROM `recorded_items`", .@ids, .@time);
	for(.@i = 0; .@i < getarraysize(.@ids); .@i++) {
		if(gettimetick(2) > .@time[.@i]) {
			setarray .@deleteitems[getarraysize(.@deleteitems)], .@ids[.@i];
		}
	}
	for(.@i = 0; .@i < getarraysize(.@deleteitems); .@i++) {
		query_sql("DELETE FROM `recorded_items` WHERE id = "+.@deleteitems[.@i]);
	}
	end;
OnInit:
	.@sql$ = "CREATE TABLE IF NOT EXISTS `recorded_items`(id int(11) PRIMARY KEY AUTO_INCREMENT, item_id int(11), record_time int(11)";
	query_sql(.@sql$);
	end;
}

this npc allows a GM to add an item id to a table in the database, and checks every night at 12:00AM for any expired items (items that have been recorder more than 30 days ago) and deletes them from the database.

there might be an easier way to do this, but maybe this  will work for you.

please note that this code is untested.

thank you.. i just need to have this into a vending npc,

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.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...