Quick Question.
#7

This should do the job sir

PHP код:
PlayersDistanceZZ(playerid,player1 = -255) {
   if(
player1 == -255) {
     for(new 
0MAX_PLAYERSi++) {
         if(!
IsPlayerConnected(i) || == playerid) continue;
         new 
Float:X1,Float:Y1,Float:Z1;
         
GetPlayerPos(iX1Y1Z1);
         if(
IsPlayerInRangeOfPoint(playerid5.0X1Y1Z1)) {
            return 
i;
         }
     }
     return -
255;
   }
   else {
      new 
Float:X1,Float:Y1,Float:Z1;
      
GetPlayerPos(player1X1Y1Z1);
      if(
IsPlayerInRangeOfPoint(playerid5.0X1Y1Z1)) {
          return 
player1;
      }
      else {
          return -
255;
      }
   }

Usage:
PlayersDistanceZZ(playerid); // check if player is near any player if not returns -255
PlayersDistanceZZ(playerid,player1); // checks if player is near another player if not returns -255

Example:

PHP код:
CMD:rape(playeridparams[])
{
    new 
rapedid;
    if  (!
IsPlayerSpawned(playerid) || PlayerData[playerid][pJailTime] > 0)
        return 
SendErrorMessage(playerid"You Cannot Use This Command Right Now");
    if    (
PlayerData[playerid][pOnDuty])
        return 
SendErrorMessage(playerid"You Cannot Use This Command Whilst On-Duty.");
        
    new 
PDest PlayersDistanceZZ(playerid);
    if(
PDest == -255) {
       if  (
sscanf(params"u"rapedid))
           return 
SendSyntaxMessage(playerid"/rape (playerid / Name).");
           
// the job
           /*
           you now can also to check if player is near player by
           
           if(PlayersDistanceZZ(playerid, trpedid) == -255) return 1;
           */
    
}
    else { 
// if he's near any player
     // the job
    
}
        

Reply


Messages In This Thread
Quick Question. - by Ritzy2K - 03.05.2016, 14:20
Re: Quick Question. - by ReD_HunTeR - 03.05.2016, 14:55
Re: Quick Question. - by Sjn - 03.05.2016, 14:56
Re: Quick Question. - by Ritzy2K - 03.05.2016, 15:00
Re: Quick Question. - by xTURBOx - 03.05.2016, 15:55
Re: Quick Question. - by Ritzy2K - 03.05.2016, 17:01
Re: Quick Question. - by jlalt - 03.05.2016, 19:32
Re: Quick Question. - by Ritzy2K - 03.05.2016, 19:41
Re: Quick Question. - by jlalt - 03.05.2016, 19:52

Forum Jump:


Users browsing this thread: 1 Guest(s)