Jump to content
  • 0

How to add parameter on a custom command ??


Question

Posted

Hi im trying to create a custom command using bindatcmd .. How to make it like @navto <character name> ???? Thankyou in advance !

Quote

-    script    unit_walk    -1,{
OnInit:
bindatcmd("navto","unit_walk::OnNavigate");
end;

OnNavigate:    
        atcommand "@navto " +.@atcmd_parameters$[0];
    if (isloggedin(getcharid(0,.@atcmd_parameters$[0])) != 1) { message strcharinfo(0), "Target player is offline or do not exist."; }
    sleep2 1; 
    unitwalkto getcharid(3),getcharid(3,.@atcmd_parameters$[0]);
}

 

6 answers to this question

Recommended Posts

  • 0
Posted

Well you can get the full command used with something like:

OnNavigate:
	.@cmd$ = implode(.@atcmd_parameters$, " ");

	if (isloggedin(getcharid(3, .@cmd$)) != 1) {
		message strcharinfo(0), "Target player '" + .@cmd$ + "' is offline or do not exist.";
	}

	sleep2 1;
	unitwalkto getcharid(3), getcharid(3, .@cmd$);
	end;

Though, unitwalkto is very limited and will most likely fail in most scenarios.

  • Upvote 1
  • 0
Posted
15 hours ago, BeWan said:

@atcmd_parameters$[0] = @navto 
@atcmd_parameters$[1] = strcharinfo(0)

What if character has more spaces on name ?? first parameter I think only goes in first name like ex: BLOOD ... but the 2nd goes to BATH so thats 1st and 2nd parameter BLOOD BATH ... what if theres a player whos name is like "O O O O O O" ??? 

  • 0
Posted
1 minute ago, Origami said:

What if character has more spaces on name ?? first parameter I think only goes in first name like ex: BLOOD ... but the 2nd goes to BATH so thats 1st and 2nd parameter BLOOD BATH ... what if theres a player whos name is like "O O O O O O" ??? 

make a condition.

if player enter the name correct, convert the name into charid

  • Upvote 1
  • 0
Posted
On 5/27/2021 at 9:51 PM, BeWan said:

make a condition.

if player enter the name correct, convert the name into charid

Okay thankyou sir ! very helpful ! Cheers

 

On 5/27/2021 at 10:40 PM, Tokei said:

Well you can get the full command used with something like:


OnNavigate:
	.@cmd$ = implode(.@atcmd_parameters$, " ");

	if (isloggedin(getcharid(3, .@cmd$)) != 1) {
		message strcharinfo(0), "Target player '" + .@cmd$ + "' is offline or do not exist.";
	}

	sleep2 1;
	unitwalkto getcharid(3), getcharid(3, .@cmd$);
	end;

Though, unitwalkto is very limited and will most likely fail in most scenarios.

omg thankyou so much sir !!!! 

  • 0
Posted
On 5/27/2021 at 9:50 AM, Eross said:

Hi im trying to create a custom command using bindatcmd .. How to make it like @navto <character name> ???? Thankyou in advance !

 

I was trying to get the first argument with `getchar(0)` but it looks this only works inside of functions? 
I'm still trying to understand better this part, but it works nice when I use @atcmd_parameters$[0], thanks!

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.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...