GmOcean Posted August 24, 2014 Group: Members Topic Count: 31 Topics Per Day: 0.01 Content Count: 666 Reputation: 93 Joined: 04/27/12 Last Seen: August 17, 2015 Share Posted August 24, 2014 (edited) Okay, so my problem is that addrid works fine, however, it seems to terminate a scripts function if it fails. Additionally, if combined with an IF statement, it sends an error to the map server, causing the script to fail. ex. if( addrid(4,0,(.x-5),(.y+5),(.x+5),(.y-5)) ){ do this; } else { end; } //This will result in an error. Also, placing it with in a set command also results in a script failure. set .@i, addrid(4,0,1,200,200,1); So, what I'm trying to do can be fully explained with the script. As you can see below it shouldn't be an issue with not having a player attached. prontera,155,170,4 script Campfire 123,{ donpcevent strnpcinfo(3)+"::OnCampfireStart"; end; OnInit: getmapxy(.m$,.x,.y,1,strnpcinfo(3)); set .a,1; end; OnCampfireStart: initnpctimer; freeloop(1); while(.a) { npctalk "Healing"; addrid(4,0,(.x-5),(.y+5),(.x+5),(.y-5)); if( playerattached() ) { dispbottom "You have been attached to script"; if( issitting() ){dispbottom "You were sitting.";} else {dispbottom "You were standing.";} sleep2 10000; getmapxy(.@m$,.@x,.@y,0); if(distance(.@x,.@y,.x,.y) >= 6){detachrid;} } sleep 100; if(.end){freeloop(0); break;} } set .end,0; end; OnFireWoodUse: set .firewood,.firewood+1; end; OnTimer60000: if(.firewood){set .firewood,.firewood-1; setnpctimer 0;} set .end,1; disablenpc strnpcinfo(0); end; } Edited August 30, 2014 by GmOcean Quote Link to comment Share on other sites More sharing options...
AnnieRuru Posted August 25, 2014 Group: Members Topic Count: 18 Topics Per Day: 0.00 Content Count: 2044 Reputation: 682 Joined: 10/09/12 Last Seen: December 20, 2020 Share Posted August 25, 2014 (edited) ( actually I'm still consider as MIA ... hehehe because its rare for you to ask a question so I want to repay your kindness by answering your question ^.^ ) nonono ... you DON'T attach everyone on the server just to loop a player timer you have to remember that addrid runs the script simultaneously equal to the number of player attached to the script if there are 10 players near the fireplace, this script will be running 10 times, after 10 seconds, if there are still 5 players still standing within the 5x5 grid, it will be run 10x5 = 50 times and its quite hard to detachrid because there are no original RID when the script started you can just use OnTouch with sleep, while(!getmapxy) method to solve this particular problem here's the script revised, its far easier like this prontera,155,170,4 script Campfire 723,5,5,{ dispbottom "[Debug] these players was within this fireplace in last 2 seconds"; .@size = getarraysize( .aid ); for ( .@i = 0; .@i < .@size; .@i++ ) if ( isloggedin( .aid[.@i] ) ) dispbottom rid2name( .aid[.@i] ); end; OnTouch: while ( getcharid(3) != .aid[.@i] && .@i < getarraysize(.aid) ) .@i++; if ( .@i < getarraysize(.aid) ) end; .aid[.@i] = getcharid(3); end; OnInit: getmapxy .map$, .x, .y, 1; while (1) { .@size = getarraysize( .aid ); for ( .@i = 0; .@i < .@size; .@i++ ) { if ( isloggedin( .aid[.@i] ) ) { attachrid .aid[.@i]; getmapxy .@map$, .@x, .@y, 0; // dispbottom !strcmp( .@map$, .map$ ) +" "+ distance( .@x, .@y, .x, .y ); if ( !strcmp( .@map$, .map$ ) && distance( .@x, .@y, .x, .y ) <= 5 ) { if ( countitem(604) ) { if ( !.fire ) { setnpcdisplay strnpcinfo(0), strnpcinfo(0), 802; .fire = 1; } delitem 604, 1; break; } } else { deletearray .aid[.@i], 1; .@i--; .@size--; } } else { deletearray .aid[.@i], 1; .@i--; .@size--; } } detachrid; // announce .@i +" "+ .@size +" "+( .@i == .@size )+" "+ .@fire, 0; if ( .@i == .@size && .fire ) { setnpcdisplay strnpcinfo(0), strnpcinfo(0), 723; .fire = 0; } sleep 2000; } end; }so, your title which is -> addrid + looping <- are not existbecause addrid is not a command that is meant to be loop I rather think, addrid shouldn't be using in an event script, its meant for utility scripts only btw ... I always thought that survival script are more like ... it ask you to put in how many firewood, then the fireplace will burn according to how many firewood that you have placed ? Edited August 25, 2014 by AnnieRuru 1 Quote Link to comment Share on other sites More sharing options...
GmOcean Posted August 26, 2014 Group: Members Topic Count: 31 Topics Per Day: 0.01 Content Count: 666 Reputation: 93 Joined: 04/27/12 Last Seen: August 17, 2015 Author Share Posted August 26, 2014 I thought about doing an OnTouch method, but i was concerned about whether or not OnTouch will activate 100% of the time upon the npc warping locations. Since the main method of using a campfire, will be through an item, which summons the NPC to that player's location, but him/her and other players in the immediate area can use it as well. Also, I figured as much, since detachrid with addrid, only removes the LAST person attached. Was hoping there was a way to detach them all, without storing their IDs in a temp variable/array. As for the firewood part, it's mostly intended, that summoning the campfire will give it a 60second use, and then adding firewood will extend its time, not necessarily a requirement. And Lastly, thank you very much for assisting me xD. It's always good to see you pop up from time to time, but I fear even 1 rare appearance, will result in a flooded PM box D:. Best of luck to you, and may the PM box stay empty~ish! lol. Quote Link to comment Share on other sites More sharing options...
AnnieRuru Posted August 29, 2014 Group: Members Topic Count: 18 Topics Per Day: 0.00 Content Count: 2044 Reputation: 682 Joined: 10/09/12 Last Seen: December 20, 2020 Share Posted August 29, 2014 http://rathena.org/board/topic/83625-movenpc/#entry267224 after I read this post I have to say ... you idea is not possible, unless have some source modification just like you said, move npc into another map will cause OnTouch to mulfunction so I try to think outside the box ... summon the fireplace as a monster but a monster doesn't has OnTouch, I can only code its AI via mob_skill_db to just act like moonlight MVP doing, healing 1 player at a time making fireplace as a monster also means it will have HPs, knocking it for 10 times (10hp + plant mode) will make it drop back firewood 100% chance ... like that this is probably the easiest way I can think of the nearest that I can think of, is coding an entire new skill something like santuary ... something like land protector so not only need to mess around with making new skills, also needs to mess around with setcell etc etc even though I have a little bit knowledge about source coding, I also have no idea how to code this skill just my imagination though And Lastly, thank you very much for assisting me xD. It's always good to see you pop up from time to time, but I fear even 1 rare appearance, will result in a flooded PM box D:. Best of luck to you, and may the PM box stay empty~ish! lol.don't worry about this anymore lol look how long I took to reply a topic ... Quote Link to comment Share on other sites More sharing options...
GmOcean Posted August 29, 2014 Group: Members Topic Count: 31 Topics Per Day: 0.01 Content Count: 666 Reputation: 93 Joined: 04/27/12 Last Seen: August 17, 2015 Author Share Posted August 29, 2014 Haha. I see. I figured as much. In the past with eA I had a command that would allow me to make npc duplicates via a script command. But sadly that code is lost. It allowed me to specify the w4, npc name and sprite I'd, while just duplicating an existing npc. So essentially it let me make a new one on the fly without the need to reloadscript, and the best part is they were temporary, so they vanished after a restart. Quote Link to comment Share on other sites More sharing options...
Question
GmOcean
Okay, so my problem is that addrid works fine, however, it seems to terminate a scripts function if it fails.
Additionally, if combined with an IF statement, it sends an error to the map server, causing the script to fail.
ex.
Also, placing it with in a set command also results in a script failure.
So, what I'm trying to do can be fully explained with the script. As you can see below it shouldn't be an issue with not having a player attached.
Edited by GmOceanLink to comment
Share on other sites
4 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.