MP at 0 when players spawn in?

MysticalMist

Well-known member
My main goal is to have the player's MP start at 0 when they spawn in instead of being full right away.

So far, all I've done was create a small script that looks like this:

void main(){

void self = getlocalvar("self");
changeentityproperty(self, "mp", 0);
}

From there, I made that an onspawn script. It seems to work initially, but if the player dies, the MP fills up on the next life. Any pointers or advice?
 
You can set the animation script in anim respawn after the player dies. Take note: using void main() is used for non animation scripts such as onspawnscript, ondrawscript, keyscript, etc. You don't need void main for animation scripts at all. You can call on anim respawn if you want to set the mp to 0. There are 2 ways you can do this:

1. You can use a one line @cmd command (is it inline script? I'm not sure) to call a function like this.

Code:
anim respawn
Delay 2
Offset 32 67
@cmd changeentityproperty getlocalvar("self") "mp" 0
Frame data/chars/sonic/idle01.png

In the end you don't need to use onspawnscript for it.

2. You can use onspawnscript and call anim respawn if you wanna change it.

Code:
void main()
{
   void self = getlocalvar("self");
   void aniID = getentityproperty("animationid");

   if(aniID == openborconstant("ANI_RESPAWN"))
   {
      changeentityproperty (self, "mp", 0);
   }
}

I advise you need anim respawn for this, so there's no need to use a one line script.

You can call anim spawn the same way with anim respawn (I guess). Maybe with OR function like this.

Code:
if(aniID == openborconstant("ANI_RESPAWN") || aniID == openborconstant("ANI_SPAWN"))
 
You can set the animation script in anim respawn after the player dies. Take note: using void main() is used for non animation scripts such as onspawnscript, ondrawscript, keyscript, etc. You don't need void main for animation scripts at all. You can call on anim respawn if you want to set the mp to 0. There are 2 ways you can do this:

Thanks for your feedback!

However, I tried both methods and they don't seem to work yet.

When I used @cmd approach, it only worked when the player first spawns. They still seemed to regain their mp after they respawn. I tried using the revised spawn script you provided as well but I was met with a crash. The log said this:

Code:
"Script function 'getentityproperty' returned an exception, check the manual for details.

 parameters: "animationid","


I made sure to use this as an onspawnscript code and I included a respawn animation as well, but I'm not sure how I got an error honestly after looking back at the code.
 
@AlphaBirb

The methods described above are good. The only thing I will suggest is to apply the code in other places.
For example, in SORX the mp is changed in the following events:

- level.c (for all players, when any level starts)
- join1.c, join2.c, join3.c, join4.c (when any player joins in a game already in progress)
- respawn1.c, respawn2.c, respawn3.c, respawn4.c (when a player dies and respawn during the game)

This way I can guarantee that the mp will always be changed according to extra menu options.
 
I think you want to spawn, join players, and respawn from death. If the MP is 0, the best effect is to add "anim spawn". If you don't want to, "anim respawn" or depending on your needs
You can refer to Kratus
 
Back
Top Bottom