Jump to content
  • 0

Request Script @go restrict on base level


Brahms

Question


  • Group:  Members
  • Topic Count:  48
  • Topics Per Day:  0.02
  • Content Count:  149
  • Reputation:   3
  • Joined:  07/29/16
  • Last Seen:  

Good day guys, may i request for script where in maintown you Can't do @go 0 commands until a certain player reach for example 100 base level.. Thank you in advance guys..

Edited by Akkarin
Changed topic title to something more meaningful
Link to comment
Share on other sites

21 answers to this question

Recommended Posts

  • 0

  • Group:  Forum Manager
  • Topic Count:  282
  • Topics Per Day:  0.06
  • Content Count:  3122
  • Reputation:   1614
  • Joined:  03/26/12
  • Last Seen:  

A quick way to do this without changing any of the source would be to overwrite the @go command using bindatcmd:
 

-	script	atcmd_go	-1,{
OnInit:
	bindatcmd "go",strnpcinfo(3)+"::OnAtcommand";
	end;
OnAtcommand:

	if(!getarraysize(.@atcmd_parameters$)) {
		message strcharinfo(0), "Invalid syntax.";
		end;
	}

	.@location = .@atcmd_parameters$[0];

	if(.@location == 0){
		if(BaseLevel < 100){
			dispbottom "You need to be atleast Base Level 100 to go there!";
		} else {
			atcommand "@go 0";
		}
	} else {
		atcommand "@go "+ .@location;
	}
	end;
}

Tested and works on my localhost, you'd need to edit to add more if/else's if you want to restrict other locations.

  • Upvote 1
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  48
  • Topics Per Day:  0.02
  • Content Count:  149
  • Reputation:   3
  • Joined:  07/29/16
  • Last Seen:  

Thank you so much for this.. ill try it out. thanks again.. :D


@Akkarin;

 

hi again. thank you for the script its 100% working. But i tried to add other commands to restrict the @warp to if your now atleast have a blvl 100.

here's what happen: my @go 0 location is invek 148 162, when i tried to put my edited script that you proivided me, @go 0 & @warp invek actually disabled when your not atleast have a base lvl 100, its working. my problem is some Debug show in my map server console everytime i used @go 0 or @warp invek after i reach base level 100.

 

Can you check this 1 for me? did i missed something? is there something wrong the way i edit it? thank you so much in advance for the help & support..

 

heres my edited script & Screenshot of my map console:

 

Restriction.txt

ss.bmp

Link to comment
Share on other sites

  • 0

  • Group:  Forum Manager
  • Topic Count:  282
  • Topics Per Day:  0.06
  • Content Count:  3122
  • Reputation:   1614
  • Joined:  03/26/12
  • Last Seen:  

Well... you need an elseif in there, and your error is because the script is trying to warp you to a map called "0".

 

Give me 20 mins to get to a PC and i can rewrite it for you and test.

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  48
  • Topics Per Day:  0.02
  • Content Count:  149
  • Reputation:   3
  • Joined:  07/29/16
  • Last Seen:  

Geez, Thank you for the fast response.. Thank you so much :D

Link to comment
Share on other sites

  • 0

  • Group:  Forum Manager
  • Topic Count:  282
  • Topics Per Day:  0.06
  • Content Count:  3122
  • Reputation:   1614
  • Joined:  03/26/12
  • Last Seen:  

-	script	atcmd_go	-1,{
OnInit:
	bindatcmd "go",strnpcinfo(3)+"::OnAtcommand";
	bindatcmd "warp",strnpcinfo(3)+"::OnAtcommand";

	end;
OnAtcommand:

	if(!getarraysize(.@atcmd_parameters$)) {
		message strcharinfo(0), "Invalid syntax.";
		end;
	}
	.@cmd$ = .@atcmd_command$;
	.@location = .@atcmd_parameters$[0];

	switch(.@cmd){
		case "go":
			switch(.@location){
				case 0:
					if(BaseLevel < 100){
						dispbottom "You need to be atleast Base Level 100 to go there!";
					} else {
						atcommand "@go 0";
					}
					break;
				case 1:
					if(BaseLevel < 100){
						dispbottom "You need to be atleast Base Level 100 to go there!";
					} else {
						atcommand "@warp invek";
					}
					break;
				case default:
					atcommand "@go "+ .@location;
					break;
			}
			break;
			
		case "warp":
			switch(.@location){
				case "invek":
					if(BaseLevel < 100){
						dispbottom "You need to be atleast Base Level 100 to go there!";
					} else {
						atcommand "@warp invek";
					}
					break;
				case default:
					atcommand "@warp "+ .@location;
					break;
			}
			break;
	}
	
	end;
}

