Jump to content
  • 0

OnPCLoadMapEvent


Kurihara

Question


  • Group:  Members
  • Topic Count:  6
  • Topics Per Day:  0.00
  • Content Count:  17
  • Reputation:   0
  • Joined:  06/19/13
  • Last Seen:  

I was looking for a script that can shove my staff from specified maps and failed to find one, so I attempted to create my own. I thought it was a success because it shoves my staff from these maps but it turns out it shoves them from ALL the maps.

Can someone help me with this please! Thank you so much in advance

-	script	AutoKick	-1,{
OnPCLoadMapEvent:
	if( getgmlevel() <= 80 ) atcommand "@shove "+strcharinfo(0);
	end;
}

abbey02    mapflag    loadevent
ra_san05    mapflag    loadevent
thor_v03    mapflag    loadevent
lhz_dun01    mapflag    loadevent
lhz_dun02    mapflag    loadevent
lhz_dun03    mapflag    loadevent
payg_cas04    mapflag    loadevent
abbey03    mapflag    loadevent
thana_boss    mapflag    loadevent
Link to comment
Share on other sites

7 answers to this question

Recommended Posts


  • Group:  Members
  • Topic Count:  72
  • Topics Per Day:  0.02
  • Content Count:  2997
  • Reputation:   1130
  • Joined:  05/27/12
  • Last Seen:  

First off, you've written your condition as "getgmlevel() <= 80", which would include normal players as well. Not sure if that's what you intended...

If OnPCLoadMapEvent triggers on a map, 'mf_loadevent' must have been set on that map (you can type @mapinfo to confirm this). You might have another mapflag script running (security scripts often do this); if you remove all the 'mapflag' lines from this script, for instance, does the label still get triggered?

A workaround is to run a map name check on the label, although you should really see if you can resolve the larger issue first.

