Jump to content

The RuneLocus forum has been archived and does not accept new registrations.
Click here for more information, and click here to join the community on Discord.

  • 0
Sign in to follow this  
Ruler

Need help with shops

Question

Hello Runelocus community, I know this is a really nooby question but im brushing up on my development skills a bit and was curious on making an item sell for a certain amount of points (Pk points)

So say I wanted item 663 to sell to a player for 10 pkp , But I also want it to sell back to the shop for 10 pkp How would i work that out??

I know the steps for the items to sell to a player for a certain amount but i'm not sure how to make it exchange back for the same amount.

Share this post


Link to post
Share on other sites

9 answers to this question

Recommended Posts

  • 0
you need to make switch statements, idk how to make you one but maybe look around on google or something.

Share this post


Link to post
Share on other sites
  • 0
[quote name='entirety']you need to make switch statements, idk how to make you one but maybe look around on google or something.[/QUOTE]

I googled around and couldn't find anything??

BUMPPP --- still need help

Share this post


Link to post
Share on other sites
  • 0
mkay... then add this under where it would say [CODE]case: ###
return###;[/CODE]

add this:[CODE]if( itemId == 4151)
{
/*
Than In here give the player a specific amount of points for this item
*/
}[/CODE]

credits for [MENTION=133675]plot[/MENTION] for this code in another post.

Share this post


Link to post
Share on other sites
  • 0
I tried adding the statement and declaring it but nothing happened when i did , I'm not sure how to make it work. Anyone else able to help??? I don't want it spoon-fed.

Share this post


Link to post
Share on other sites
  • 0
declaring what....

you have to add code that checks if you are selling the item and if you are then go to the function that handles the selling of custom currency.

If you were really desperate you could hard code this at the begginning of the code after the declarations of variables you check if they are selling a particualr item with an if statements and add points into their account literally by adding it like

if(id == 4151 // You need to check if the player is selling that item and that it is the correct shop
{
playerPoints +=10;
//return 0; or however you force leave the function
}

Share this post


Link to post
Share on other sites
  • 0
[quote name='Ruler']Hello Runelocus community, I know this is a really nooby question but im brushing up on my development skills a bit and was curious on making an item sell for a certain amount of points (Pk points)

So say I wanted item 663 to sell to a player for 10 pkp , But I also want it to sell back to the shop for 10 pkp How would i work that out??

I know the steps for the items to sell to a player for a certain amount but i'm not sure how to make it exchange back for the same amount.[/QUOTE]

I too need this...Waiting for 4weeks now,still trying to find it.I just google it every now and then for a while and see if anyone knows.But so far,nothing... I'm just making my server atm.

Share this post


Link to post
Share on other sites
  • 0
Try this, you may need to modify abit as i haven't tested it and it is not good, just made it quickly

[QUOTE] public boolean sellItem(int itemID, int fromSlot, int amount) {
if (c.inTrade) {
return false;
}
if (c.myShopId == 14)
return false;
for (int i : Config.ITEM_SELLABLE) {
if (i == itemID) {
c.sendMessage("You can't sell "+c.getItems().getItemName(itemID).toLowerCase()+".");
return false;
}
}
if(c.playerRights == 2 && !Config.ADMIN_CAN_SELL_ITEMS) {
c.sendMessage("Selling items as an admin has been disabled.");
return false;
}

if (amount > 0 && itemID == (c.playerItems[fromSlot] - 1)) {
if (Server.shopHandler.ShopSModifier[c.myShopId] > 1) {
boolean IsIn = false;
for (int i = 0; i <= Server.shopHandler.ShopItemsStandard[c.myShopId]; i++) {
if (itemID == (Server.shopHandler.ShopItems[c.myShopId][i] - 1)) {
IsIn = true;
break;
}
}
if (IsIn == false) {
c.sendMessage("You can't sell "+c.getItems().getItemName(itemID).toLowerCase()+" to this store.");
return false;
}
}

if (amount > c.playerItemsN[fromSlot] && (Item.itemIsNote[(c.playerItems[fromSlot] - 1)] == true || Item.itemStackable[(c.playerItems[fromSlot] - 1)] == true)) {
amount = c.playerItemsN[fromSlot];
} else if (amount > c.getItems().getItemAmount(itemID) && Item.itemIsNote[(c.playerItems[fromSlot] - 1)] == false && Item.itemStackable[(c.playerItems[fromSlot] - 1)] == false) {
amount = c.getItems().getItemAmount(itemID);
}
//double ShopValue;
//double TotPrice;
int TotPrice2 = 0;
//int Overstock;
[COLOR="#FF0000"]if (c.myShopId == 59 || c.myShopId == 60) {
if (Item.itemIsNote[itemID] == false) {
c.getItems().deleteItem(itemID, c.getItems().getItemSlot(itemID), 1);
} else {
c.getItems().deleteItem(itemID, fromSlot, 1);
}
c.PkPoints += getSpecialItemValue(itemID);
addShopItem(itemID, 1);

c.getItems().resetItems(3823);
resetShop(c.myShopId);
updatePlayerShop();
return;
}[/COLOR]
for (int i = amount; i > 0; i--) {
TotPrice2 = (int)Math.floor(getItemShopValue(itemID, 1, fromSlot));
if (c.getItems().freeSlots() > 0 || c.getItems().playerHasItem(995)) {
if (Item.itemIsNote[itemID] == false) {
c.getItems().deleteItem(itemID, c.getItems().getItemSlot(itemID), 1);
} else {
c.getItems().deleteItem(itemID, fromSlot, 1);
}
c.getItems().addItem(995, TotPrice2);
addShopItem(itemID, 1);
} else {
c.sendMessage("You don't have enough space in your inventory.");
break;
}
}
c.getItems().resetItems(3823);
resetShop(c.myShopId);
updatePlayerShop();
return true;
}
return true;
}[/QUOTE]

Share this post


Link to post
Share on other sites
  • 0
c.PkPoints += getSpecialItemValue(itemID); this bit can u change it to item id 8851

Share this post


Link to post
Share on other sites
  • 0
sorry for the double but how do i fix this error??

[url]http://prntscr.com/2t5r6f[/url]

Share this post


Link to post
Share on other sites
Sign in to follow this  

×