Jump to content
  • 0
bWolfie

Using 'for()', can you repeat text in same line?

Question

I have a script command which fetches a character's name from the .@atcmd_parameters$[] and displays them in a message.

How do I get them to display in one line?

 

Currently I can only get them to display if I print it one line at a time (using message())

 

 

-    script    Print Names    FAKE_NPC,{
    end;

OnCommand:
    // If user inputs no parameters (i.e. character name)
    if (!.@atcmd_numparameters)
    {
        message(strcharinfo(PC_NAME), "Usage: @printname <name of player to print>");
        message(strcharinfo(PC_NAME), "@printname failed.");
        end;
    }

    .@size = getarraysize(.@atcmd_parameters$);
    for (.@i = 0; .@i < .@size; ++.@i)
    {
        .@player$[.@i] = .@atcmd_parameters$[.@i];
        message(strcharinfo(PC_NAME), "" + .@player$[.@i] + "");
    }

    end;

OnInit:
    bindatcmd("printname", "Print Names::OnCommand", 10 ,96 , true);
    end;
    
}

 

If I typed @printname John Smith, it would appear like this:

 

John

Smith

 

However, I would like it to be on the same line.

 

John Smith

 

Thank you for any help.

Share this post


Link to post
Share on other sites

2 answers to this question

Recommended Posts

  • 0

script_commands.txt have a nice example for it

-	script	atcmd_example	FAKE_NPC,{
OnInit:
	bindatcmd("test", strnpcinfo(NPC_NAME_UNIQUE)+"::OnAtcommand");
	end;
OnAtcommand:
	// This command expects a character name (that may contain spaces) as
	// the only parameter.
	.@name$ = "";
	for (.@i = 0; .@i < .@atcmd_numparameters; ++.@i) {
		.@name$ += (.@i > 0 ? " " : "") + .@atcmd_parameters$[.@i];
	}
	dispbottom("The specified name is: '" + .@name$ + "'");
	end;
}

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.