Hello,
our server is in beta near release but our developer left so i jump in / in hope to get the last things done.
We still missing view things. Today i wanted to do a Reward NPC its completely new for me i never scripted /coded / programm or anything like that! I got access to the Gitlab from the admin of the server and try to figure out how it works.. sadly i dont know.
But ive seen here are very experienced people and i saw the script from Viole which looks "complete????" but i would like to costumize it a little bit for our needs
Here is his Code (thanks to Viole)
/* ______________________________________________________________
| |
| rAthena Script |
| |
| Rewards NPC |
| By: |
| Viole |
| |
| Current Version |
| 1.6 |
| |
| Description: |
| NPC which you can assign a reward |
| to a 'specific' player and set |
| the quantity of the reward to be |
| given. |
| |
| Changelog: |
| Rewards NPC 1.0 Items recognized are only from item_db |
| Rewards NPC 1.1 Items recognized from item_db to item_db2 |
| Rewards NPC 1.1 Prevent null from typing 0 in item & amount |
| Rewards NPC 1.1 Main: Can put many players now to give item |
| Rewards NPC 1.2 Fixed Cancel the process option |
| Rewards NPC 1.2 Added Delete a process or all process option|
| Rewards NPC 1.3 Added Show Current Processes option |
| Rewards NPC 1.4 Added Party Option in Assign Rewards |
| Rewards NPC 1.4 Show Current Process (Player or Party) |
| Rewards NPC 1.4 Added Delete Option for Party |
| Rewards NPC 1.5 Added Guild Option in Assign Rewards |
| Rewards NPC 1.5 Show Current Process (Player/Party/Guild) |
| Rewards NPC 1.5 Added Delete Option for Guild |
| Rewards NPC 1.5 Announce. GM adds a process for Party/Guild |
| Rewards NPC 1.6 Added View Logs (Credits: Euphy) |
| (Requested: bVersatile) |
| |
| Note: |
| Players can view the logs too, or it's your choice to |
| remove it, or not. Feel free to edit things inside. |
| |
| If you added 2 items to a 'same' player/guild/party |
| Only the first one is recognized. |
| |
| If you delete 1 player/party/guild process, all its |
| player/party/guild's process will be deleted. |
| |
| If some processes were deleted, and if you add a new process,|
| all those previous slots will be filled up. |
| |
| About the query sql's, I sucked at query sql, and got a prob |
| when adding only 1 sql, becuz of nulls..(I'll learn more) |
|______________________________________________________________|*/
- script Rewards#101 -1,{
set
[email protected]$, "^FF0000[Rewards NPC]^000000";
set .gmlvl, 80;
if (getgmlevel() >= .gmlvl)
{
admin_only:
mes
[email protected]$;
mes "Hello, GM "+strcharinfo(0)+"!";
mes "What do you want to do?";
next;
switch(select("Assign Reward:Show Current Processes:Delete Process:View Logs"))
{
case 1:
next;
mes
[email protected]$;
mes"Choose what category you want to give the reward.";
next;
switch(select("To a Player:To a Party:To a Guild"))
{
case 1:
next;
mes
[email protected]$;
mes "To whom do you wanna give the reward?";
input @playername$;
query_sql "SELECT `char_id` FROM `char` WHERE `name` = '"+escape_sql(@playername$)+"'",
[email protected];
if (
[email protected]) {next; mes
[email protected]$; mes "The name is invalid."; next; goto admin_only; }
else set
[email protected],0;
next;
mes
[email protected]$;
mes "What will be the reward item?";
mes "Please, input the Item ID #";
input @inputrewarditem;
if (getitemname(@inputrewarditem) == "null" || getitemname(@inputrewarditem) == "") {next; mes
[email protected]$; mes "The item doesn't exists in the database."; next; goto admin_only; }
set @rewarditem, @inputrewarditem;
next;
mes
[email protected]$;
mes "How many "+getitemname(@rewarditem)+" will be given to "
[email protected]$+"?";
input @rewardamount;
if(@rewardamount <= 0) {next; mes
[email protected]$; mes "Please input a number greater than 0"; next; goto admin_only; }
next;
mes
[email protected]$;
mes "So, player "
[email protected]$+" will have";
mes ""
[email protected]+" "+getitemname(@rewarditem)+"s. Great~!";
next;
message @playername$,"Please claim your rewards from the Rewards NPC! "
[email protected]+" "+getitemname(@rewarditem)+"s";
query_sql "INSERT INTO `rewardplayernpc` (`playername`, `reward_id`, `reward_amount`) VALUES ('"
[email protected]$+"', "
[email protected]+", "
[email protected]+")";
setarray $giverlog1$[getarraysize($giverlog1$)],strcharinfo(0);
setarray $receiverlog1$[getarraysize($receiverlog1$)],@playername$;
setarray $itemlog1[getarraysize($itemlog1)],@rewarditem;
setarray $amountlog1[getarraysize($amountlog1)],@rewardamount;
set @playername$, "";
close2;
end;
case 2:
next;
mes
[email protected]$;
mes "Please input the party name..";
input @partyname$;
query_sql "SELECT `party_id` FROM `party` WHERE `name` = '"+escape_sql(@partyname$)+"'",
[email protected];
if (
[email protected]) {next; mes
[email protected]$; mes "The party name is invalid."; next; goto admin_only; }
else set
[email protected],0;
next;
mes
[email protected]$;
mes "What will be the reward item?";
mes "Please, input the Item ID #";
input @inputpartyrewarditem;
if (getitemname(@inputpartyrewarditem) == "null" || getitemname(@inputpartyrewarditem) == "") {next; mes
[email protected]$; mes "The item doesn't exists in the database."; next; goto admin_only; }
set @partyrewarditem, @inputpartyrewarditem;
next;
mes
[email protected]$;
mes "How many "+getitemname(@partyrewarditem)+" will be given to party "
[email protected]$+"?";
input @partyrewardamount;
if(@partyrewardamount <= 0) {next; mes
[email protected]$; mes "Please input a number greater than 0"; next; goto admin_only; }
next;
mes
[email protected]$;
mes "So, party "
[email protected]$+" will have";
mes ""
[email protected]+" "+getitemname(@partyrewarditem)+"s. Great~!";
next;
announce "Party leader of the party ["
[email protected]$+"], please claim your "
[email protected]+" "+getitemname(@partyrewarditem)+"s from the Rewards NPC! ",0,0xDBA901;
query_sql "INSERT INTO `rewardpartynpc` (`partyname`, `reward_id`, `reward_amount`) VALUES ('"
[email protected]$+"', "
[email protected]+", "
[email protected]+")";
setarray $giverlog2$[getarraysize($giverlog2$)],strcharinfo(0);
setarray $receiverlog2$[getarraysize($receiverlog2$)],@partyname$;
setarray $itemlog2[getarraysize($itemlog2)],@partyrewarditem;
setarray $amountlog2[getarraysize($amountlog2)],@partyrewardamount;
set @partyname$, "";
close2;
end;
case 3:
next;
mes
[email protected]$;
mes "Please input the guild name..";
input @guildname$;
query_sql "SELECT `guild_id` FROM `guild` WHERE `name` = '"+escape_sql(@guildname$)+"'",
[email protected];
if (
[email protected]) {next; mes
[email protected]$; mes "The guild name is invalid."; next; goto admin_only; }
else set
[email protected],0;
next;
mes
[email protected]$;
mes "What will be the reward item?";
mes "Please, input the Item ID #";
input @inputguildrewarditem;
if (getitemname(@inputguildrewarditem) == "null" || getitemname(@inputguildrewarditem) == "") {next; mes
[email protected]$; mes "The item doesn't exists in the database."; next; goto admin_only; }
set @guildrewarditem, @inputguildrewarditem;
next;
mes
[email protected]$;
mes "How many "+getitemname(@guildrewarditem)+" will be given to the guild "
[email protected]$+"?";
input @guildrewardamount;
if(@guildrewardamount <= 0) {next; mes
[email protected]$; mes "Please input a number greater than 0"; next; goto admin_only; }
next;
mes
[email protected]$;
mes "So, guild "
[email protected]$+" will have";
mes ""
[email protected]+" "+getitemname(@guildrewarditem)+"s. Great~!";
next;
announce "GuildMaster of the Guild ["
[email protected]$+"], please claim your "
[email protected]+" "+getitemname(@guildrewarditem)+"s from the Rewards NPC!",0,0xDBA901;
query_sql "INSERT INTO `rewardguildnpc` (`guildname`, `reward_id`, `reward_amount`) VALUES ('"
[email protected]$+"', "
[email protected]ewarditem+", "
[email protected]+")";
setarray $giverlog3$[getarraysize($giverlog3$)],strcharinfo(0);
setarray $receiverlog3$[getarraysize($receiverlog3$)],@guildname$;
setarray $itemlog3[getarraysize($itemlog3)],@guildrewarditem;
setarray $amountlog3[getarraysize($amountlog3)],@guildrewardamount;
setarray $numberlog3[getarraysize($numberlog3)],1;
set @guildname$, "";
close2;
end;
}
case 2:
show_process:
next;
mes
[email protected]$;
mes "Choose from what category you would like to view current processes.";
next;
switch(select("Player:Party:Guild"))
{
case 1:
next;
mes "^FF0000[Current Processes]^000000";
mes "••••••••••••••••••••••••••••••••";
query_sql "SELECT `playername`, `reward_id`, `reward_amount` FROM `rewardplayernpc`",
[email protected]_name$,
[email protected]_item,
[email protected]_amount;
for(set @i, 0; @i < getarraysize(
[email protected]_name$); set @i, @i+1)
{
mes "To: ^FF0000Player^000000 ^0000FF"
[email protected]_name$[@i]+"^000000";
mes "Reward: "
[email protected]_amount[@i]+" "+getitemname(
[email protected]_item[@i])+"s";
mes "••••••••••••••••••••••••••••••••";
}
goto show_process;
case 2:
next;
mes "^FF0000[Current Processes]^000000";
mes "••••••••••••••••••••••••••••••••";
query_sql "SELECT `partyname`, `reward_id`, `reward_amount` FROM `rewardpartynpc`",
[email protected]_name$,
[email protected]_item,
[email protected]_amount;
for(set @i, 0; @i < getarraysize(
[email protected]_name$); set @i, @i+1)
{
mes "To: ^088A4BParty^000000 ^0000FF"
[email protected]_name$[@i]+"^000000";
mes "Reward: "
[email protected]_amount[@i]+" "+getitemname(
[email protected]_item[@i])+"s";
mes "••••••••••••••••••••••••••••••••";
}
goto show_process;
case 3:
next;
mes "^FF0000[Current Processes]^000000";
mes "••••••••••••••••••••••••••••••••";
query_sql "SELECT `guildname`, `reward_id`, `reward_amount` FROM `rewardguildnpc`",
[email protected]_name$,
[email protected]_item,
[email protected]_amount;
for(set @i, 0; @i < getarraysize(
[email protected]_name$); set @i, @i+1)
{
mes "To: ^B18904Guild^000000 ^0000FF"
[email protected]_name$[@i]+"^000000";
mes "Reward: "
[email protected]_amount[@i]+" "+getitemname(
[email protected]_item[@i])+"s";
mes "••••••••••••••••••••••••••••••••";
}
goto show_process;
}
case 3:
next;
mes
[email protected]$;
mes "Do you want to delete one process only or all processes?";
switch(select("Delete one process only:Delete all processes:Leave it as it is"))
{
case 1:
next;
mes
[email protected]$;
mes "Please choose from what category you would like to delete a process.";
next;
switch(select("Player:Party:Guild"))
{
case 1:
next;
mes
[email protected]$;
mes "Please input the player name you want to delete the process.";
input @deletename$;
next;
query_sql "SELECT `playername`, `reward_id`, `reward_amount` FROM `rewardplayernpc`",
[email protected]_name$,
[email protected]_item,
[email protected]_amount;
for (set @i, 0; @i < getarraysize(
[email protected]_name$); set @i, @i+1)
{
if(@deletename$ ==
[email protected]_name$[@i])
{
mes
[email protected]$;
mes "Deleting....";
query_sql "DELETE FROM `rewardplayernpc` WHERE `playername`='"
[email protected]$+"'";
next;
mes
[email protected]$;
mes "Deleted unclaimed process!";
close;
}
}
goto R_Invalid;
case 2:
next;
mes
[email protected]$;
mes "Please input the party name you want to delete the process.";
input @partydeletename$;
next;
query_sql "SELECT `partyname`, `reward_id`, `reward_amount` FROM `rewardpartynpc`",
[email protected]_name$,
[email protected]_item,
[email protected]_amount;
for (set @i, 0; @i < getarraysize(
[email protected]_name$); set @i, @i+1)
{
if(@partydeletename$ ==
[email protected]_name$[@i])
{
mes
[email protected]$;
mes "Deleting....";
query_sql "DELETE FROM `rewardpartynpc` WHERE `partyname`='"
[email protected]$+"'";
next;
mes
[email protected]$;
mes "Deleted unclaimed process!";
close;
}
}
goto R_Invalid;
case 3:
next;
mes
[email protected]$;
mes "Please input the guild name you want to delete the process.";
input @guilddeletename$;
next;
query_sql "SELECT `guildname`, `reward_id`, `reward_amount` FROM `rewardguildnpc`",
[email protected]_name$,
[email protected]_item,
[email protected]_amount;
for (set @i, 0; @i < getarraysize(
[email protected]_name$); set @i, @i+1)
{
if(@guilddeletename$ ==
[email protected]_name$[@i])
{
mes
[email protected]$;
mes "Deleting....";
query_sql "DELETE FROM `rewardguildnpc` WHERE `guildname`='"
[email protected]$+"'";
next;
mes
[email protected]$;
mes "Deleted unclaimed process!";
close;
}
}
goto R_Invalid;
}
case 2:
next;
mes
[email protected]$;
mes "Please input DELETE to delete all the unclaimed processes.";
input @deleteall$;
if(@deleteall$ == "DELETE")
{
next;
mes
[email protected]$;
mes "Deleting....";
query_sql "DELETE FROM `rewardplayernpc`";
query_sql "DELETE FROM `rewardpartynpc`";
query_sql "DELETE FROM `rewardguildnpc`";
next;
mes
[email protected]$;
mes "Deleted all unclaimed processes!";
close;
}
next;
mes
[email protected]$;
mes "Next time, please input DELETE correctly!";
close;
case 3:
next;
mes
[email protected]$;
mes "Nothing Changed!";
close2;
end;
}
case 4:
viewlogs:
next;
mes
[email protected]$;
mes "Choose what category you want to view the logs!";
next;
switch(select("Player Logs:Party Logs:Guild Logs",
( getgmlevel() < .gmlvl )?"":"Delete Logs"))
{
case 1:
next;
mes
[email protected]$;
mes "Current logs: ^008000" + (getarraysize($giverlog1$)) + "^000000";
mes "--------------------------------";
set
[email protected],0;
while (
[email protected] < getarraysize($giverlog1$)) {
mes ""
[email protected]+". ^B041FFGM " + $giverlog1$[
[email protected]] + "^000000 gave "+$amountlog1[
[email protected]]+"x "+getitemname($itemlog1[
[email protected]])+" to Player^55AAFF " + $receiverlog1$[
[email protected]] + "^000000";
mes "--------------------------------";
set
[email protected],
[email protected]+1; }
next;
goto viewlogs;
case 2:
next;
mes
[email protected]$;
mes "Current logs: ^008000" + (getarraysize($giverlog2$)) + "^000000";
mes "--------------------------------";
set
[email protected],0;
while (
[email protected] < getarraysize($giverlog2$)) {
mes ""
[email protected]+". ^B041FFGM " + $giverlog2$[
[email protected]] + "^000000 gave "+$amountlog2[
[email protected]]+"x "+getitemname($itemlog2[
[email protected]])+" to Party^55AAFF " + $receiverlog2$[
[email protected]] + "^000000";
mes "--------------------------------";
set
[email protected],
[email protected]+1; }
next;
goto viewlogs;
case 3:
next;
mes
[email protected]$;
mes "Current logs: ^008000" + (getarraysize($giverlog3$)) + "^000000";
mes "--------------------------------";
set
[email protected],0;
while (
[email protected] < getarraysize($giverlog3$)) {
mes ""
[email protected]+". ^B041FFGM " + $giverlog3$[
[email protected]] + "^000000 gave "+$amountlog3[
[email protected]]+"x "+getitemname($itemlog3[
[email protected]])+" to Guild^55AAFF " + $receiverlog3$[
[email protected]] + "^000000";
mes "--------------------------------";
set
[email protected],
[email protected]+1; }
next;
goto viewlogs;
case 4:
next;
mes
[email protected]$;
mes "^FF0000This action cannot be undone.^000000";
mes "Are you sure?";
mes " ";
if (select("Yes:No") == 2) { mes "Request cancelled."; next; goto Log_Menu; }
deletearray $giverlog1$[0],getarraysize($giverlog1$); deletearray $receiverlog1$[0],getarraysize($receiverlog1$);
deletearray $itemlog1[0],getarraysize($itemlog1); deletearray $amountlog1[0],getarraysize($amountlog1);
deletearray $giverlog2$[0],getarraysize($giverlog2$); deletearray $receiverlog2$[0],getarraysize($receiverlog2$);
deletearray $itemlog2[0],getarraysize($itemlog2); deletearray $amountlog2[0],getarraysize($amountlog2);
deletearray $giverlog3$[0],getarraysize($giverlog3$); deletearray $receiverlog3$[0],getarraysize($receiverlog3$);
deletearray $itemlog3[0],getarraysize($itemlog3); deletearray $amountlog3[0],getarraysize($amountlog3);
next;
mes
[email protected]$;
mes "Logs cleared.";
next;
goto admin_only;
}
}
}
mes
[email protected]$;
mes "Hello, "+strcharinfo(0)+"!";
next;
switch(Select("Claim Reward:View Logs:Leave"))
{
case 1:
mes
[email protected]$;
mes "From what category you want to claim your reward?";
next;
switch(select("Player:Party:Guild"))
{
case 1:
mes
[email protected]$;
mes "Please enter your Name:";
input @winnername$;
if (@winnername$!=strcharinfo(0)){next; mes
[email protected]$; mes "You are a fake!"; close; end; }
next;
query_sql "SELECT `playername`, `reward_id`, `reward_amount` FROM `rewardplayernpc`",
[email protected]_name$,
[email protected]_item,
[email protected]_amount;
for (set @i, 0; @i < getarraysize(
[email protected]_name$); set @i, @i+1)
{
if(@winnername$ ==
[email protected]_name$[@i])
{
mes
[email protected]$;
mes "You get ^0000FF" + getitemname(
[email protected]_item[@i]) + " - " +
[email protected]_amount[@i] + " ea.^000000";
query_sql "DELETE FROM `rewardplayernpc` WHERE `playername`='"
[email protected]$+"'";
getitem
[email protected]_item[@i],
[email protected]_amount[@i];
announce "Player "
[email protected]_name$[@i]+" has claimed "
[email protected]_amount[@i]+" "+getitemname(
[email protected]_item[@i])+"s from the Rewards NPC!",0,0xDBA901;
close;
}
}
goto R_Noreward;
case 2:
if( !getcharid(1) || getcharid(3) != getpartyleader( getcharid(1),1 ) ){next; mes
[email protected]$; mes "Only party leaders are allowed here!"; close; end; }
mes
[email protected]$;
mes "Please enter your party name:";
input @partywinnername$;
if (@partywinnername$!=strcharinfo(1)){next; mes
[email protected]$; mes "You are a fake!"; close; end; }
next;
query_sql "SELECT `partyname`, `reward_id`, `reward_amount` FROM `rewardpartynpc`",
[email protected]_name$,
[email protected]_item,
[email protected]_amount;
for (set @i, 0; @i < getarraysize(
[email protected]_name$); set @i, @i+1)
{
if(@partywinnername$ ==
[email protected]_name$[@i])
{
mes
[email protected]$;
mes "You get ^0000FF" + getitemname(
[email protected]_item[@i]) + " - " +
[email protected]_amount[@i] + " ea.^000000";
query_sql "DELETE FROM `rewardpartynpc` WHERE `partyname`='"
[email protected]$+"'";
announce "Party "
[email protected]_name$[@i]+" has claimed "
[email protected]_amount[@i]+" "+getitemname(
[email protected]_item[@i])+"s from the Rewards NPC!",0,0xDBA901;
getitem
[email protected]_item[@i],
[email protected]_amount[@i];
close;
}
}
goto R_Noreward;
case 3:
set @guildid, getcharid(2);
if( !getcharid(2) || strcharinfo(0) != getguildmaster(@guildid) ){next; mes
[email protected]$; mes "Only guild masters are allowed here!"; close; end; }
mes
[email protected]$;
mes "Please enter your guild name:";
input @guildwinnername$;
if (@guildwinnername$!=strcharinfo(2)){next; mes
[email protected]$; mes "You are a fake!"; close; end; }
next;
query_sql "SELECT `guildname`, `reward_id`, `reward_amount` FROM `rewardguildnpc`",
[email protected]_name$,
[email protected]_item,
[email protected]_amount;
for (set @i, 0; @i < getarraysize(
[email protected]_name$); set @i, @i+1)
{
if(@guildwinnername$ ==
[email protected]_name$[@i])
{
mes
[email protected]$;
mes "You get ^0000FF" + getitemname(
[email protected]_item[@i]) + " - " +
[email protected]_amount[@i] + " ea.^000000";
query_sql "DELETE FROM `rewardguildnpc` WHERE `guildname`='"
[email protected]$+"'";
announce "Guild "
[email protected]_name$[@i]+" has claimed "
[email protected]_amount[@i]+" "+getitemname(
[email protected]_item[@i])+"s from the Rewards NPC!",0,0xDBA901;
getitem
[email protected]_item[@i],
[email protected]_amount[@i];
close;
}
}
goto R_Noreward;
}
case 2:
next;
goto viewlogs;
case 3:
mes
[email protected]$;
mes "See yah.";
close;
}
R_Invalid:
mes "^FF0000[Rewards NPC]^000000";
mes "Invalid. Does not exists in the logs!";
close;
R_Noreward:
mes "^FF0000[Rewards NPC]^000000";
mes "No rewards at the meantime";
mes "Get out!";
close;
OnInit:
query_sql "CREATE TABLE IF NOT EXISTS `rewardplayernpc` (`playername` TINYTEXT NOT NULL, `reward_id` INT NOT NULL, `reward_amount` INT NOT NULL, INDEX `playername` (`playername`(32)) ) ENGINE=MyISAM";
query_sql "CREATE TABLE IF NOT EXISTS `rewardpartynpc` (`partyname` TINYTEXT NOT NULL, `reward_id` INT NOT NULL, `reward_amount` INT NOT NULL, INDEX `partyname` (`partyname`(32)) ) ENGINE=MyISAM";
query_sql "CREATE TABLE IF NOT EXISTS `rewardguildnpc` (`guildname` TINYTEXT NOT NULL, `reward_id` INT NOT NULL, `reward_amount` INT NOT NULL, INDEX `guildname` (`guildname`(32)) ) ENGINE=MyISAM";
}
/* Add npc's here (duplicate) ciao */
lunette,73,97,1 duplicate(Rewards#101) Rewards NPC 100
well i would like to know first where do i have to add this in gitlab to get it "run on the server"
i would like to choose my own sprite of this npc script (ID #2538) rAthena
and seperate to the "all GMs over lvl 80 can type in the #item id ) i would like to be the own who can type in the Id and i would like to add few items which can be obtainable with event tickets (id #7711)
Hopefully anyone could help me out. thanks