domez86 Posted April 14, 2019 Group: Members Topic Count: 85 Topics Per Day: 0.02 Content Count: 207 Reputation: 0 Joined: 06/11/13 Last Seen: July 11, 2020 Share Posted April 14, 2019 (edited) hi, I need a npc that gives a free equip, but if the char already has the same item in the inventory or equipped you say that you already have it. thank you Edited April 15, 2019 by domez86 Quote Link to comment Share on other sites More sharing options...
0 crazyarashi Posted April 15, 2019 Group: Developer Topic Count: 50 Topics Per Day: 0.02 Content Count: 776 Reputation: 239 Joined: 02/11/17 Last Seen: 19 hours ago Share Posted April 15, 2019 24 minutes ago, domez86 said: can you explain this script to me? Does the item equip it directly? do I just have to enter an item id? you didn't mention about being equipped on the topic. prontera,255,255,3 script Equip Freebies 123,{ if(#claimed){ mes "[ Freebies ]"; mes "You alreay receieved your freebies."; close; } getinventorylist; for(.@i = 0; .@i < 20; .@i++){ .@id = getequipid(.@i); if(.@id == -1) .@equip_id[.@i] = 0; // Dummy Data else .@equip_id[.@i] = .@id; } for(.@i = 0; .@i < getarraysize(.equip_id); .@i++){ if(inarray(.@equip_id[0],.equip_id[.@i]) >= 0 || inarray(@inventorylist_id[0],.equip_id[.@i]) >= 0){ .@fail = 1; break; } continue; } if(.@fail){ mes "[ Freebies ]"; mes "You already have a duplicated freebies in your inventory/equipment."; close; } #claimed = 1; for(.@i = 0; .@i < getarraysize(.equip_id); .@i++){ getitem .equip_id[.@i],1; equip .equip_id[.@i]; } mes "[ Freebies ]"; mes "Here is your freebies."; end; OnInit: setarray .equip_id,1208,2154; // Add your ID's here. end; } Here is the new script that it will automatically equip it after receiving :)) 1 Quote Link to comment Share on other sites More sharing options...
1 crazyarashi Posted April 15, 2019 Group: Developer Topic Count: 50 Topics Per Day: 0.02 Content Count: 776 Reputation: 239 Joined: 02/11/17 Last Seen: 19 hours ago Share Posted April 15, 2019 (edited) prontera,255,255,3 script Equip Freebies 123,{ if(#claimed){ mes "[ Freebies ]"; mes "You alreay receieved your freebies."; close; } getinventorylist; for(.@i = 0; .@i < 20; .@i++){ .@id = getequipid(.@i); if(.@id == -1) .@equip_id[.@i] = 0; // Dummy Data else .@equip_id[.@i] = .@id; } for(.@i = 0; .@i < getarraysize(.equip_id); .@i++){ if(inarray(.@equip_id[0],.equip_id[.@i]) >= 0 || inarray(@inventorylist_id[0],.equip_id[.@i]) >= 0){ .@fail = 1; break; } continue; } if(.@fail){ mes "[ Freebies ]"; mes "You already have a duplicated freebies in your inventory/equipment."; close; } #claimed = 1; for(.@i = 0; .@i < getarraysize(.equip_id); .@i++){ getitem .equip_id[.@i],1; } mes "[ Freebies ]"; mes "Here is your freebies."; end; OnInit: setarray .equip_id,1208,2154; // Add your ID's here. end; } Edited April 15, 2019 by crazyarashi Quote Link to comment Share on other sites More sharing options...
0 Normynator Posted April 14, 2019 Group: Developer Topic Count: 7 Topics Per Day: 0.00 Content Count: 292 Reputation: 199 Joined: 05/03/13 Last Seen: May 26, 2023 Share Posted April 14, 2019 (edited) 23 minutes ago, AndyTheGoblin said: Impossible That’s wrong, it is possible. Check the successrefitem script source. Its certainly not possible to do it without writing your own script command, as far as I know. but creating the command you want should be quite simple with the successrefitem as reference. Edited April 14, 2019 by Normynator Quote Link to comment Share on other sites More sharing options...
0 domez86 Posted April 15, 2019 Group: Members Topic Count: 85 Topics Per Day: 0.02 Content Count: 207 Reputation: 0 Joined: 06/11/13 Last Seen: July 11, 2020 Author Share Posted April 15, 2019 i modified this: start_items: 1201,1,2:2301,1,16 in this: start_items: 1201,1,2:2301,1,16:2154,1,65536 but not work.... Quote Link to comment Share on other sites More sharing options...
0 Seravy Posted April 15, 2019 Group: Members Topic Count: 31 Topics Per Day: 0.01 Content Count: 176 Reputation: 60 Joined: 01/11/19 Last Seen: March 12, 2021 Share Posted April 15, 2019 (edited) Why inventory? Why not if (character variable=0) give item and set character variable to 1? Not sure if the syntax is correct but like this : if (FreeItemGiven==0) { getitem 2500,1; FreeItemGiven = 1; close; } else { mes "You already received your free items!"; close; } Edited April 15, 2019 by Seravy Quote Link to comment Share on other sites More sharing options...
0 domez86 Posted April 15, 2019 Group: Members Topic Count: 85 Topics Per Day: 0.02 Content Count: 207 Reputation: 0 Joined: 06/11/13 Last Seen: July 11, 2020 Author Share Posted April 15, 2019 1 hour ago, crazyarashi said: prontera,255,255,3 script Equip Freebies 123,{ if(#claimed){ mes "[ Freebies ]"; mes "You alreay receieved your freebies."; close; } getinventorylist; for(.@i = 0; .@i < 20; .@i++){ .@id = getequipid(.@i); if(.@id == -1) .@equip_id[.@i] = 0; // Dummy Data else .@equip_id[.@i] = .@id; } for(.@i = 0; .@i < getarraysize(.equip_id); .@i++){ if(inarray(.@equip_id[0],.equip_id[.@i]) >= 0 || inarray(@inventorylist_id[0],.equip_id[.@i]) >= 0){ .@fail = 1; break; } continue; } if(.@fail){ mes "[ Freebies ]"; mes "You already have a duplicated freebies in your inventory/equipment."; close; } #claimed = 1; for(.@i = 0; .@i < getarraysize(.equip_id); .@i++){ getitem .equip_id[.@i],1; } mes "[ Freebies ]"; mes "Here is your freebies."; end; OnInit: setarray .equip_id,1208,2154; // Add your ID's here. end; } can you explain this script to me? Does the item equip it directly? do I just have to enter an item id? Quote Link to comment Share on other sites More sharing options...
0 Skorm Posted April 15, 2019 Group: Forum Moderator Topic Count: 33 Topics Per Day: 0.01 Content Count: 1282 Reputation: 393 Joined: 02/03/12 Last Seen: April 11 Share Posted April 15, 2019 (edited) 40 minutes ago, crazyarashi said: you didn't mention about being equipped on the topic. Here is the new script that it will automatically equip it after receiving :)) Could maybe shorten it to... prontera,255,255,3 script Equip Freebies 123,{ getinventorylist; copyarray .@inventory[0],@inventorylist_id[0],getarraysize(@inventorylist_id); for(.@i = 0; .@i < .len; .@i++){ if(!isequipped(.equip_id[.@i]) && inarray(.@inventory, .equip_id[.@i]) == -1) { getitem .equip_id[.@i],1; equip .equip_id[.@i]; } else .@fail++; } mes "[ Freebies ]"; if(!.len - .@fail){ mes "It looks like you already have all the freebie(s)."; close; } else if (.@fail) mes "It looks like you already have "+.@fail+" freebie(s)."; mes "Here is your freebies."; close; OnInit: setarray .equip_id, 1208, 2154; // Add your ID's here. .len = getarraysize(.equip_id); } Although in this case if the user was able to store/trade the freebies he could get more, but it would also allow the list of freebies to be updated. Also my example is completely untested so... Edit: I think equipped items might already show up in the @inventorylist_id so I might not even need isequipped(). Edited April 15, 2019 by Skorm 1 Quote Link to comment Share on other sites More sharing options...
0 crazyarashi Posted April 15, 2019 Group: Developer Topic Count: 50 Topics Per Day: 0.02 Content Count: 776 Reputation: 239 Joined: 02/11/17 Last Seen: 19 hours ago Share Posted April 15, 2019 20 minutes ago, Skorm said: Could maybe shorten it too... prontera,255,255,3 script Equip Freebies 123,{ getinventorylist; copyarray .@inventory[0],@inventorylist_id[0],getarraysize(@inventorylist_id); for(.@i = 0; .@i < .len; .@i++){ if(isequipped(.equip_id[.@i]) || inarray(.@inventory, .equip_id[.@i]) > -1) { getitem .equip_id[.@i],1; equip .equip_id[.@i]; } else .@fail++; } mes "[ Freebies ]"; if(!.len - .@fail){ mes "It looks like you already have all the freebie(s)."; close; } else if (.@fail) mes "It looks like you already have "+.@fail+" freebie(s)."; mes "Here is your freebies."; close; OnInit: setarray .equip_id, 1208, 2154; // Add your ID's here. .len = getarraysize(.equip_id); } Although in this case if the user was able to store/trade the freebies he could get more, but it would also allow the list of freebies to be updated. Also my example is completely untested so... I forgot about the isequipped that could have shorten it a little bit ^^ Quote Link to comment Share on other sites More sharing options...
0 domez86 Posted April 16, 2019 Group: Members Topic Count: 85 Topics Per Day: 0.02 Content Count: 207 Reputation: 0 Joined: 06/11/13 Last Seen: July 11, 2020 Author Share Posted April 16, 2019 (edited) 11 hours ago, crazyarashi said: you didn't mention about being equipped on the topic. prontera,255,255,3 script Equip Freebies 123,{ if(#claimed){ mes "[ Freebies ]"; mes "You alreay receieved your freebies."; close; } getinventorylist; for(.@i = 0; .@i < 20; .@i++){ .@id = getequipid(.@i); if(.@id == -1) .@equip_id[.@i] = 0; // Dummy Data else .@equip_id[.@i] = .@id; } for(.@i = 0; .@i < getarraysize(.equip_id); .@i++){ if(inarray(.@equip_id[0],.equip_id[.@i]) >= 0 || inarray(@inventorylist_id[0],.equip_id[.@i]) >= 0){ .@fail = 1; break; } continue; } if(.@fail){ mes "[ Freebies ]"; mes "You already have a duplicated freebies in your inventory/equipment."; close; } #claimed = 1; for(.@i = 0; .@i < getarraysize(.equip_id); .@i++){ getitem .equip_id[.@i],1; equip .equip_id[.@i]; } mes "[ Freebies ]"; mes "Here is your freebies."; end; OnInit: setarray .equip_id,1208,2154; // Add your ID's here. end; } Here is the new script that it will automatically equip it after receiving :)) hi, can I ask you how the npc detects that a char has already taken the equip? because I see that id equip you only insert it in 1 position in the script. Edited April 16, 2019 by domez86 Quote Link to comment Share on other sites More sharing options...
0 sader1992 Posted April 16, 2019 Group: Content Moderator Topic Count: 55 Topics Per Day: 0.01 Content Count: 1691 Reputation: 716 Joined: 12/21/14 Last Seen: 19 hours ago Share Posted April 16, 2019 9 minutes ago, domez86 said: char has already taken the equip if(#claimed){ mes "[ Freebies ]"; mes "You alreay receieved your freebies."; close; } the player get #claimed = 1; when he get the equipment ,so he will hit the close every time after that in that case it's account variable , if you want it for each character , just remove the # 1 Quote Link to comment Share on other sites More sharing options...
0 domez86 Posted April 16, 2019 Group: Members Topic Count: 85 Topics Per Day: 0.02 Content Count: 207 Reputation: 0 Joined: 06/11/13 Last Seen: July 11, 2020 Author Share Posted April 16, 2019 (edited) 12 minutes ago, sader1992 said: if(#claimed){ mes "[ Freebies ]"; mes "You alreay receieved your freebies."; close; } the player get #claimed = 1; when he get the equipment ,so he will hit the close every time after that in that case it's account variable , if you want it for each character , just remove the # yes, it concerns every single char, not account equip. okok but I don't understand how this script it detects equip if id equip is not there. since it is an item that has all the restrictions (restrictions 507) I would like npc to look right in the inventory and in the equip and if it sees it it refuses. not that it looks if you have already received item, that is not only a script that is spoken only once. excuse my bad english Edited April 16, 2019 by domez86 Quote Link to comment Share on other sites More sharing options...
0 sader1992 Posted April 16, 2019 Group: Content Moderator Topic Count: 55 Topics Per Day: 0.01 Content Count: 1691 Reputation: 716 Joined: 12/21/14 Last Seen: 19 hours ago Share Posted April 16, 2019 5 minutes ago, domez86 said: yes, it concerns every single char, not account equip. okok but I don't understand how this script it detects equip if id equip is not there. setarray .equip_id,1208,2154; // Add your ID's here. the script work on the array variable .equip_id so you don't need to add the id all over the script , just add it here it's 101 how to basic xD setarray .equip_id,1208,2154; // Add your ID's here. = .equip_id[0] is 1208 .equip_id[1] is 2154 Quote Link to comment Share on other sites More sharing options...
0 domez86 Posted April 16, 2019 Group: Members Topic Count: 85 Topics Per Day: 0.02 Content Count: 207 Reputation: 0 Joined: 06/11/13 Last Seen: July 11, 2020 Author Share Posted April 16, 2019 7 minutes ago, sader1992 said: setarray .equip_id,1208,2154; // Add your ID's here. the script work on the array variable .equip_id so you don't need to add the id all over the script , just add it here it's 101 how to basic xD setarray .equip_id,1208,2154; // Add your ID's here. = .equip_id[0] is 1208 .equip_id[1] is 2154 and if i restart / reload server? Quote Link to comment Share on other sites More sharing options...
0 domez86 Posted April 16, 2019 Group: Members Topic Count: 85 Topics Per Day: 0.02 Content Count: 207 Reputation: 0 Joined: 06/11/13 Last Seen: July 11, 2020 Author Share Posted April 16, 2019 (edited) 12 minutes ago, sader1992 said: setarray .equip_id,1208,2154; // Add your ID's here. the script work on the array variable .equip_id so you don't need to add the id all over the script , just add it here it's 101 how to basic xD setarray .equip_id,1208,2154; // Add your ID's here. = .equip_id[0] is 1208 .equip_id[1] is 2154 and if i restart / reload server? after the first time, npc detects item in inventory / equip? or do you notice that you have already received items and that's it? Edited April 16, 2019 by domez86 Quote Link to comment Share on other sites More sharing options...
0 sader1992 Posted April 16, 2019 Group: Content Moderator Topic Count: 55 Topics Per Day: 0.01 Content Count: 1691 Reputation: 716 Joined: 12/21/14 Last Seen: 19 hours ago Share Posted April 16, 2019 5 minutes ago, domez86 said: and if i restart / reload server? after the first time, npc detects item in inventory / equip? or do you notice that you have already received items and that's it? this is your best friend https://github.com/rathena/rathena/blob/master/doc/script_commands.txt Quote Link to comment Share on other sites More sharing options...
0 domez86 Posted April 16, 2019 Group: Members Topic Count: 85 Topics Per Day: 0.02 Content Count: 207 Reputation: 0 Joined: 06/11/13 Last Seen: July 11, 2020 Author Share Posted April 16, 2019 4 hours ago, domez86 said: and if i restart / reload server? after the first time, npc detects item in inventory / equip? or do you notice that you have already received items and that's it? Excuse me, could you only answer my last question? Quote Link to comment Share on other sites More sharing options...
Question
domez86
hi, I need a npc that gives a free equip, but if the char already has the same item in the inventory or equipped you say that you already have it.
thank you
Edited by domez86Link to comment
Share on other sites
16 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.