Jump to content
  • 0

Hey guys can you help me fix this script..


Critica

Question


  • Group:  Members
  • Topic Count:  82
  • Topics Per Day:  0.02
  • Content Count:  223
  • Reputation:   4
  • Joined:  02/23/12
  • Last Seen:  

//===== eAthena Script =======================================
//= Scavenger Hunt NPC
//===== By: ==================================================
//= Iceandrews and MagnusG87
//= Contact: caiaphas(at)hotmail.com
//= eAthena ID: Iceandrews
//===== Description: =========================================
//=
//= This NPC initiates a server wide Scavenger Hunt.
//= The NPC generates a list of 10 items that are to be
//= collected.  This list is valid for everyone on the entire
//= server.  All players compete against each other to gather
//= the items in the hunt.  Once a player collects all the
//= items, they can turn them in for a large experience
//= reward, both job and base.  At this time, a new list of
//= items is generated for the entire server.  If at any time
//= the list of items is too hard, or impossible to gather,
//= a GM character can reset the game and generate a new list
//= of items.  Only GM characters or a server restart will
//= generate a new list of items.
//=
//= ******************* WARNINGS *****************************
//= 1 - It is possible that some hunts may be impossible.
//= This script should generate a list of items that are
//= dropped by a mosnter or sold by and NPC.  However,
//= it may select a mosnter that is NOT in the game.
//= I believe this is a rare case.
//= 2 - This script makes use of a global variable.
//=
//===== Version History: =====================================
//= 1.0 - Initial Release
//= 1.1 - Made adjustments to the way in which it generated
//=   the item list.  Previously, it was ANY random item
//=   from the item_db.txt.  Now it should ONLY items
//=   that are either dropped by a monster  or sold by
//=   any NPC.  I also added code to choose between
//=   and experience reward or a specified number of base
//=   and job levels.
//= 1.2 - Added item control.
//============================================================

prontera,143,101,6 script ScavengerHunt 856,{
set .ireward,909; // change the 909 for your own item reward.
set .iamount,1; // ammount of the item reward.
//Main Menu Choices.
mes "[scavenger Hunt]";
mes "Welcome to the Scavenger Hunt!";
next;
menu "View Current Scavenger Hunt Items",ViewItems,
 "Hand in Current Scavenger Hunt Items",CheckForItems,
 "Leave",QuitHunt,
 "Initiate New Scavenger Hunt",GMCheck;

// Diplays the list of items and their item ID number
// that is valid for the current hunt.
ViewItems:
mes "[scavenger Hunt]";
mes "This is the current list of items.";
mes "";
for(set .@i,0; .@i < 10; set .@i,.@i+1)
{
 mes .@i+1 + ". " + getitemname($@scavengerList[.@i]) + " - Item ID:" + $@scavengerList[.@i];
}
next;
menu "Leave",QuitHunt;

// Check to make sure you have all the required items
// in your inventory.  If you do, you get the rewards.
// If not, the NPC interactions ends.
CheckForItems:
for(set .@i,0; .@i < 10; set .@i,.@i+1)
{
 if(countitem($@scavengerList[.@i]) == 0)
 {
  goto DoesNotHaveItems;
 }
}
goto HasRequiredItems;

// Player has the required items.
// The player can turn in the items for a reward.
// They can also not turn anything in and just leave.
HasRequiredItems:
mes "[scavenger Hunt]";
mes "Congratulations! You've collected all the items in this Scavenger Hunt. Would you like to turn them in for the reward?";
next;
menu "Yes",HandInItems,
 "No",DoNotHandInItems;

// Takes the items from the players inventory.
// Player receives an experience reward.
HandInItems:
for(set .@i,0; .@i < 10; set .@i,.@i+1)
{
 delitem $@scavengerList[.@i],1;
}
// Reward!
getitem .ireward,.iamount;

// Instead of experience, this reward is for a
// specified number of base and job levels.
// Change the numbers accordingly for your server.
//atcommand "@blvl 5";
//atcommand "@jlvl 5";

callfunc "setScavengerList";
announce "Attention! A new scavenger hunt has begun!  Come and get the new item list!",bc_all;
mes "[scavenger Hunt]";
mes "You've gained base and job experience.";
next;
menu "Leave",QuitHunt;

// Check to make sure player is a GM.
// If they player is a GM, generate a new item list.
// If they are not, provide a message and leave the NPC.
GMCheck:
if (getgmlevel())
{
 callfunc "setScavengerList";
 mes "[scavenger Hunt]";
 mes "A new list of item has been generated. Thanks!";
 next;
 menu "View Current Scavenger Hunt Items",viewItems,
  "Leave",QuitHunt;
}
else
{
 mes "[scavenger Hunt]";
 mes "Sorry, you don't have the rights to start a new Scavenger Hunt.";
 next;
 menu "Leave",QuitHunt;
}

// Player does not have the required items.
DoesNotHaveItems:
mes "[scavenger Hunt]";
mes "Sorry, but it looks like you are missing some items. Come back when you've collected everything.";
next;
menu "Leave",QuitHunt;

// Player chooses not to hand in the items.
DoNotHandInItems:
mes "[scavenger Hunt]";
mes "Aww, but you're missing out on a great reward!";
next;
menu "Leave",QuitHunt;

// Ends NPC interaction.
QuitHunt:
mes "[scavenger Hunt]";
mes "Good luck finding everything!";
close;

// NPC Intialization
OnInit:
callfunc "setScavengerList";
end;
}