Currently untested, but this should provide you with a good base to edit without breaking it :P Should be fairly easy to follow so you can add additional locations in the future.

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  48
  • Topics Per Day:  0.02
  • Content Count:  149
  • Reputation:   3
  • Joined:  07/29/16
  • Last Seen:  

Thank you so much for your time. im going to try it.


still having some problem sir Akkarin.. sorry for taking much of your time.

 

heres the ss of my map server console:

 

post-40858-0-79930700-1476538207_thumb.jpg

Link to comment
Share on other sites

  • 0

  • Group:  Forum Manager
  • Topic Count:  282
  • Topics Per Day:  0.06
  • Content Count:  3122
  • Reputation:   1614
  • Joined:  03/26/12
  • Last Seen:  

Bah. Sometimes i forget which language i'm using *_*

 

/me edits.


-	script	atcmd_go	-1,{
OnInit:
	bindatcmd "go",strnpcinfo(3)+"::OnAtcommand";
	bindatcmd "warp",strnpcinfo(3)+"::OnAtcommand";

	end;
OnAtcommand:

	if(!getarraysize(.@atcmd_parameters$)) {
		message strcharinfo(0), "Invalid syntax.";
		end;
	}
	.@cmd$ = .@atcmd_command$;
	.@location$ = .@atcmd_parameters$[0];

	dispbottom .@cmd$ +" used";


	if( .@cmd$ == "@go" ){
		dispbottom "found @go";
		if( .@location$ == "0" ){
			dispbottom "found 0";
			if(BaseLevel < 100){
				dispbottom "You need to be atleast Base Level 100 to go there!";
			} else {
				atcommand "@go 0";
			}
		} else if( .@location$ == "1" ){
			dispbottom "found 1";
			if(BaseLevel < 100){
				dispbottom "You need to be atleast Base Level 100 to go there!";
			} else {
				atcommand "@warp invek";
			}
		} else {
			dispbottom "found something else";
			atcommand "@go "+ .@location$;
		}
	} else if( .@cmd$ == "@warp" ){
		dispbottom "found @warp";
		if( .@location$ == "invek" ){
			dispbottom "found invek";
			if(BaseLevel < 100){
				dispbottom "You need to be atleast Base Level 100 to go there!";
			} else {
				atcommand "@warp invek";
			}
		} else {
			atcommand "@warp "+ .@location$;
		}
	} else {
		dispbottom "Odd.. nothing processed..";
	}
	dispbottom "@ end";

	end;
}

You can do away with all of the dispbottom's everywhere, they're just there for debugging.

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  48
  • Topics Per Day:  0.02
  • Content Count:  149
  • Reputation:   3
  • Joined:  07/29/16
  • Last Seen:  

Yay! it works! Thank you so much!, Thank you for the fast response & Thank you for giving me some knowledge.. :D Thank you.. :D

 

I got another problem, Lol sorry for this..

Here's what happen, the whole @warp is working but the problem is everytime i  do for example, @warp prontera 150,100, it drops me anywhere in prontera. the x,y this is not working. hehehe... same with the other maps. :D 

Edited by Brahms
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  51
  • Topics Per Day:  0.01
  • Content Count:  192
  • Reputation:   9
  • Joined:  05/08/13
  • Last Seen:  

Yay! it works! Thank you so much!, Thank you for the fast response & Thank you for giving me some knowledge.. :D Thank you.. :D

 

I got another problem, Lol sorry for this..

Here's what happen, the whole @warp is working but the problem is everytime i  do for example, @warp prontera 150,100, it drops me anywhere in prontera. the x,y this is not working. hehehe... same with the other maps. :D 

 

Don't forget to mark the best answer. :)

