Question regarding getmapxy

Eternity

New member
Messages
123
Points
0
So i would like to ask if how can i make each player is returned to the same exact point they were before playing the match.

OnEventEnd:
   getmapxy(.@m$,.@px,.@py,0);
   warp .@m$,.@px,.@py;
    .off = 0;
    .on = 0;
    for(set .@i, 0; .@i < getarraysize(.option); set .@i,.@i+1)
        removemapflag .map$,.option[.@i];
    end;


Everytime the event is end, the mapserver tells player not attached. maybe? does it requires any SQL?

 
When you want to trigger the warp, you need to use attachrid(AID)

1. When creating event, you need to add every AID to an array which will be looped through at the end to check.

2. When event starts, save coordinates and map values using temporary @ value. E.g. @map$ = "prontera"; @x = 150; @y = 150;

3. When event ends, trigger donpcevent() for the event.

4. Loop through array and attachrid as you go.

Here is an example...cannot confirm it works trying to work through with logic.

prontera,150,150,3    script    Blah_Blah_Me    CLEAR_NPC,{

    @map$ = "amatsu"; @x = 200; @y = 200;
    $@Event_Array[$@Count] = getcharid(CHAR_ID_ACCOUNT);
    $@Count ++;
    mes("I saved your coordinates!");
    close;

OnEnd:
    for (.@i = 0; .@i < getarraysize($@Event_Array); ++.@i)
        if (isloggedin($@Event_Array[.@i]))
        {
            attachrid($@Event_Array[.@i]);
            warp("" + @map$ + "", @x, @y, 0);
            detachrid();
        }
    deletearray($@Event_Array);
    $@Count = 0;
    end;
}

Again, cannot confirm if works, tryna work through logic.

 
Thanks for the idea and base! i appreciate it.

Edited: Does not work.

Also, i want them to be warp on their original position (coordinates) where they play the last matched.
 

e.g
player 1 was in the pay_fild01 123 22

After the EVENT ends, he will warped back to its original position THE "pay_fild01 123 22"

Thank you for helping!

 
Last edited by a moderator:
There is no need to use global variables ($@) or to use attachrid

Code:
	getmapxy(@evt_map$, @evt_x, @evt_y, UNITTYPE_PC); // save the previous position
	warp(.map$, .warp_x, .warp_y); // warp the player to your event
	end;

OnWarpBack:
	warp(@evt_map$, @evt_x, @evt_y);
	end;

OnEventEnd:
	.@count = getunits(BL_PC, .@players, false, .map$);
	for (.@i = 0; .@i < .@count; .@i++) {
		addtimer(rand(500), strnpcinfo(0) + "::OnWarpBack", .@players[.@i]);
	}
	end;


OnInit:
	.map$ = "the-map"; // map of the event
	.warp_x = 50; // the x position to warp the player to
	.warp_y = 50; // the y position to warp the player to
 
Last edited by a moderator:
Back
Top