Hi everyone.. So I have found a Donation Npc from EA using SQL... I edited the npc and just get the things i need which is the add donation and claim donation thing using SQL...
It's working as intended but I got a problem with the claiming part and needed a help with this..
So I can add and claim, but the deleting part after claiming is my problem.. It's not deleting in the SQL...
Here's the retrieve function...
// ************************* [Yhn] ********************************
// RetrieveDonatedItems
// *RetrieveDonatedItems();
// ****************************************************************
function script RetrieveDonatedItems {
if ($useSQL) {
query_sql "SELECT `item_id`,`amount` FROM `"+$database_name$+"`.`"+$table_items$+"` WHERE `donation_id`=(SELECT `donation_id` FROM `"+$database_name$+"`.`"+$table_balance$+"` WHERE `account_id`='"+getcharid(3)+"')",@itemid,@amount;
} else {
copyarray @itemid[0],getd("$don_item_ids_"+getcharid(3)+"[0]"),getarraysize(getd("$don_item_ids_"+getcharid(3)));
copyarray @amount[0],getd("$don_amount_"+getcharid(3)+"[0]"),getarraysize(getd("$don_amount_"+getcharid(3)));
}
if (getarraysize(@itemid) < 1) {
mes "["+$donation_name$+"]";
mes "There are no items for you at the moment.";
mes "If you have donated and haven't got your items yet, please contact a GM or try again later.";
next;
} else {
for (set @i,0; @i < getarraysize(@itemid); set @i,@i+1) {
if (checkweight(@itemid[@i],@amount[@i])) {
getitem @itemid[@i],@amount[@i];
callfunc "RemoveDonationItemSub",getcharid(3),@itemid[@i],@amount[@i];
} else {
mes "["+$donation_name$+"]";
mes "You don't have enough free weight to get this donation:";
mes "^FF0000"+@amount[@i]+" "+getitemname(@itemid[@i])+"(s)^000000";
mes "Please come get this one after you have more free weight.";
next;
menu "Continue with the other donations",L_Cont,"Give me as much of these items as I can carry.",-,"Bring me back to the menu",L_Back;
set @j,0;
while (checkweight(@itemid[@i],(@j+1)) && @j < @amount[@i]) {
set @j,@j+1;
}
getitem @itemid[@i],@j;
callfunc "DecreaseDonationItem",getcharid(3),@itemid[@i],@amount[@i],@j;
L_Cont:
}
}
mes "["+$donation_name$+"]";
mes "Have fun with your items, and thanks for the donation!";
next;
}
L_Back:
deletearray @itemid[0],getarraysize(@itemid);
deletearray @amount[0],getarraysize(@amount);
return;
}
Then this is the remove function...
// ************************* [Yhn] ********************************
// RemoveDonationItem Sub
// *RemoveDonationItemSub(account id,item_id,amount);
// ****************************************************************
function script RemoveDonationItemSub {
if ($useSQL) {
if (getarg(2) == 0) {
query_sql "DELETE FROM `"+$database_name$+"`.`"+$table_items$+"` WHERE `donation_id`=(SELECT `donation_id` FROM `"+$database_name$+"`.`"+$table_balance$+"` WHERE `account_id`='"+getarg(0)+"') && `item_id`='"+getarg(1)+"'";
} else {
query_sql "DELETE FROM `"+$database_name$+"`.`"+$table_items$+"` WHERE `donation_id`=(SELECT `donation_id` FROM `"+$database_name$+"`.`"+$table_balance$+"` WHERE `account_id`='"+getarg(0)+"') && `item_id`='"+getarg(1)+"' && `amount`='"+getarg(2)+"'";
}
} else {
for (set .@i,0; .@i < getarraysize(getd("$don_item_ids_"+getarg(0))); set .@i,.@i+1) {
if (getd("$don_item_ids_"+getarg(0)+"["+.@i+"]") == getarg(1)) {
if (getarg(2) == -1) {
deletearray getd("$don_item_ids_"+getarg(0)+"["+.@i+"]"),1;
deletearray getd("$don_amount_"+getarg(0)+"["+.@i+"]"),1;
} else {
if (getd("$don_amount_"+getarg(0)+"["+.@i+"]") == getarg(2)) {
deletearray getd("$don_item_ids_"+getarg(0)+"["+.@i+"]"),1;
deletearray getd("$don_amount_"+getarg(0)+"["+.@i+"]"),1;
break;
}
}
}
}
}
return;
}
After claiming the item, it's not deleted in the SQL.. But if I used this function, it can delete the item in the SQL...
// ************************* [Yhn] ********************************
// RemoveDonationItem
// *RemoveDonationItem();
// ****************************************************************
function script RemoveDonationItem {
mes "["+$donation_name$+"]";
mes "To remove a donated item for someone to collect from this npc, I will need some information.";
mes "If you input the information I ask you, then everything should be allright.";
next;
L_Input:
mes "["+$donation_name$+"]";
mes "Please tell me the ^FF0000account id^000000 of the person to remove the item from.";
input @aid;
mes "Now, please input the ^FF0000Item ID^000000 of the item you want to remove.";
input @itemid;
next;
mes "["+$donation_name$+"]";
mes "Now, I need to know how many of the items are meant to be given. This is so that I can delete the righ entry from the system. If you do not know, or want to remove ^FF0000all^000000 the items with the given item id, please put 0.";
input @amount;
next;
mes "["+$donation_name$+"]";
mes "Please confirm if the following information is ^FF0000correct^000000.";
mes "Account ID: ^FF0000"+@aid+"^000000.";
mes "Item: ^FF0000"+@itemid+"^000000(^FF0000"+getitemname(@itemid)+"^000000).";
if (@amount > 0) mes "Amount: ^FF0000"+@amount+"^000000.";
if (@amount == 0) mes "Amount: ^FF0000ALL^000000.";
next;
menu "Yes, correct.",-,"No, please let me input again",L_Input,"No, and take me back to the GM menu",L_Back;
callfunc "RemoveDonationItemSub",@aid,@itemid,@amount;
mes "["+$donation_name$+"]";
mes "It has been done.";
next;
L_Back:
return;
}
No error in the map server.. It seems like it's not calling the function removeitemsub after the getitem arg..
Question
Elijah23
Hi everyone.. So I have found a Donation Npc from EA using SQL... I edited the npc and just get the things i need which is the add donation and claim donation thing using SQL...
It's working as intended but I got a problem with the claiming part and needed a help with this..
So I can add and claim, but the deleting part after claiming is my problem.. It's not deleting in the SQL...
Here's the retrieve function...
Then this is the remove function...
After claiming the item, it's not deleted in the SQL.. But if I used this function, it can delete the item in the SQL...
No error in the map server..
It seems like it's not calling the function removeitemsub after the getitem arg.. 
Thanks in advance..
Edit: Seems the problem is in this line..
I tried it manually and it works..
And I'm a little bit confused on where the problem is..
Thanks.. 
Edited by wakoko321Link to comment
Share on other sites
0 answers to this question
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.