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

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

  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.

Loading...

×
×
  • Create New...

Important Information

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