help with each player
#1

when none goverment player in the area it will work fine and losing his health , BUT
the problem is if None Goverment guy in the area and and his health keep losing then if a goverment guy
came in the same area it will stop losing health of that non goverment player

this is ongamemodeinit
SetTimer("PlayerZoneChecker",6000,true);

Код:
forward PlayerZoneChecker();
public PlayerZoneChecker()
{

		new Float:X,Float:Y,Float:Z;
		new Float:pheal;
	     foreach (new i : Player){
	    
		GetPlayerPos(i,X,Y,Z);
		 
		 GetPlayerHealth(i,pheal);
		 
		if ( IsSpawned[i]==1 && !IsPlayerNPC(i) ){
		
	     if (IsPlayerInArea(i,-1701.5393,647.1263,-1571.7961,718.8061)||IsPlayerInArea(i,-1336.4915,705.7386,-1182.2593,823.7599)||
		 IsPlayerInArea(i,-1780.9791,939.1539,-1683.4225,1063.1093)||IsPlayerInArea(i,-1546.4114,260.0058,-1222.0865,521.8784)){
		 
		 if (gTeam[i] == TEAM_COP || gTeam[i] == TEAM_ARMY ||
		  gTeam[i] == TEAM_CIA || gTeam[i] == TEAM_MEDIC) return 1;

  		SetPlayerHealth(i,pheal -15);
			
		GameTextForPlayer(i, "your losing health", 2000, 3);
			}
		  }
		}
return 1;
}
Reply
#2

I guess you only tested it out if the Non-Gouvernment player has an ID above yours.

Your problem is that if there is an CIA agent, cop, army or medic, you automaticly stop the timer.


Код:
if (gTeam[i] == TEAM_COP || gTeam[i] == TEAM_ARMY ||
		  gTeam[i] == TEAM_CIA || gTeam[i] == TEAM_MEDIC) return 1;
This is not what it is meant to be ( what you wanted to have ). You should try this out:

pawn Код:
forward PlayerZoneChecker();
public PlayerZoneChecker()
{

        new Float:X,Float:Y,Float:Z;
        new Float:pheal;
         foreach (new i : Player){
       
        GetPlayerPos(i,X,Y,Z);
         
         GetPlayerHealth(i,pheal);
         
        if ( IsSpawned[i]==1 && !IsPlayerNPC(i) ){
       
         if (IsPlayerInArea(i,-1701.5393,647.1263,-1571.7961,718.8061)||IsPlayerInArea(i,-1336.4915,705.7386,-1182.2593,823.7599)||
         IsPlayerInArea(i,-1780.9791,939.1539,-1683.4225,1063.1093)||IsPlayerInArea(i,-1546.4114,260.0058,-1222.0865,521.8784)){
         
         if (gTeam[i] == TEAM_COP || gTeam[i] == TEAM_ARMY ||
          gTeam[i] == TEAM_CIA || gTeam[i] == TEAM_MEDIC) continue;

        SetPlayerHealth(i,pheal -15);
           
        GameTextForPlayer(i, "your losing health", 2000, 3);
            }
          }
        }
return 1;
}
You are now skipping the loop for that player id and it continues on and on for the other players. With your codes, you were stopping the loop, that's why it wasn't working.

You should have try debugging it before asking.

I hope I helped you. See you
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)