- eAAC update to Donation Girl.

git-svn-id: https://svn.code.sf.net/p/rathena/svn/trunk@8026 54d463be-8e91-2dee-dedb-b68131a5f0ec
This commit is contained in:
eaac 2006-08-01 13:47:11 +00:00
parent af1ef44664
commit 82fc0a468e

View File

@ -11,26 +11,28 @@
//= 1.2 - Modified for public use. Added checkweight feature. //= 1.2 - Modified for public use. Added checkweight feature.
//= 2.0 - Many changes, especially ones I had always wanted //= 2.0 - Many changes, especially ones I had always wanted
//= to add to this script. Includes reading items from //= to add to this script. Includes reading items from
//= a separate sql table and more database manipulation //= a separate SQL table and more database manipulation
//= options for GMs. //= options for GMs.
//= 2.1 - Made few changes including the add/remove items //= 2.1 - Made few changes including the add/remove items
//= feature. //= feature.
//= 3.0 - All strings inputed by a user and user/char names //= 3.0 - All strings inputed by a user and user/char names
//= in sql queries are now escaped. Each item has a //= in SQL queries are now escaped. Each item has a
//= price rather than a quantity. This script can work //= price rather than a quantity. This script can work
//= with decimals. //= with decimals.
//= 3.1 - Added quotes to some queries, fixed a variable and //= 3.1 - Added quotes to some queries, fixed a variable and
//= removed a comment. //= removed a comment.
//= 3.2 - Fixed a problem where eAthena would crash if a //= 3.2 - Fixed a problem where eAthena would crash if a
//= query returned NULL. //= query returned NULL.
//= 3.3 - Optimized query speeds by combining a few select
//= queries into one. Requires Trunk 7975.
//===== Compatible With ===================================== //===== Compatible With =====================================
//= eAthena - any version that contains the escape_sql //= eAthena - any version that contains the new query_sql
//= function (Stable 6299 OR Trunk 6262) //= command (Trunk 7975).
//===== Description ========================================= //===== Description =========================================
//= A script that lets a player claim an item for donating. //= A script that lets a player claim an item for donating.
//= Allows a GM to input each donation. //= Allows a GM to input each donation.
//===== Comments ============================================ //===== Comments ============================================
//= This script uses sql tables to store variables for the //= This script uses SQL tables to store variables for the
//= amount donated by users and the items claimable. //= amount donated by users and the items claimable.
//===== Installation ======================================== //===== Installation ========================================
//= You must execute donate.sql and donate_item_db.sql before //= You must execute donate.sql and donate_item_db.sql before
@ -40,6 +42,8 @@
//= Thanks to Lance for helping me with the the arrays and //= Thanks to Lance for helping me with the the arrays and
//= for implementing query_sql. //= for implementing query_sql.
//= Thanks to Skotlex for implementing escape_sql. //= Thanks to Skotlex for implementing escape_sql.
//= Thanks to Toms for implementing the new multi-column
//= query_sql command.
//=========================================================== //===========================================================
prontera.gat,145,179,5 script Donation Girl 714,{ prontera.gat,145,179,5 script Donation Girl 714,{
@ -67,8 +71,7 @@ menu "Continue",L_START,"Cancel",-;
close; close;
L_CHECK: L_CHECK:
query_sql "SELECT `amount` FROM `donate` WHERE `account_id` = "+escape_sql(getcharid(3))+"", @amount$; query_sql "SELECT `amount`,`claimed` FROM `donate` WHERE `account_id` = "+getcharid(3)+"", @amount$, @claimed$;
query_sql "SELECT `claimed` FROM `donate` WHERE `account_id` = "+escape_sql(getcharid(3))+"", @claimed$;
query_sql "SELECT MIN(price) FROM `donate_item_db`", @min$; query_sql "SELECT MIN(price) FROM `donate_item_db`", @min$;
query_sql "SELECT '"+@amount$+"' - '"+@claimed$+"'", @value$; query_sql "SELECT '"+@amount$+"' - '"+@claimed$+"'", @value$;
query_sql "SELECT '"+@value$+"' >= '"+@min$+"'", @enough; query_sql "SELECT '"+@value$+"' >= '"+@min$+"'", @enough;
@ -94,7 +97,7 @@ L_YES:
mes "[Donation Girl]"; mes "[Donation Girl]";
mes "Very well. Which item would you like?"; mes "Very well. Which item would you like?";
next; next;
query_sql "SELECT name FROM `donate_item_db` order by name ASC",$@name$; query_sql "SELECT `name` FROM `donate_item_db` ORDER BY `name` ASC",$@name$;
set $@menu$, $@name$[0]; set $@menu$, $@name$[0];
for(set $@i, 1; $@i < 127; set $@i, $@i + 1){ for(set $@i, 1; $@i < 127; set $@i, $@i + 1){
set $@menu$, $@menu$ + ":" + $@name$[$@i]; set $@menu$, $@menu$ + ":" + $@name$[$@i];
@ -102,8 +105,7 @@ set $@menu$, $@name$[0];
set @menu, (select($@menu$))-1; set @menu, (select($@menu$))-1;
query_sql "SELECT ID FROM `donate_item_db` WHERE name = '"+$@name$[@menu]+"'", @id; query_sql "SELECT `id`,`price` FROM `donate_item_db` WHERE `name` = '"+$@name$[@menu]+"'", @id, @price$;
query_sql "SELECT price FROM `donate_item_db` WHERE ID = "+@id+"", @price$;
query_sql "SELECT TRUNCATE("+@value$+" / "+@price$+",0)", @max; query_sql "SELECT TRUNCATE("+@value$+" / "+@price$+",0)", @max;
mes "[Donation Girl]"; mes "[Donation Girl]";
@ -137,7 +139,7 @@ query_sql "SELECT "+@quantity+" * "+@price$+"", @total$;
mes "Are you sure you want to claim "+@quantity+" "+$@name$[@menu]+"s for $"+@total$+"?"; mes "Are you sure you want to claim "+@quantity+" "+$@name$[@menu]+"s for $"+@total$+"?";
next; next;
menu "No",L_CLAIM,"Yes",-; menu "No",L_CLAIM,"Yes",-;
query_sql "UPDATE `donate` SET `claimed` = `claimed` + "+@total$+" WHERE `account_id` = '"+escape_sql(getcharid(3))+"'"; query_sql "UPDATE `donate` SET `claimed` = `claimed` + "+@total$+" WHERE `account_id` = '"+getcharid(3)+"'";
getitem @id,@quantity; getitem @id,@quantity;
mes "[Donation Girl]"; mes "[Donation Girl]";
mes "Thankyou for donating! We hope you enjoy your gift!"; mes "Thankyou for donating! We hope you enjoy your gift!";
@ -234,8 +236,7 @@ close;
L_ALLITEMS: L_ALLITEMS:
mes "[GM Menu]"; mes "[GM Menu]";
query_sql "SELECT `name` FROM `donate_item_db` ORDER BY `name` ASC", @items$; query_sql "SELECT `name`,`price` FROM `donate_item_db` ORDER BY `name` ASC", @items$, @itemamount$;
query_sql "SELECT `price` FROM `donate_item_db` ORDER BY `name` ASC", @itemamount$;
for(set @i, 0; @i < getarraysize(@items$); set @i, @i + 1){ for(set @i, 0; @i < getarraysize(@items$); set @i, @i + 1){
mes ""+@items$[@i]+" - $"+@itemamount$[@i]+""; mes ""+@items$[@i]+" - $"+@itemamount$[@i]+"";
} }
@ -351,8 +352,7 @@ goto L_GM;
L_VIEWALL: L_VIEWALL:
mes "[GM Menu]"; mes "[GM Menu]";
query_sql "SELECT `account_id` FROM `donate` ORDER BY `amount` DESC", @donatoraid; query_sql "SELECT `account_id`,`amount` FROM `donate` ORDER BY `amount` DESC", @donatoraid, @donatedamount$;
query_sql "SELECT `amount` FROM `donate` ORDER BY `amount` DESC", @donatedamount$;
for(set @i, 0; @i < getarraysize(@donatoraid); set @i, @i + 1){ for(set @i, 0; @i < getarraysize(@donatoraid); set @i, @i + 1){
query_sql "SELECT `userid` FROM `login` WHERE `account_id` = '"+@donatoraid[@i]+"'", @donateruserid$; query_sql "SELECT `userid` FROM `login` WHERE `account_id` = '"+@donatoraid[@i]+"'", @donateruserid$;
for(set @j, 0; @j < getarraysize(@donateruserid$); set @j, @j + 1){ for(set @j, 0; @j < getarraysize(@donateruserid$); set @j, @j + 1){