Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 10/14/23 in Posts

  1. prontera, 155, 180, 4 script Guild Donation Manager 4_F_AGENTKAFRA,{ function listAcceptedItems { for(.@i = 0; .@i < getarraysize(.accepted_items); .@i++) mes getitemname(.accepted_items[.@i]); } function saveDonation { .@guild_id = getcharid(2); .@character_id = getcharid(0); .@zeny = getarg(0); for(.@i = 0; .@i < getarraysize(.accepted_items); .@i++) { .@item_row$ = "item" + (.@i + 1); .@item_rows$ += ", " + .@item_row$; .@item_insert$ += ", " + getelementofarray(getarg(1), .@i)); .@insert_update$ += ", " + .@item_row$ + " = " + .@item_row$ + " + " + getelementofarray(getarg(1), .@i)); } query_sql("INSERT INTO guild_donations (guild_id, character_id, zeny" + .@item_rows$ + ") VALUES (" + .@guild_id + ", " + .@character_id + ", " + .@zeny + .@item_insert$ + ") ON DUPLICATE KEY UPDATE zeny = zeny + " + .@zeny + .@insert_update$); } function showHistory { .@guild_id = getcharid(2); for(.@i = 0; .@i < getarraysize(.accepted_items); .@i++) .@item_rows$ += ", item" + (.@i + 1); query_sql("SELECT character_id, zeny" + .@item_rows$ + " FROM guild_donations WHERE guild_id = " + .@guild_id, .@character_id, .@zeny, .@item1, .@item2); for(.@i = 0; .@i < getarraysize(.@guild_id); .@i++) mes "Character: " + strcharinfo(0, .@character_id[.@i]) + " Zeny: " + .@zeny[.@i] + " " + getitemname(.accepted_items[0]) + ": " + .@item1[.@i] + " " + getitemname(.accepted_items[1]) + ": " + .@item2[.@i]; } if((.@guild_id = getcharid(2)) == 0) { mes "[" + .npc_name$ + "]"; mes "Sadly i can't help you, since you are not in a guild."; close; } mes "[" + .npc_name$ + "]"; mes "Hello Guild " + ((is_guild_leader(.@guild_id)) ? "Master" : "Member") + "!"; mes "How may i help you today?"; next; switch(select("I want to donate.:Show me the donation history.")) { case 1: mes "[" + .npc_name$ + "]"; mes "What do you want to donate?"; next; if(select("Zeny:Items") == 1) { mes "[" + .npc_name$ + "]"; mes "How many zeny do you want to donate?"; next; input(.@donation); if (Zeny < .@donation) { mes "[" + .npc_name$ + "]"; mes "You don't have enough zeny."; close; } Zeny -= .@donation; saveDonation(.@donation, .@items); mes "[" + .npc_name$ + "]"; mes "Alright, i registered your donation!"; close; } else { mes "[" + .npc_name$ + "]"; mes "Remember i can only take the following items: "; listAcceptedItems(); close2; callshop("guild_donation_dummy_shop", 2); npcshopattach("guild_donation_dummy_shop"); end; } break; case 2: mes "[" + .npc_name$ + "]"; showHistory(); close; break; } OnSellItem: for(.@i = 0; .@i < getarraysize(@sold_nameid); .@i++) { if((.@index = inarray(.accepted_items[0], @sold_nameid[.@i])) == -1) { mes "[" + .npc_name$ + "]"; mes "There are items i can't accept."; mes "I only take the following items: "; listAcceptedItems(); close; } .@items[.@index] = @sold_quantity[.@i]; } for(.@i = 0; .@i < getarraysize(@sold_nameid); .@i++) delitem(@sold_nameid[.@i], @sold_quantity[.@i]); saveDonation(0, .@items); end; OnInit: .npc_name$ = strnpcinfo(1); setarray(.accepted_items[0], 45000, 45001); } - shop guild_donation_dummy_shop -1,501:50. CREATE TABLE IF NOT EXISTS `guild_donations` ( `guild_id` int(11) NOT NULL, `character_id` int(11) NOT NULL, `character_name` varchar(32) NOT NULL, `zeny` int(11) NOT NULL, `item1` int(11) NOT NULL, `item2` int(11) NOT NULL, PRIMARY KEY (`guild_id`,`character_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
    1 point
×
×
  • Create New...