Hadeszeus
New member
if the player step down on warps.. the warp checks the item if the user has required item he will enter the warp automatically else message "You need this item to enter on this map"..
prontera,150,150,0 script testwarp WARPNPC,1,1,{OnTouch: mes "[Test Warp]"; mes "Hello "+strcharinfo(0)+"!"; mes "You need this item to enter on this map."; mes "Do you have it?"; if(select("No:Yes") == 1) { close; } else { if(!countitem(501)) { //<- item required = Apple next; mes "[Test Warp]"; mes "Where is it?"; close; } close2; warp "izlude",0,0; end; }}
OnPCLoadMapEvent: set @id, ITEMID; set @quantity, QUANTITY; if( strcharinfo(3) == MAPNAME ) { if( countitem(@id) >= @quantity ) end; mes "[Warp master]"; mes "You don't have the required item to enter this map!"; mes "Get "+@quantity+" "+getitemname(@id)+""+((@quantity > 1)?"s.":"."); close2; warp "prontera",150,150; } end;
Why would it be? OnPCLoadMapEvent doesn't run until the player is already on the map. Your example would leave the player on the map itself after simply prompting them that they needed to have something to be there; then with that close, they'd walk happily off, confused as to why they were even told such a thing.It's better to use the mapflag loadevent.
prontera,150,150,0 script testwarp WARPNPC,1,1,{ /*----------------------------------------------------- Configuration -----------------------------------------------------*/ OnInit: .item_id = Jellopy; .item_amount = 1; .warp_map$ = "prontera"; .warp_x = 155; .warp_y = 179; end; /*----------------------------------------------------- Script -----------------------------------------------------*/ OnTouch: if (countitem(.item_id) < .item_amount) { message strcharinfo(0), "You need "+ .item_amount +" "+ getitemname(.item_id) +" to access this warp."; } else { delitem .item_id, .item_amount; warp .warp_map$, .warp_x, .warp_y; } end;}
Ops, sorry, my mistake. It would be possible to use a warp afterwards, having to replace every warp that goes to a map would be a pain, and also every warp npc would have to mimic that invisible line that all warps have that triggers them.Why would it be? OnPCLoadMapEvent doesn't run until the player is already on the map. Your example would leave the player on the map itself after simply prompting them that they needed to have something to be there; then with that close, they'd walk happily off, confused as to why they were even told such a thing.
Mhalicot's approach was on the right track, but I believe the topic starter would something more seamless. Here's my method:
prontera,150,150,0 script testwarp WARPNPC,1,1,{ /*----------------------------------------------------- Configuration -----------------------------------------------------*/ OnInit: .item_id = Jellopy; .item_amount = 1; .warp_map$ = "prontera"; .warp_x = 155; .warp_y = 179; end; /*----------------------------------------------------- Script -----------------------------------------------------*/ OnTouch: if (countitem(.item_id) < .item_amount) { message strcharinfo(0), "You need "+ .item_amount +" "+ getitemname(.item_id) +" to access this warp."; } else { delitem .item_id, .item_amount; warp .warp_map$, .warp_x, .warp_y; } end;}
Yeah, but OnPCLoadMapEvent runs through all maps that have a loadevent mapflag, which can cause high stress on the server when several players load those maps continuously. Understandably, there are some scenarios where a map isn't accessed by warp portal and OnPCLoadMapEvent would be appropriate; however, in this case the topic starter simply wanted a portal for quest-like purposes (and likely seamless integration). Sure, you'd have to disable existing warps that you would replace this "quest warp" with, but it would make sense that this tedium would be found in sensible applications, such as blocking off all warp-portal entrances into Morroc or something - and even so, this can be done by using duplicate to copy your script over without actually having to add another file/script.Ops, sorry, my mistake. It would be possible to use a warp afterwards, having to replace every warp that goes to a map would be a pain, and also every warp npc would have to mimic that invisible line that all warps have that triggers them.
I see. Oh, and I think that after the header you should put an 'end;', if the script stays this way every time someone clicks the warp it will execute everything that's under OnInit's scope, that's unnecessary overhead. Thank you for your answer.Yeah, but OnPCLoadMapEvent runs through all maps that have a loadevent mapflag, which can cause high stress on the server when several players load those maps continuously. Understandably, there are some scenarios where a map isn't accessed by warp portal and OnPCLoadMapEvent would be appropriate; however, in this case the topic starter simply wanted a portal for quest-like purposes (and likely seamless integration). Sure, you'd have to disable existing warps that you would replace this "quest warp" with, but it would make sense that this tedium would be found in sensible applications, such as blocking off all warp-portal entrances into Morroc or something - and even so, this can be done by using duplicate to copy your script over without actually having to add another file/script.
I typically wouldn't place OnInit overhead, but due to the behaviour of the WARPNPC sprite, its script won't be run when clicked upon. Add this line above the OnInit label and see for yourself:I see. Oh, and I think that after the header you should put an 'end;', if the script stays this way every time someone clicks the warp it will execute everything that's under OnInit's scope, that's unnecessary overhead. Thank you for your answer.
Just tested, indeed WARPNPC has this behavior.I typically wouldn't place OnInit overhead, but due to the behaviour of the WARPNPC sprite, its script won't be run when clicked upon. Add this line above the OnInit label and see for yourself:
message strcharinfo(0), "You touched me!"; However, I do concede that it would be good habit to throw an end up there in any similar situation.
The more you know. Brought up some good points though. d:Just tested, indeed WARPNPC has this behavior.
+1 to this. Thank you it's working. BTW How to check/add more item in .item_id for example atleast 3 or more items..Why would it be? OnPCLoadMapEvent doesn't run until the player is already on the map. Your example would leave the player on the map itself after simply prompting them that they needed to have something to be there; then with that close, they'd walk happily off, confused as to why they were even told such a thing.It's better to use the mapflag loadevent.
Mhalicot's approach was on the right track, but I believe the topic starter would something more seamless. Here's my method:
prontera,150,150,0 script testwarp WARPNPC,1,1,{ /*----------------------------------------------------- Configuration -----------------------------------------------------*/ OnInit: .item_id = Jellopy; .item_amount = 1; .warp_map$ = "prontera"; .warp_x = 155; .warp_y = 179; end; /*----------------------------------------------------- Script -----------------------------------------------------*/ OnTouch: if (countitem(.item_id) < .item_amount) { message strcharinfo(0), "You need "+ .item_amount +" "+ getitemname(.item_id) +" to access this warp."; } else { delitem .item_id, .item_amount; warp .warp_map$, .warp_x, .warp_y; } end;}
Here's a version that supports multiple items:+1 to this. Thank you it's working. BTW How to check/add more item in .item_id for example atleast 3 or more items..
I tried adding comma but it's not working.
prontera,150,150,0 script testwarp WARPNPC,1,1,{ message strcharinfo(0), "You touched me!"; /*----------------------------------------------------- Configuration -----------------------------------------------------*/ OnInit: // Item constant/ID, amount setarray .item_id[0], Jellopy, 1, Clover, 5, Fluff, 10; // Warp destination .warp_map$ = "prontera"; .warp_x = 155; .warp_y = 179; end; /*----------------------------------------------------- Script -----------------------------------------------------*/ OnTouch: // Check items for (.@i = 0; .@i < getarraysize(.item_id); .@i += 2) { if (countitem(.item_id[.@i]) < .item_id[.@i + 1]) { message strcharinfo(0), "You need the following items to access this warp:"; for (.@j = 0; .@j < getarraysize(.item_id); .@j += 2) { message strcharinfo(0), .item_id[.@j + 1] +" "+ getitemname(.item_id[.@j]); } message strcharinfo(0), "Access denied."; end; } } // Delete items for (.@i = 0; .@i < getarraysize(.item_id); .@i += 2) { delitem .item_id[.@i], .item_id[.@i + 1]; } // Warp player warp .warp_map$, .warp_x, .warp_y; end;}
We use essential cookies to make this site work, and optional cookies to enhance your experience.