maxman
Well-known member
I have a question regarding the way to use for scripting for player index. This one, for example, is that I want to give player index the way @Kratus does in his projects.
I usually made it like this.
	
	
	
		
What I want is different from what I usually do. It's something that goes like this for having the player part as part of the function here.
	
	
	
		
This leads me to my question on the player variable/function I use as a new script. Its result is correct as what I previously made. But is giving the player variable/function with its index like this correct (

				
			I usually made it like this.
		C:
	
	void main(){
    LastoNumber();
}
void LastoNumber()
{
    if(openborvariant("in_level"))
    {
        int P1 = getplayerproperty(0, "entity");
        int P2 = getplayerproperty(1, "entity");
        int P3 = getplayerproperty(2, "entity");
        int P4 = getplayerproperty(3, "entity");
        int P1Life = getplayerproperty(0, "lives");
        int P2Life = getplayerproperty(1, "lives");
        int P3Life = getplayerproperty(2, "lives");
        int P4Life = getplayerproperty(3, "lives");
        int font = 3; //Standard Life Font
        void mStyle = getglobalvar("musicStyle");
        if(mStyle == 0){font = 4;} // Green font
        if(mStyle == 1){font = 6;} // Red font
        if(mStyle == 2){font = 5;} // Blue font
        
        if(P1)
        {
            drawstring(111, 9, font, P1Life-1);
        }
        if(P2)
        {
            drawstring(231, 9, font, P2Life-1);
        }
        if(P3)
        {
            drawstring(351, 9, font, P3Life-1);
        }
        if(P4)
        {
            drawstring(471, 9, font, P4Life-1);
        }
    }
}What I want is different from what I usually do. It's something that goes like this for having the player part as part of the function here.
		C:
	
	void main(){
    lastNumber2(0); // player 1
    lastNumber2(1); // player 2
    lastNumber2(2); // player 3
    lastNumber2(3); // player 4
}
void lastNumber2(int player){
    if(openborvariant("in_level")){
        int ent = getplayerproperty(player, "ent");
        if(ent != NULL()){ // Does this playable entity exist?
            int Life = getplayerproperty(player, "lives");
            int font = 3; //Standard Life Font
            void mStyle = getglobalvar("musicStyle");
            if(mStyle == 0){font = 4;} // Green font
            if(mStyle == 1){font = 6;} // Red font
            if(mStyle == 2){font = 5;} // Blue font
            int xPos = 111;
            int yPos = 9;
            int xAdd = 120;
            int align;
            if(player == 0){
                drawstring(xPos, yPos, font, Life-1);
            }
            if(player == 1){
                drawstring(xPos+xAdd, yPos, font, Life-1);
            }
            if(player == 2){
                drawstring(xPos+xAdd*2, yPos, font, Life-1);
            }
            if(player == 3){
                drawstring(xPos+xAdd*3, yPos, font, Life-1);
            }
        }
    }
}This leads me to my question on the player variable/function I use as a new script. Its result is correct as what I previously made. But is giving the player variable/function with its index like this correct (
(player == 0))? I don't know if it's correct to use this kind since I want the text to be aligned accordingly to each/specific player index based on where it should be located.
 
	 
 
		 
 
		
 
 
		
 
 
		
 
 
		