Link to comment
Share on other sites

  • 0

  • Group:  Forum Manager
  • Topic Count:  282
  • Topics Per Day:  0.06
  • Content Count:  3122
  • Reputation:   1614
  • Joined:  03/26/12
  • Last Seen:  

I got another problem, Lol sorry for this..

Here's what happen, the whole @warp is working but the problem is everytime i  do for example, @warp prontera 150,100, it drops me anywhere in prontera. the x,y this is not working. hehehe... same with the other maps. :D 

 

Again, untested:

-	script	atcmd_go	-1,{
OnInit:
	bindatcmd "go",strnpcinfo(3)+"::OnAtcommand";
	bindatcmd "warp",strnpcinfo(3)+"::OnAtcommand";

	end;
OnAtcommand:

	if(!getarraysize(.@atcmd_parameters$)) {
		message strcharinfo(0), "Invalid syntax.";
		end;
	}
	.@cmd$ = .@atcmd_command$;
	.@location$ = .@atcmd_parameters$[0];
	.@x$ = .@atcmd_parameters$[1];
	.@y$ = .@atcmd_parameters$[2];
	dispbottom .@cmd$ +" used";


	if( .@cmd$ == "@go" ){
		dispbottom "found @go";
		if( .@location$ == "0" ){
			dispbottom "found 0";
			if(BaseLevel < 100){
				dispbottom "You need to be atleast Base Level 100 to go there!";
			} else {
				atcommand "@go 0";
			}
		} else if( .@location$ == "1" ){
			dispbottom "found 1";
			if(BaseLevel < 100){
				dispbottom "You need to be atleast Base Level 100 to go there!";
			} else {
				atcommand "@warp invek";
			}
		} else {
			dispbottom "found something else";
			atcommand "@go "+ .@location$;
		}
	} else if( .@cmd$ == "@warp" ){
		dispbottom "found @warp";
		if( .@location$ == "invek" ){
			dispbottom "found invek";
			if(BaseLevel < 100){
				dispbottom "You need to be atleast Base Level 100 to go there!";
			} else {
				atcommand "@warp invek" + .@x$ + " " + .@y$;
			}
		} else {
			atcommand "@warp "+ .@location$ + " " + .@x$ + " " + .@y$;
		}
	} else {
		dispbottom "Odd.. nothing processed..";
	}
	dispbottom "@ end";

	end;
}

Just needed additional parameters adding for the x and y coordinates.

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  48
  • Topics Per Day:  0.02
  • Content Count:  149
  • Reputation:   3
  • Joined:  07/29/16
  • Last Seen:  

im here again. :P another error sir Akkarin..

 

everytime i try to @warp to any town with my base lvl is 100 the screen keep showing "Map not found" & "@warp failed"

 

for my map server console here's the Screenshots..


 

Yay! it works! Thank you so much!, Thank you for the fast response & Thank you for giving me some knowledge.. :D Thank you.. :D

 

I got another problem, Lol sorry for this..

Here's what happen, the whole @warp is working but the problem is everytime i  do for example, @warp prontera 150,100, it drops me anywhere in prontera. the x,y this is not working. hehehe... same with the other maps. :D 

 

Don't forget to mark the best answer. :)

 

 

 

yes i will.. :D mr. Akkarin is working hard for me and im very thankfull for that.. :D

post-40858-0-61464300-1476546799_thumb.jpg

Link to comment
Share on other sites

  • 0

  • Group:  Forum Manager
  • Topic Count:  282
  • Topics Per Day:  0.06
  • Content Count:  3122
  • Reputation:   1614
  • Joined:  03/26/12
  • Last Seen:  

I guess you could add a check to make sure that if .@x$ exists or is not null or is not 0 then echo out that line in the atcommand @warp line..

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  48
  • Topics Per Day:  0.02
  • Content Count:  149
  • Reputation:   3
  • Joined:  07/29/16
  • Last Seen:  

I guess you could add a check to make sure that if .@x$ exists or is not null or is not 0 then echo out that line in the atcommand @warp line..

 

Sorry Akkarin but to be honest i dont know how to do that. Im really sorry. im just a newbie.. /wah

Link to comment
Share on other sites

  • 0

  • Group:  Forum Moderator
  • Topic Count:  93
  • Topics Per Day:  0.02
  • Content Count:  10013
  • Reputation:   2345
  • Joined:  10/28/11
  • Last Seen:  

