Jump to content
  • 0

How to detect that a player leaves a map?


eKoh

Question


  • Group:  Members
  • Topic Count:  46
  • Topics Per Day:  0.01
  • Content Count:  206
  • Reputation:   13
  • Joined:  01/07/12
  • Last Seen:  

Is it possible to make that??

Link to comment
Share on other sites

6 answers to this question

Recommended Posts


  • Group:  Members
  • Topic Count:  82
  • Topics Per Day:  0.02
  • Content Count:  846
  • Reputation:   137
  • Joined:  02/26/14
  • Last Seen:  

Is it possible to make that??

		
set .map$, mapname;

		getmapxy(@map$, @xb, @yb, 0 );
		if (@map$ != .map$) {
				dispbottom "You have left "+.map$+".";
				end;
		}

Set the set .map$ higher up in the script to the map that you want to check for

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  46
  • Topics Per Day:  0.01
  • Content Count:  206
  • Reputation:   13
  • Joined:  01/07/12
  • Last Seen:  

Hello man, I am only able to run the script if I use OnPCLoadMapEvent, otherwise it doesn't show.

 

Also the script_command.txt says this:

 

 


OnPCLoadMapEvent:

This special label will trigger once a player steps in a map marked with the
'loadevent' mapflag and attach its RID. The fact that this label requires a
mapflag for it to work is because, otherwise, it'd be server-wide and trigger
every time a player would change maps. Imagine the server load with 1,000 players

(oh the pain...)

 

I don't know what does this mean, will the server go extremely slow?

 

P.S. I have a dought

 

Why use .map$ instead of @map$, what is the difference? one is temporary and another npc variable, but whatt?? I don't understand /wah .

 

Btw, this is the script that I am testing:

prontera    mapflag    loadevent
morocc    mapflag    loadevent
-    script    Test    -1,{
OnPCLoadMapEvent:
set .map$,"prontera";
    getmapxy(@map$, @xb, @yb, 0 );
        if (@map$ != .map$) {
                dispbottom "You have left "+.map$+".";
                mes "Hello "+.map$+".";
                close;
        }
    end;
}
Edited by eKoh
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  82
  • Topics Per Day:  0.02
  • Content Count:  846
  • Reputation:   137
  • Joined:  02/26/14
  • Last Seen:  

Hello man, I am only able to run the script if I use OnPCLoadMapEvent, otherwise it doesn't show.

 

Also the script_command.txt says this:

 

I don't know what does this mean, will the server go extremely slow?

 

P.S. I have a dought

 

Why use .map$ instead of @map$, what is the difference? one is temporary and another npc variable, but whatt?? I don't understand /wah .

.map$ is what is being compared to @map$.

set .map$, mapname;

^Sets .map$ to the map you are checking that they are in


		getmapxy(@map$, @xb, @yb, 0 );
		if (@map$ != .map$) {
				dispbottom "You have left "+.map$+".";
				end;
		}

^Gets their current map which is @map$ and then compares to see if it is different than .map$; If it is, it displays the message.

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  46
  • Topics Per Day:  0.01
  • Content Count:  206
  • Reputation:   13
  • Joined:  01/07/12
  • Last Seen:  

But it doesn't work, I have already setted .map$ to prontera

 

set .map$,"prontera";

 

I leave prontera and I don't get any message...

 

The only way to make it work, was using OnPCLoadMapEvent...

 

That's why my question about the "loadevent" mapflag, if it causes a lot of lag or that, so I can make that mapflag to all the maps in my server.

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  82
  • Topics Per Day:  0.02
  • Content Count:  846
  • Reputation:   137
  • Joined:  02/26/14
  • Last Seen:  

But it doesn't work, I have already setted .map$ to prontera

set .map$,"prontera";

I leave prontera and I don't get any message...

 

The only way to make it work, was using OnPCLoadMapEvent...

 

That's why my question about the "loadevent" mapflag, if it causes a lot of lag or that, so I can make that mapflag to all the maps in my server.

 

 

The only way the map check will work is if you have a script continuously running that checks for mapchange. If you could provide me with the full script I might beable to help you more

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  46
  • Topics Per Day:  0.01
  • Content Count:  206
  • Reputation:   13
  • Joined:  01/07/12
  • Last Seen:  

Well, I have this problem because I am developing a pvp room, it uses @battleignore to make a "safe zone" and toggles to make the "pvp zone", but if the player for some reason leaves (like being ecalled) and he is on the safe zone, he is still having @battleignore on. And well, it is a bug:

 

-    script    pvp_on_try2    -1,{
OnTouch:
    atcommand "@battleignore";
    set @ig,0;
    set @bignore,1;
    end;
}

 

And the OnPCLoadMap:

 

prontera    mapflag    loadevent
morocc    mapflag    loadevent
-    script    Test    -1,{
OnPCLoadMapEvent:
set .map$, "prontera";
        getmapxy(@map$, @xb, @yb, 0 );
        if (@map$ != .map$) {
                dispbottom "You have left "+.map$+".";
                end;
        }
end;
}

 

There could be also another solution instead of detecting if a player leaves a map.

 

Thank you Pneuma, for helping me so much =)!

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...