Can anyone help me make this script work for 2 players?

machok

Well-known member
*Already found best the solution :giggle:

Canceled, ineffective
I'll try to find a more appropriate solution.

Just like the title, can anyone help me make this script work when there are 2 players?
a simple script, it's just that I'm not good at this

Code:
@script
     int P1 = getplayerproperty(0, "entity");
     void self = getlocalvar("self");
    {
     int z = getentityproperty(P1, "z");
     if(z >= 230)performattack(self,openborconstant("ANI_FOLLOW2"));
     if(z <= 229)performattack(self,openborconstant("ANI_FOLLOW3"));
    }
    @end_script
 
Last edited:
*Already found best the solution :giggle:

Canceled, ineffective
I'll try to find a more appropriate solution.

Just like the title, can anyone help me make this script work when there are 2 players?
a simple script, it's just that I'm not good at this

Code:
@script
     int P1 = getplayerproperty(0, "entity");
     void self = getlocalvar("self");
    {
     int z = getentityproperty(P1, "z");
     if(z >= 230)performattack(self,openborconstant("ANI_FOLLOW2"));
     if(z <= 229)performattack(self,openborconstant("ANI_FOLLOW3"));
    }
    @end_script
@machok

I don't know what you are trying to do exactly, but to work with player 2 you need to add a new line with the player 2 index (or others).
Don't forget to call "entity" with a "void", same as to call "self"

C:
@script
     void P1 = getplayerproperty(0, "entity");
     void P2 = getplayerproperty(1, "entity");
     void P3 = getplayerproperty(2, "entity");
     void P4 = getplayerproperty(3, "entity");
    {
     int z = getentityproperty(P1, "z");
     if(z >= 230)performattack(self,openborconstant("ANI_FOLLOW2"));
     if(z <= 229)performattack(self,openborconstant("ANI_FOLLOW3"));
    }
    @end_script

I suggest using the "playerindex" property to detect the current index automatically, and avoid calling every player "entity".

C:
@script
void self    = getlocalvar("self");
int pIndex    = getentityproperty(self, "playerindex");
int z        = getentityproperty(self , "z");

if(pIndex == 0) //PLAYER 1
{
    if(z >= 230)performattack(self,openborconstant("ANI_FOLLOW2"));
    if(z <= 229)performattack(self,openborconstant("ANI_FOLLOW3"));
}

if(pIndex == 1) //PLAYER 2
{
    if(z >= ???)performattack(self,openborconstant("???"));
    if(z <= ???)performattack(self,openborconstant("???"));
}
@end_script
 
Back
Top Bottom