try this

https://pastebin.com/9dWAt99d

 

Add more maps with level restriction here.

func_SetLevel( "prontera",30 ); // prontera need level 30.
func_SetLevel( "payon",99 ); // payon need level 99.
  • Upvote 1
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  0
  • Topics Per Day:  0
  • Content Count:  92
  • Reputation:   17
  • Joined:  08/11/12
  • Last Seen:  

Wow, nice catch Emistry! +1

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  48
  • Topics Per Day:  0.02
  • Content Count:  149
  • Reputation:   3
  • Joined:  07/29/16
  • Last Seen:  

 

try this

https://pastebin.com/9dWAt99d

 

Add more maps with level restriction here.

func_SetLevel( "prontera",30 ); // prontera need level 30.
func_SetLevel( "payon",99 ); // payon need level 99.

 

Let me try emistry. Thanks!

Hi Emistry i tried to edit the map as you instructed. but it seems im having a problem with the commands.. when i use @go 0 my screen shows map 0 doesnt exist. here's the script i edited and my map server console..

 

i just want to restrict @go 0 & @warp (my maintown) commands if the players have 99 baselevel below only. if the players reach baselevel 100 they can use the command

// https://rathena.org/board/topic/107746-request-script-go-restrict-on-base-level/

- script Sample#at_go_restrict -1,{
function func_SetLevel {
setd( ".map_" + getarg( 0,"" ) ), getarg( 1,1 );
return;
}
OnInit:
bindatcmd( "go", strnpcinfo(3)+"::OnAtcommand" );

func_SetLevel( "invek",100 ); // prontera need level 30.
func_SetLevel( "payon",99 ); // payon need level 99.
end;

OnAtcommand:
if ( !.@atcmd_numparameters ) {
dispbottom .@atcmd_command$+" <mapname> <x> <y>";
}
else if ( getmapusers( .@atcmd_parameters$[0] ) == -1 ) {
dispbottom "map '"+.@atcmd_parameters$[0]+"' doesn't exist.";
}
else if ( !getmapflag( .@atcmd_parameters$[0],mf_town ) || getmapflag( .@atcmd_parameters$[0],mf_nowarpto ) ) {
dispbottom "you cant warp to this map.";
}
else if ( getd( ".map_" + .@atcmd_parameters$[0] ) > BaseLevel ) {
dispbottom "You need higher level to warp to this map.";
}
else {
warp .@atcmd_parameters$[0],atoi( .@atcmd_parameters$[1] ),atoi( .@atcmd_parameters$[2] );
}
end;
}

post-40858-0-89051600-1476563183_thumb.png

Edited by Emistry
Please use CODEBOX.
Link to comment
Share on other sites

  • 0

  • Group:  Forum Moderator
  • Topic Count:  93
  • Topics Per Day:  0.02
  • Content Count:  10013
  • Reputation:   2345
  • Joined:  10/28/11
  • Last Seen:  

try this.

https://pastebin.com/9dWAt99d

Edited by Emistry
fix link
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  48
  • Topics Per Day:  0.02
  • Content Count:  149
  • Reputation:   3
  • Joined:  07/29/16
  • Last Seen:  

A big thanks to all for making an effort about my request. maybe ill just stick to  Akkarin's script for @go restriction only on a certain map. thanks to all the replies and effort.. 

 

-no error cause by this script. but the script @ warp restriction still not working properly. 

em.bmp

Edited by Brahms
Link to comment
Share on other sites

  • 0

  • Group:  Forum Manager
  • Topic Count:  282
  • Topics Per Day:  0.06
  • Content Count:  3122
  • Reputation:   1614
  • Joined:  03/26/12
  • Last Seen:  

The error in your screenshot is not being caused by Emistry's script.

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  48
  • Topics Per Day:  0.02
  • Content Count:  149
  • Reputation:   3
  • Joined:  07/29/16
  • Last Seen:  

yea i solve that already. its not on emistry script. but still the @warp restriction is not working properly. when i use @warp prontera 150 150 it drops me randomly. :P so maybe ill just stick to your @go restriction.. Thank you Akkarin.. and by the way also thanks to emistry for the efforts.

Edited by Brahms
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...