Solved Change Player entities Name (?)

Question that is answered or resolved.

Crimsondeath

Active member
I'm using a global var to change enemy names for translation purpose on update.c script:
Code:
void main(){
    // Set 0 to English
    // Set 1 to Spanish
    setglobalvar("language", 1);
}

It's working great on enemies using the onspawnscript:

Code:
void main() {
    int idioma = getglobalvar("language");

    if(idioma == 1){
        changeentityproperty(getlocalvar("self"), "name", "Biosoldado_F"); /* The original name was Biosoldier_F */

    }
}

But for changing the name in players entities that method didn't work, so how can i do it? :(
 
Solution
Hi Kratus, sorry the late answer. I got sick like a week x.x, but I'm better now.

I started "language" global variable on update.c.

I have noticed that player name is still in english (Isolde), but this happeds only before player loses a life or quit the game going to the title screen, if players starts a new game from there, the name change to spanish:

I also tried with "alwaysupdate 1", but didn't work, I'm using OpenBOR version 6391.
I tested the exact same script you posted in a BOR mod, it worked fine with the following adjustments:

- Placed the language variable in the updated.c file

1723317162131.png

- The script to change name in the onspawnscript file (called by the player entity at the header)...
But for changing the name in players entities that method didn't work, so how can i do it? :(
I tested your code and works fine in an empty BOR mod through the onspawn event. Maybe the "language" global variable is empty during the player spawn, so I suggest starting this variable in any other event before the select screen.

 
I tested your code and works fine in an empty BOR mod through the onspawn event. Maybe the "language" global variable is empty during the player spawn, so I suggest starting this variable in any other event before the select screen.

Hi Kratus, sorry the late answer. I got sick like a week x.x, but I'm better now.

I started "language" global variable on update.c.

I have noticed that player name is still in english (Isolde), but this happeds only before player loses a life or quit the game going to the title screen, if players starts a new game from there, the name change to spanish:

I also tried with "alwaysupdate 1", but didn't work, I'm using OpenBOR version 6391.
 
Hi Kratus, sorry the late answer. I got sick like a week x.x, but I'm better now.

I started "language" global variable on update.c.

I have noticed that player name is still in english (Isolde), but this happeds only before player loses a life or quit the game going to the title screen, if players starts a new game from there, the name change to spanish:

I also tried with "alwaysupdate 1", but didn't work, I'm using OpenBOR version 6391.
I tested the exact same script you posted in a BOR mod, it worked fine with the following adjustments:

- Placed the language variable in the updated.c file

1723317162131.png

- The script to change name in the onspawnscript file (called by the player entity at the header)

1723317206694.png

1723317272025.png

- And the alwaysupdate is 1

1723317420898.png

Maybe there's other things affecting the language variable, like other scripts. You can check the language value using the drawstring function in the updated.c like this:

Code:
void main(){
    // Set 0 to English
    // Set 1 to Spanish
    setglobalvar("language", 1);
   
    //DRAW THE VARIABLE ON THE SCREEN TO CHECK ITS VALUE
    drawstring(50, 50, 0, "language = "+getglobalvar("language"));
}

Tested in the engine build 6391

 
Solution
I tested the exact same script you posted in a BOR mod, it worked fine with the following adjustments:

- Placed the language variable in the updated.c file

View attachment 8877

- The script to change name in the onspawnscript file (called by the player entity at the header)

View attachment 8878

View attachment 8879

- And the alwaysupdate is 1

View attachment 8880

Maybe there's other things affecting the language variable, like other scripts. You can check the language value using the drawstring function in the updated.c like this:

Code:
void main(){
    // Set 0 to English
    // Set 1 to Spanish
    setglobalvar("language", 1);
  
    //DRAW THE VARIABLE ON THE SCREEN TO CHECK ITS VALUE
    drawstring(50, 50, 0, "language = "+getglobalvar("language"));
}

Tested in the engine build 6391


It worked at last! Thank you @Kratus :D .

I didn't know I can use an "script.txt" file for alwaysupdate 1 (I was using it on Models.txt xddddd) .
 
Back
Top Bottom