function script setScavengerList {

//initializes list of scavenger items
for( set .@i,0; .@i < 10 ; set .@i,.@i+1 )
{
 set .@valid, 0;

 //continue generating random numbers until a valid item is found
 while(.@valid == 0)
 {
  // This is the range of item IDs that can be produced
  // for any given scavenger hunt.  This can be changed.
  set .@j, rand(501, 12153);

  // This takes the random number above and does 2 things.
  // First it check to see if the item exists at all.
  // If getiteminfo() returns -1, then an item with that
  // number is not in the item database.  If that item does
  // exist, then it returns the maximum drop rate for that
  // item from the entier mosnter set.  For example, if the
  // item is a 'Apple', and both Porings (5%) and Luncatis (1%)
  // drop this item, the function will return 5.  This verifies
  // that the item ID gernerated is dropped by a monster.
  // If the returned number is 10000, this means it is
  // sold by an NPC.  So this generates a list of random
  // items that are either dropped by a mosnter or sold
  // by and NPC.
  if(getiteminfo(.@j,3) > 0)
  {
set $@scavengerList[.@i], .@j;
set .@valid , 1;
  }
 }
}
return;
}

iM not sure if its ok to post somebody's script to edit it.. if not then ill just delete it then..

if its ok,, can anyone help me fix it?

everytime i tried to Initiate the NPC, it gives me an error on map server syng "infinity loop"

im not sure what's wrong.. so guys can you help me? thanks..

Link to comment
Share on other sites

2 answers to this question

Recommended Posts


  • Group:  Members
  • Topic Count:  0
  • Topics Per Day:  0
  • Content Count:  9
  • Reputation:   0
  • Joined:  05/11/12
  • Last Seen:  

//===== eAthena Script =======================================
//= Scavenger Hunt NPC
//===== By: ==================================================
//= Iceandrews and MagnusG87
//= Contact: caiaphas(at)hotmail.com
//= eAthena ID: Iceandrews
//===== Description: =========================================
//=
//= This NPC initiates a server wide Scavenger Hunt.
//= The NPC generates a list of 10 items that are to be


