crazyarashi Posted April 8, 2017 Posted April 8, 2017 Hi, Good Day Rathena I want to know how to limit an accessory effect to 1 only. For example of you wear 2 Glorious Ring Only 1 will effect. and the other wont have effect. Is it in the item script? or others.. Quote
0 Jey Posted April 8, 2017 Posted April 8, 2017 (edited) Oh I just realized: *isequippedcnt is for counting cards only. Sorry didn't see it correctly. I thought it will count equipped items by a given nameid. So a command to count equipped items is missing. There are now other possible solutions: As I mentioned above change the equip loc of the accessory to either right or left. (easiest method) Write a custom script-command like *countequipped(<itemid>) (most efficient solution) Write a custom script-function by using getinventorylist to count equipped items. Example: # Careful! Not tested. function script countequipped { getinventorylist(); .@nameid = getarg(0,0); .@count = 0; for( .@i = 0; .@i < @inventorylist_count; .@i++) { if( @inventorylist_id[.@i] == .@nameid && @inventorylist_equip[.@i] > 0 ) .@count++; } return .@count; } Use countitem as a workaround for countequipped (Note: every inventory item will be counted) Example DB entry for Clip: 2607,Clip,Clip,4,30000,,100,,0,,1,0xFFFFFFFF,63,2,136,,0,0,0,{ bonus bMaxSP,10; },{},{} #standard 2607,Clip,Clip,4,30000,,100,,0,,1,0xFFFFFFFF,63,2,136,,0,0,0,{ if( callfunc("countequipped",2607) > 1 ) { bonus bMaxSP,5; } else { bonus bMaxSP,10; } },{},{} If you're interested in using the command "countequipped", I'll create a pull request for it as a script command, since I wouldn't recommend the inflationary use of getinventorylist. Edited April 8, 2017 by Jey 2 Quote
1 crazyarashi Posted August 20, 2018 Author Posted August 20, 2018 13 hours ago, OscarScorp said: @crazyarashi , does that function works as intended? Only 1 effect from both accessories equipped will be on effect? I ask because of the "Caerful! Not tested." comment. i used only once but it worked fine :)) Quote
0 Jey Posted April 8, 2017 Posted April 8, 2017 The easiest way is to set the accessory either as "left" or "right" accessory in the database, so you simply can't equip multiple of them. Another way is to use isequippedcnt(<id>) in the item script and divide the effect into half if there is more than one equipped. (Not really pretty imo) 1 Quote
0 crazyarashi Posted April 8, 2017 Author Posted April 8, 2017 25 minutes ago, Jey said: The easiest way is to set the accessory either as "left" or "right" accessory in the database, so you simply can't equip multiple of them. Another way is to use isequippedcnt(<id>) in the item script and divide the effect into half if there is more than one equipped. (Not really pretty imo) Hi do you mind if i ask for an example if the script. isequippedcnt :)) Quote
0 crazyarashi Posted April 8, 2017 Author Posted April 8, 2017 15 minutes ago, Jey said: Oh I just realized: *isequippedcnt is for counting cards only. Sorry didn't see it correctly. I thought it will count equipped items by a given nameid. So a command to count equipped items is missing. There are now other possible solutions: As I mentioned above change the equip loc of the accessory to either right or left. (easiest method) Write a custom script-command like *countequipped(<itemid>) (most efficient solution) Write a custom script-function by using getinventorylist to count equipped items. Example: # Careful! Not tested. function script countequipped { getinventorylist(); .@nameid = getarg(0,0); .@count = 0; for( .@i = 0; .@i < @inventorylist_count; .@i++) { if( @inventorylist_id[.@i] == .@nameid && @inventorylist_equip[.@i] > 0 ) .@count++; } return .@count; } Use countitem as a workaround for countequipped (Note: every inventory item will be counted) Example DB entry for Clip: 2607,Clip,Clip,4,30000,,100,,0,,1,0xFFFFFFFF,63,2,136,,0,0,0,{ bonus bMaxSP,10; },{},{} #standard 2607,Clip,Clip,4,30000,,100,,0,,1,0xFFFFFFFF,63,2,136,,0,0,0,{ if( callfunc("countequipped",2607) > 1 ) { bonus bMaxSP,5; } else { bonus bMaxSP,10; } },{},{} If you're interested in using the command "countequipped", I'll create a pull request for it as a script command, since I wouldn't recommend the inflationary use of getinventorylist. Please do Thanks for the help :)) Quote
0 OscarScorp Posted August 19, 2018 Posted August 19, 2018 @crazyarashi , does that function works as intended? Only 1 effect from both accessories equipped will be on effect? I ask because of the "Caerful! Not tested." comment. Quote
0 PsyOps Posted September 1, 2020 Posted September 1, 2020 On 4/9/2017 at 7:09 AM, Jey said: Oh I just realized: *isequippedcnt is for counting cards only. Sorry didn't see it correctly. I thought it will count equipped items by a given nameid. So a command to count equipped items is missing. There are now other possible solutions: As I mentioned above change the equip loc of the accessory to either right or left. (easiest method) Write a custom script-command like *countequipped(<itemid>) (most efficient solution) Write a custom script-function by using getinventorylist to count equipped items. Example: # Careful! Not tested. function script countequipped { getinventorylist(); .@nameid = getarg(0,0); .@count = 0; for( .@i = 0; .@i < @inventorylist_count; .@i++) { if( @inventorylist_id[.@i] == .@nameid && @inventorylist_equip[.@i] > 0 ) .@count++; } return .@count; } Use countitem as a workaround for countequipped (Note: every inventory item will be counted) Example DB entry for Clip: 2607,Clip,Clip,4,30000,,100,,0,,1,0xFFFFFFFF,63,2,136,,0,0,0,{ bonus bMaxSP,10; },{},{} #standard 2607,Clip,Clip,4,30000,,100,,0,,1,0xFFFFFFFF,63,2,136,,0,0,0,{ if( callfunc("countequipped",2607) > 1 ) { bonus bMaxSP,5; } else { bonus bMaxSP,10; } },{},{} If you're interested in using the command "countequipped", I'll create a pull request for it as a script command, since I wouldn't recommend the inflationary use of getinventorylist. So it means that if the player is wearing one ring and has the same ring on his inventory, then the script will count it as having two items? Quote
Question
crazyarashi
Hi, Good Day Rathena I want to know how to limit an accessory effect to 1 only.
For example of you wear 2 Glorious Ring Only 1 will effect. and the other wont have effect.
Is it in the item script? or others..
7 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.