mrpatrick Posted May 19, 2014 Group: Members Topic Count: 7 Topics Per Day: 0.00 Content Count: 28 Reputation: 2 Joined: 03/22/12 Last Seen: October 13, 2016 Share Posted May 19, 2014 Hello, does anyone here knows how to make a script that deletes a specific item from all players in a certain map?I need my players to have a specific item to be deleted in their inventory when my event is finished. I know that the command for the script is delitem but I don't know how to apply it to all player in a specific map. Thanks in advance! Quote Link to comment Share on other sites More sharing options...
Zell Posted May 19, 2014 Group: Members Topic Count: 53 Topics Per Day: 0.01 Content Count: 412 Reputation: 266 Joined: 04/25/12 Last Seen: Yesterday at 01:17 AM Share Posted May 19, 2014 To attach all players on npc map, use this: addrid(1); Quote Link to comment Share on other sites More sharing options...
mrpatrick Posted May 19, 2014 Group: Members Topic Count: 7 Topics Per Day: 0.00 Content Count: 28 Reputation: 2 Joined: 03/22/12 Last Seen: October 13, 2016 Author Share Posted May 19, 2014 actually, I don't know where to put that. Can you help me a little bit more? here is my script for example: OnTimer600000: Announce "The event has ended!",0; mapwarp "poring_w01","prontera",156,191; end; how should I apply it? Quote Link to comment Share on other sites More sharing options...
Zell Posted May 20, 2014 Group: Members Topic Count: 53 Topics Per Day: 0.01 Content Count: 412 Reputation: 266 Joined: 04/25/12 Last Seen: Yesterday at 01:17 AM Share Posted May 20, 2014 OnTimer600000: Announce "The event has ended!",0; addrid(1); delitem ID_ITEM,countitem(ID_ITEM); warp "prontera",156,191; end; Quote Link to comment Share on other sites More sharing options...
Skorm Posted May 20, 2014 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 May 20, 2014 Assuming the NPC is located on the same map as all the players in the event. Quote Link to comment Share on other sites More sharing options...
mrpatrick Posted May 20, 2014 Group: Members Topic Count: 7 Topics Per Day: 0.00 Content Count: 28 Reputation: 2 Joined: 03/22/12 Last Seen: October 13, 2016 Author Share Posted May 20, 2014 OnTimer600000: Announce "The event has ended!",0; addrid(1); delitem ID_ITEM,countitem(ID_ITEM); warp "prontera",156,191; end; Thank you so much I didn't expect that I will just add it there. Assuming the NPC is located on the same map as all the players in the event. What if the NPC is in a different map? Here is how my even works: When the event starts, there's a certain waiting time to gather participants and warp them to a different map. After that, the NPC will no longer accept participants. And when the event ends, they will be automatically warped out without the need to talk to any npc. Another thing: I am planning to add a script to check for a specific item in their inventory everytime my players login and delete that item if it is available in their inventory. My concern with this is that, will it slow down my server since the script automatically runs every time someone logins? Im really sorry for the noob question. Just wanna make sure it wont hurt my server. Quote Link to comment Share on other sites More sharing options...
Skorm Posted May 20, 2014 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 May 20, 2014 What if the NPC is in a different map? Here is how my even works: When the event starts, there's a certain waiting time to gather participants and warp them to a different map. After that, the NPC will no longer accept participants. And when the event ends, they will be automatically warped out without the need to talk to any npc. Another thing: I am planning to add a script to check for a specific item in their inventory everytime my players login and delete that item if it is available in their inventory. My concern with this is that, will it slow down my server since the script automatically runs every time someone logins? Im really sorry for the noob question. Just wanna make sure it wont hurt my server. The suggested code won't work unless the npc is located on the same map or the players are attached to the script... What I would do in this situation is create a static invisible dummy npc which resides on the map and have him keep the timer. In my experience that is the least resource intensive and the least likely to fail. So basically when your entrance npc starts the event trigger a label (donpcevent() which starts a timer in the dummy npc that will eventually trigger the above script. It's ok to use commands like OnPCLogout & OnPCLogin when they are used in moderation... But if you're just trying to wipe your server of that specific item the best way is though SQL. For example: DELETE FROM `Inventory` WHERE `nameid` = <itemid>; Quote Link to comment Share on other sites More sharing options...
mrpatrick Posted May 20, 2014 Group: Members Topic Count: 7 Topics Per Day: 0.00 Content Count: 28 Reputation: 2 Joined: 03/22/12 Last Seen: October 13, 2016 Author Share Posted May 20, 2014 (edited) Thankyou What if the NPC is in a different map?Here is how my even works: When the event starts, there's a certain waiting time to gather participants and warp them to a different map. After that, the NPC will no longer accept participants. And when the event ends, they will be automatically warped out without the need to talk to any npc.Another thing: I am planning to add a script to check for a specific item in their inventory everytime my players login and delete that item if it is available in their inventory.My concern with this is that, will it slow down my server since the script automatically runs every time someone logins?Im really sorry for the noob question. Just wanna make sure it wont hurt my server. The suggested code won't work unless the npc is located on the same map or the players are attached to the script... What I would do in this situation is create a static invisible dummy npc which resides on the map and have him keep the timer. In my experience that is the least resource intensive and the least likely to fail. So basically when your entrance npc starts the event trigger a label (donpcevent() which starts a timer in the dummy npc that will eventually trigger the above script.It's ok to use commands like OnPCLogout & OnPCLogin when they are used in moderation... But if you're just trying to wipe your server of that specific item the best way is though SQL. For example: DELETE FROM `Inventory` WHERE `nameid` = <itemid>; Thankyou so much skorm!So the NPC in prontera will now just be a warper NPC, and when the waiting time has ended, it will no longer accept players (or it will be disabled) then it will activate the NPC which will hold the timer and the whole script?so is this what I should do on my script?this is just an example: OnInit: disablenpc "script NPC"; end; OnClock0000: announce "The event has started!",bc_all,0xFF4500; enablenpc "warper in prontera" sleep2 30000; announce "Time's up! The warper will no longer accept participants!",bc_all,0xFF4500; disablenpc "event Warper"; donpcevent "script NPC::EventStart"; end; please correct me if I'm wrong. Thank you! EDIT: or would it be fine if I make an NPC that will do this SQL command that you given every let's say 12 midnight instead of using OnPCLogout & OnPClogin? Edited May 20, 2014 by mrpatrick Quote Link to comment Share on other sites More sharing options...
Skorm Posted May 20, 2014 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 May 20, 2014 OnInit: disablenpc "script NPC"; end; OnClock0000: announce "The event has started!",bc_all,0xFF4500; enablenpc "warper in prontera" sleep2 30000; announce "Time's up! The warper will no longer accept participants!",bc_all,0xFF4500; disablenpc "event Warper"; donpcevent "script NPC::EventStart"; end; please correct me if I'm wrong. Thank you! EDIT: or would it be fine if I make an NPC that will do this SQL command that you given every let's say 12 midnight instead of using OnPCLogout & OnPClogin? Firstly, you don't want to do disablenpc "<script_npc>"; that would unload the npc altogether instead make the npc header like... event_map,0,0,0 script script_npc 139,{ L_EventStart: initnpctimer; end; OnTimer600000: announce "The event has ended!",bc_all,0xFF4500; addrid(1); delitem <item_id>, countitem(<item_id>); warp "prontera",156,191; end; } Secondly, you wouldn't want to use sleep2 because no players are attached so it doesn't matter if we keep them. OnClock0000: announce "The event has started!",bc_all,0xFF4500; enablenpc "<event_warper>"; sleep 30000; announce "Time's up! The warper will no longer accept participants!",bc_all,0xFF4500; disablenpc "<event_warper>"; donpcevent "script_npc::L_EventStart"; end; Lastly, yes and no.. For the players that are currently logged into your server you want to remove the item from inside the server because SQL doesn't update to the player until they relog. OnClock0000: donpcevent "script_npc::L_Coroutine"; addrid(0); if(set(.@i,countitem(<item_id>))) delitem <item_id>, .@i; end; L_Coroutine: sleep 100; query_sql("DELETE FROM `inventory` WHERE `nameid` = <itemid>;"); Just remember to include the other databases that could contain items like storage and cart. But overall you understood what I meant quite well. Quote Link to comment Share on other sites More sharing options...
mrpatrick Posted May 21, 2014 Group: Members Topic Count: 7 Topics Per Day: 0.00 Content Count: 28 Reputation: 2 Joined: 03/22/12 Last Seen: October 13, 2016 Author Share Posted May 21, 2014 Firstly, you don't want to do disablenpc "<script_npc>"; that would unload the npc altogether instead make the npc header like... event_map,0,0,0 script script_npc 139,{ L_EventStart: initnpctimer; end; OnTimer600000: announce "The event has ended!",bc_all,0xFF4500; addrid(1); delitem <item_id>, countitem(<item_id>); warp "prontera",156,191; end; } Secondly, you wouldn't want to use sleep2 because no players are attached so it doesn't matter if we keep them. OnClock0000: announce "The event has started!",bc_all,0xFF4500; enablenpc "<event_warper>"; sleep 30000; announce "Time's up! The warper will no longer accept participants!",bc_all,0xFF4500; disablenpc "<event_warper>"; donpcevent "script_npc::L_EventStart"; end; Lastly, yes and no.. For the players that are currently logged into your server you want to remove the item from inside the server because SQL doesn't update to the player until they relog. OnClock0000: donpcevent "script_npc::L_Coroutine"; addrid(0); if(set(.@i,countitem(<item_id>))) delitem <item_id>, .@i; end; L_Coroutine: sleep 100; query_sql("DELETE FROM `inventory` WHERE `nameid` = <itemid>;"); Just remember to include the other databases that could contain items like storage and cart. But overall you understood what I meant quite well. Thank you so much skorm! I learned more that what I am asking. This is my first attempt to make a script. I hope it will end up good. I'll return the favor someday! Quote Link to comment Share on other sites More sharing options...
Question
mrpatrick
Hello, does anyone here knows how to make a script that deletes a specific item from all players in a certain map?
I need my players to have a specific item to be deleted in their inventory when my event is finished.
I know that the command for the script is delitem but I don't know how to apply it to all player in a specific map.
Thanks in advance!
Link to comment
Share on other sites
9 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.