prontera,150,162,5 script ScavengerHunt 856,{
//Main Menu Choices.
mes "[scavenger Hunt]";
mes "Welcome to the Scavenger Hunt!";
next;
menu "View Current Scavenger Hunt Items",ViewItems,
"Hand in Current Scavenger Hunt Items",CheckForItems,
"Leave",QuitHunt,
"Initiate New Scavenger Hunt",GMCheck;


// Diplays the list of items and their item ID number
// that is valid for the current hunt.
ViewItems:
mes "[scavenger Hunt]";
mes "This is the current list of items.";
mes "";
for(set .@i,0; .@i < 10; set .@i,.@i+1)
{
mes .@i+1 + ". " + getitemname($@scavengerList[.@i]) + " - Item ID:" + $@scavengerList[.@i];
}
next;
menu "Leave",QuitHunt;



// Check to make sure you have all the required items
// in your inventory.  If you do, you get the rewards.
// If not, the NPC interactions ends.
CheckForItems:
for(set .@i,0; .@i < 10; set .@i,.@i+1)
{
if(countitem($@scavengerList[.@i]) == 0)
{
goto DoesNotHaveItems;
}
}
goto HasRequiredItems;



// Player has the required items.  
// The player can turn in the items for a reward.
// They can also not turn anything in and just leave.
HasRequiredItems:
mes "[scavenger Hunt]";
mes "Congratulations! You've collected all the items in this Scavenger Hunt. Would you like to turn them in for the reward?";
next;
menu "Yes",HandInItems,
"No",DoNotHandInItems;



// Takes the items from the players inventory.
// Player receives an experience reward.
HandInItems:
for(set .@i,0; .@i < 10; set .@i,.@i+1)
{
delitem $@scavengerList[.@i],1;
}


getitem 6153,1;


// Instead of experience, this reward is for a
// specified number of base and job levels.
// Change the numbers accordingly for your server.

//atcommand "@blvl 5";
//atcommand "@jlvl 5";

callfunc "setScavengerList";
announce "Attention! A new scavenger hunt has begun!  Come and get the new item list!",bc_all;
mes "[scavenger Hunt]";
mes "You've gained base and job experience.";
next;
menu "Leave",QuitHunt;



// Check to make sure player is a GM.
// If they player is a GM, generate a new item list.
// If they are not, provide a message and leave the NPC.
GMCheck:
if (getgmlevel())
{
callfunc "setScavengerList";
mes "[scavenger Hunt]";
mes "A new list of item has been generated. Thanks!";
next;
menu "View Current Scavenger Hunt Items",viewItems,
"Leave",QuitHunt;
}
else
{
mes "[scavenger Hunt]";
mes "Sorry, you don't have the rights to start a new Scavenger Hunt.";
next;
menu "Leave",QuitHunt;
}



// Player does not have the required items.
DoesNotHaveItems:
mes "[scavenger Hunt]";
mes "Sorry, but it looks like you are missing some items. Come back when you've collected everything.";
next;
menu "Leave",QuitHunt;



// Player chooses not to hand in the items.
DoNotHandInItems:
mes "[scavenger Hunt]";
mes "Aww, but you're missing out on a great reward!";
next;
menu "Leave",QuitHunt;



// Ends NPC interaction.
QuitHunt:
mes "[scavenger Hunt]";
mes "Good luck finding everything!";
close;



// NPC Intialization
OnInit:
callfunc "setScavengerList";
end;
}


function script setScavengerList {

//initializes list of scavenger items
for( set .@i,0; .@i < 10 ; set .@i,.@i+1 )
{
set .@valid, 0;

//continue generating random numbers until a valid item is found
while(.@valid == 0)
{
// This is the range of item IDs that can be produced
// for any given scavenger hunt.  This can be changed.

set .@j, rand(701, 1060);

// This takes the random number above and does 2 things.
// First it check to see if the item exists at all.
// If getiteminfo() returns -1, then an item with that
// number is not in the item database.  If that item does
// exist, then it returns the maximum drop rate for that
// item from the entier mosnter set.  For example, if the
// item is a 'Apple', and both Porings (5%) and Luncatis (1%)
// drop this item, the function will return 5.  This verifies
// that the item ID gernerated is dropped by a monster.
// If the returned number is 10000, this means it is
// sold by an NPC.  So this generates a list of random
// items that are either dropped by a mosnter or sold
// by and NPC.

if(getiteminfo(.@j,3) > 0)
{
set $@scavengerList[.@i], .@j;
set .@valid , 1;
}
}
}

return;

}

dont reload script or loadnpc

restart server is better to effect that script

i simple edit that script and add to my server

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  16
  • Topics Per Day:  0.00
  • Content Count:  658
  • Reputation:   57
  • Joined:  11/20/11
  • Last Seen:  

Please us Codeboxes next time. I added them now.

Link to comment
Share on other sites

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.

×
×
  • Create New...