if (!compare("abbey02|ra_san05|thor_v03|lhz_dun01|lhz_dun02|lhz_dun03|payg_cas04|abbey03|thana_boss", strcharinfo(3)) end;
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  7
  • Topics Per Day:  0.00
  • Content Count:  135
  • Reputation:   41
  • Joined:  02/05/14
  • Last Seen:  

You could also bind a script to @warp to prevent specific groups from accessing maps you want blacklisted. Here's an example:

-	script	at_warp	-1,{

	OnInit:
		// Define map blacklist
		setarray .blacklist[0], "abbey02", "ra_san05", "thor_v03", "lhz_dun01", "lhz_dun02", "lhz_dun03", "payg_cas04", "abbey03", "thana_boss";
		
		// Restricted group IDs
		setarray .map_restrict[0], 1, 2, 3;
		
		// Group level command access
		.cmd_access = 40;
		
		// Bind command to script event
		bindatcmd "warp", strnpcinfo(3) +"::OnAtcommand", .cmd_access, .cmd_access;
		end;
		
		
	OnAtcommand:
		// Loop through restricted group IDs
		for (.@i = 0; .@i < getarraysize(.blacklist); .@i++) {
			// Continue if group ID is blacklisted
			if (getgroupid() == .map_restrict[.@i]) { 
				// Loop through blacklist
				for (.@j = 0; .@j < getarraysize(.blacklist); .@j++) {
					// Error if destination is blacklisted
					if (.@atcmd_parameters$[0] == .blacklist[.@j]) {
						message strcharinfo(0), "You are not authorised to warp to this map.";
						end;
					}
				}
			}
		}
		
		// Warp to destination
		warp .@atcmd_parameters$[0], atoi(.@atcmd_parameters$[1]), atoi(.@atcmd_parameters$[2]);
		end;

}

  • Upvote 1
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  6
  • Topics Per Day:  0.00
  • Content Count:  17
  • Reputation:   0
  • Joined:  06/19/13
  • Last Seen:  

First off, you've written your condition as "getgmlevel() <= 80", which would include normal players as well. Not sure if that's what you intended...

If OnPCLoadMapEvent triggers on a map, 'mf_loadevent' must have been set on that map (you can type @mapinfo to confirm this). You might have another mapflag script running (security scripts often do this); if you remove all the 'mapflag' lines from this script, for instance, does the label still get triggered?

A workaround is to run a map name check on the label, although you should really see if you can resolve the larger issue first.

if (!compare("abbey02|ra_san05|thor_v03|lhz_dun01|lhz_dun02|lhz_dun03|payg_cas04|abbey03|thana_boss", strcharinfo(3)) end;

Thank you for pointing that out I definitely did not want to include the regular players. As for your script, I'm kind of a noob in scripting still so where should I insert that part? 

 

 

 

You could also bind a script to @warp to prevent specific groups from accessing maps you want blacklisted. Here's an example:

-	script	at_warp	-1,{

	OnInit:
		// Define map blacklist
		setarray .blacklist[0], "abbey02", "ra_san05", "thor_v03", "lhz_dun01", "lhz_dun02", "lhz_dun03", "payg_cas04", "abbey03", "thana_boss";
		
		// Restricted group IDs
		setarray .map_restrict[0], 1, 2, 3;
		
		// Group level command access
		.cmd_access = 40;
		
		// Bind command to script event
		bindatcmd "warp", strnpcinfo(3) +"::OnAtcommand", .cmd_access, .cmd_access;
		end;
		
		
	OnAtcommand:
		// Loop through restricted group IDs
		for (.@i = 0; .@i < getarraysize(.blacklist); .@i++) {
			// Continue if group ID is blacklisted
			if (getgroupid() == .map_restrict[.@i]) { 
				// Loop through blacklist
				for (.@j = 0; .@j < getarraysize(.blacklist); .@j++) {
					// Error if destination is blacklisted
					if (.@atcmd_parameters$[0] == .blacklist[.@j]) {
						message strcharinfo(0), "You are not authorised to warp to this map.";
						end;
					}
				}
			}
		}
		
		// Warp to destination
		warp .@atcmd_parameters$[0], atoi(.@atcmd_parameters$[1]), atoi(.@atcmd_parameters$[2]);
		end;

}

Thank you so much for this, it looks very complicated haha I hope it works. Btw which gm levels does your script apply to?

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  7
  • Topics Per Day:  0.00
  • Content Count:  135
  • Reputation:   41
  • Joined:  02/05/14
  • Last Seen:  

These are the Group IDs that cannot access blacklisted maps:

		// Restricted group IDs
		setarray .map_restrict[0], 1, 2, 3;

This is the Group Level required to use @warp:

		// Group level command access
		.cmd_access = 40;

See conf/groups.conf for GM levels.

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  6
  • Topics Per Day:  0.00
  • Content Count:  17
  • Reputation:   0
  • Joined:  06/19/13
  • Last Seen:  

This conf/groups.conf isn't in my trunk. I'm using eathena btw sorry that I forgot to mention.

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  7
  • Topics Per Day:  0.00
  • Content Count:  135
  • Reputation:   41
  • Joined:  02/05/14
  • Last Seen:  

This conf/groups.conf isn't in my trunk. I'm using eathena btw sorry that I forgot to mention.

 

Might want to merge over to rAthena soon, then.

 

For eAthena compatibility, change any occurrences of getgroupid() to getgmlevel(), and change any occurrences of .@var = value; to set .@var, value (keep in mind that the italicised text is pseudocode; it is just an example of similar occurrences). Lastly, change these values to the GM levels that you want to restrict from specified maps:

setarray .map_restrict[0], 1, 2, 3;

But really, switch over to rAthena already.

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  6
  • Topics Per Day:  0.00
  • Content Count:  17
  • Reputation:   0
  • Joined:  06/19/13
  • Last Seen:  

Haha I do with what's given to me for my server and it was eAthena. I experienced a big failure on my last server when I tried to update it so I might stick with eAthena for a little while. I'll try this script thank you so much for your help :)

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...