i need to make a usable item do this:
when activated, it counts the number of item x in the players inventory. then it removes all of the players item x and then grants the player the same number of item y. so if the player has 300 item x, it removes all 300 item x and grants 300 item y. if the player has no item x, it messages the player "you need item x for this to work"
is this possible? your help is really appriciated, this is the last script hurdle i need to jump before the planet is playable. thanks.
1 scripting question please help!
this *should* do it. although it would spam the user with a grant and ungrant message for each item they have.
what it does is check to see if the player has more then 0 of the items, then runs a custom event that loops replacing each item one at a time until they are all replaced. once the player has none of the item left on them, the script ends and says 'transaction complete'
for some reason the forum wants to display the quotations as boxes.
but when copy/pasted into notepad, the boxes appear as quotations.
what it does is check to see if the player has more then 0 of the items, then runs a custom event that loops replacing each item one at a time until they are all replaced. once the player has none of the item left on them, the script ends and says 'transaction complete'
Code: Select all
Event (“Useitem”, “item x”)
{
if Playerinventory (“item x”) > 0)
{
CustomEvent( “replacexy” )
}
else
{
*msg %player% you need item x for this to work
}
Event (“Custom”,”replacexy”)
{
if Playerinventory (“item x”) > 0)
{
*grantitem %player% -1 item x
*grantitem %player% 1 item y
CustomEvent( “replacexy” )
}
else
{
*msg %player% transaction complete
}
}
but when copy/pasted into notepad, the boxes appear as quotations.
this one is the exact same as above, but should yield less spam.
if a player has more then a hundred of the item, it will replace a hundred at a time
if a player has between 50 and 100, it will replace 50 at a time
if a player has between 25 and 50, it will replace 25 at a time
if a player has between 10 and 25, it will replace 10 at a time
if a player has between 1 and 10, it will replace 1 at a time
once again, copy into notepad to see the boxes as quotations
if a player has more then a hundred of the item, it will replace a hundred at a time
if a player has between 50 and 100, it will replace 50 at a time
if a player has between 25 and 50, it will replace 25 at a time
if a player has between 10 and 25, it will replace 10 at a time
if a player has between 1 and 10, it will replace 1 at a time
Code: Select all
Event (“Useitem”, “item x”)
{
if Playerinventory (“item x”) > 0)
{
CustomEvent( “replacexy” )
}
else
{
*msg %player% you need item x for this to work
}
Event (“Custom”,”replacexy”)
{
if Playerinventory (“item x”) > 0)
{
if Playerinventory (“item x”) > 9)
{
if Playerinventory (“item x”) > 24)
{
if Playerinventory (“item x”) > 49)
{
if Playerinventory (“item x”) > 99)
{
*grantitem %player% -100 item x
*grantitem %player% 100 item y
CustomEvent( “replacexy” )
}
else
{
*grantitem %player% -50 item x
*grantitem %player% 50 item y
CustomEvent( “replacexy” )
}
}
else
{
*grantitem %player% -25 item x
*grantitem %player% 25 item y
CustomEvent( “replacexy” )
}
}
else
{
*grantitem %player% -10 item x
*grantitem %player% 10 item y
CustomEvent( “replacexy” )
}
}
else
{
*grantitem %player% -1 item x
*grantitem %player% 1 item y
CustomEvent( “replacexy” )
}
}
else
{
*msg %player% transaction complete
}
}
once again, copy into notepad to see the boxes as quotations
I haven't tried this, and im not up-to-date with how my own scripting language works, but is there any reason you can't just do this?
If there is a reason, its probably something i can easily fix
Code: Select all
$numItems = Playerinventory("itemX")
$numItemsNeg = 0 - $numItems
*grantitem %player% $numItemsNeg itemX
*grantitem %player% $numItems itemY