Solved if or after player joins question.

Question that is answered or resolved.

PS_VITA

Active member
Hi guys, for a partucular stage I want player 1 and 2 to start of with 1 HP and I manged to do that already but whenever I start a 1 player game and the 2nd player joins, by default P2 startup HP is 100.

Are there options available for me to be able to acomplish the joining playerto start with 1 HP for a particular stage?
 
For any player that joins a game in progress, you can use the same script used on this specific level inside the join.c event.
In your case, you will need to create two files named join1.c and join2.c, and then create a script to change the player's health inside it.

1669153230716.png
 
For any player that joins a game in progress, you can use the same script used on this specific level inside the join.c event.
In your case, you will need to create two files named join1.c and join2.c, and then create a script to change the player's health inside it.

View attachment 2415
Hi @Kratus ,


So I created a blank txt file and changed the extension to.c renamed the file to join1.c than placed the join1 file inside the stage3 folder.
inside the join1.c I wrote this script...


void main()
{
void self = getlocalvar ("self");
int HP1 = getentityproperty (self, "health");

if (frame ==0)
{
changeentityproperty (self, "health", HP1-99);
}

And it didn't work.

Do you or anyone else mind giving a hint of what I'm doing wrong?

Thank you.
 
Hi @Kratus ,


So I created a blank txt file and changed the extension to.c renamed the file to join1.c than placed the join1 file inside the stage3 folder.
inside the join1.c I wrote this script...


void main()
{
void self = getlocalvar ("self");
int HP1 = getentityproperty (self, "health");

if (frame ==0)
{
changeentityproperty (self, "health", HP1-99);
}

And it didn't work.

Do you or anyone else mind giving a hint of what I'm doing wrong?

Thank you.
I suppose you pasted it from some inline script, but for this code there's no "frame" requirement.
Try a script like this:

C:
void main()
{

    void player = getplayerproperty(0, "entity"); //USE "0" ON THE "JOIN1.C" FILE AND "1" ON THE "JOIN2.C" FILE
    int newHealth = 1;

    changeentityproperty (player, "health", newHealth );

}
 
In case you want to go for specific levels with player join interaction or whichever you prefer to (or maybe level interaction), check this. You can use onspawnscript or join#.c which Kratus shows you.

 
I suppose you pasted it from some inline script, but for this code there's no "frame" requirement.
Try a script like this:

C:
void main()
{

    void player = getplayerproperty(0, "entity"); //USE "0" ON THE "JOIN1.C" FILE AND "1" ON THE "JOIN2.C" FILE
    int newHealth = 1;

    changeentityproperty (player, "health", newHealth );

}
Awesome script and I'm sure it works but I might be still doing something wrong. Am I supposed to also include a join script for each player. txt file along with the path to stage 3 join1.c ?
 
You don't need to call the the "join.c" scripts, the engine will call them automatically same as any other global events, like the endlevel.c or updated.c
And yes, you need to add a join.c script for every player allowed to join. In case you have 4 players allowed in your mod, you need four "join.c" files, like this:

join1.c
join2.c
join3.c
join4.c

Note that this "join.c" event only works for the player that joins during an in-progress game. You need to maintain the other scripts that work when a level starts too.
 
You don't need to call the the "join.c" scripts, the engine will call them automatically same as any other global events, like the endlevel.c or updated.c
And yes, you need to add a join.c script for every player allowed to join. In case you have 4 players allowed in your mod, you need four "join.c" files, like this:

join1.c
join2.c
join3.c
join4.c

Note that this "join.c" event only works for the player that joins during an in-progress game. You need to maintain the other scripts that work when a level starts too.
Great! thanks @Kratus and @maxman ,
I think I have enough information to make this work and I'm marking my questions as solved. I just need to figure out why is not working on my end and I'm good to go.
 
I just need to figure out why is not working on my end and I'm good to go.
@PS_VITA I put the script in this BOR mod for you to see how it works.

In addition, you need to add the same code inside the respawn.c event too, otherwise every time the player dies and then respawn, the health will go back to the default value.
The respawn follows the same way as the "join" event does (respawn1.c, respawn2.c, etc), already added on the BOR mod file too.
 
@PS_VITA I put the script in this BOR mod for you to see how it works.

In addition, you need to add the same code inside the respawn.c event too, otherwise every time the player dies and then respawn, the health will go back to the default value.
The respawn follows the same way as the "join" event does (respawn1.c, respawn2.c, etc), already added on the BOR mod file too.
OMG! thank you , thank you, I'm already in bed but tomorrow I'm downloading the bor mod you posted and test it out.

Thank you immensely @Kratus
 
@PS_VITA I put the script in this BOR mod for you to see how it works.

In addition, you need to add the same code inside the respawn.c event too, otherwise every time the player dies and then respawn, the health will go back to the default value.
The respawn follows the same way as the "join" event does (respawn1.c, respawn2.c, etc), already added on the BOR mod file too.
Hi @Kratus and @maxman
Thank you for the mod and info I was able to get it working.

what I was doing wrong was not putting the join1.c file inside the scripts folder and adding extra codes lines like "if level==2 && if set ==0" to the join1.c and join2.c files , so that player 1 and player 2 always start of stage 3 with 1 hp only on survival mode.

Thanks once again!
 
Hi @DCurrent , @Kratus , @maxman

I have one last question:

why is it that whenever I add
(In levels.txt)

skipselect
select data/customselect.txt
for set 1

the join1.c and join2.c scripts are rendered obsolete?

what could the conflict be?

Edit: I've included the demo revised that @Kratus provided, where all you guys have to do is delete skipselect and select data/seldd.txt (from levels.txt) to see how the join1.c and join2.c work again.
 

Attachments

Last edited:
@PS_VITA Maybe the script is not working in your mod due to this line:
"if level==2
Once you declare the skipselect command and define a custom select screen file, the engine will add +1 to every command, jumping +2 levels in total.

skipselect //LEVEL 0
select data/levels/custom_select.txt //LEVEL 1
z 180 230
file data/levels/lv1.txt //LEVEL 2

So, you need to add +2 to your level count too, fixing your script to "if(level == 4)" instead. However, to prevent this behaviour I suggest giving a branch name for every level, completely avoiding the level counter and focusing only on the branch string name.

skipselect //LEVEL 0
select data/levels/custom_select.txt //LEVEL 1
branch level_name
z 180 230
file data/levels/lv1.txt //LEVEL 2

Now you can use:

C:
if(openborvariant("current_branch") == "level_name")
{
    do_something();
}

 
Wow! I didn't know that skipselect and select are counted as current levels, Kratus!

I made an empty dummy entity for levels, and gave it a level spawn script, but @Kratus's answer is way better.

Code:
spawn    empty
@script
void main(){
    int P1 = getplayerproperty(0, "entity");

    changeentityproperty(P1, "health", 1);
}
@end_script
coords    0 0
at    0
 
@PS_VITA Maybe the script is not working in your mod due to this line:

Once you declare the skipselect command and define a custom select screen file, the engine will add +1 to every command, jumping +2 levels in total.

skipselect //LEVEL 0
select data/levels/custom_select.txt //LEVEL 1
z 180 230
file data/levels/lv1.txt //LEVEL 2

So, you need to add +2 to your level count too, fixing your script to "if(level == 4)" instead. However, to prevent this behaviour I suggest giving a branch name for every level, completely avoiding the level counter and focusing only on the branch string name.

skipselect //LEVEL 0
select data/levels/custom_select.txt //LEVEL 1
branch level_name
z 180 230
file data/levels/lv1.txt //LEVEL 2

Now you can use:

C:
if(openborvariant("current_branch") == "level_name")
{
    do_something();
}

First of all ,THANK YOU ;_; so much.
I would have never guessed that custom select screens added a +1 towards the stage counts.
Also, you saved me future headaches by recommending me the branch vs set and level script.

I loved the video tutorial, thanks again everything works perfec now.

I wish I could like your post more!

Happy Thanksgiving !
 
Back
Top Bottom