print and \n
#1

I was just wondering why every time I use print, SA:MP automatically assumes I want to make a new line. Shouldn't new lines be determined only by using \n?

Say I want to do something like:

print("loading something");
* one second passes
print(".");
* one second passes
print(".");
* one second passes
print(".");
* task finishes
print("done (x amount loaded, in x amount time)");

so in the end it would look like this:

Код:
loading something...done (x amount loaded, in x amount time)
but if I were to do this is it would look like:

Код:
loading something
.
.
.
done (x amount loaded, in x amount time)
Reply
#2

Thats normal, you could format strings though and send them using printf once everything is loaded
Reply
#3

The problem with that is it will look like the script is frozen.
Reply
#4

It's possible to do a new print function in a plugin, using the c printf function, which doesn't happend a newline character to the string. Smething like that should work:

Код:
static cell AMX_NATIVE_CALL n_print2(AMX *a, cell *p)
{
  const char *s;
  amx_StrParam(a, p[1], s);
  printf(s);
  return true;
}
Problem: this basic code will not write into the server_log.txt, it is fixable but 'illegal'..
Reply
#5

I was thinking/hoping it could be done through a plugin. I myself have no clue where to start with making a plugin, but I found the tutorial.

As for it printing into the log, I don't really care since I would be using it for making a visual representation of loading things as explained in my first post.

I'll try compiling that code you posted. It will be a good learning experience I guess.

Thanks a bunch.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)