SA-MP Forums Archive
help with each player - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: help with each player (/showthread.php?tid=451566)



help with each player - dash5487 - 17.07.2013

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;
}



Re : help with each player - lelemaster - 17.07.2013

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