All pastes #760505 Raw Edit

03nov - mdietger

public c v1 · immutable
·published 2007-11-04 01:44 UTC
rendered paste body
//// OLD CODE - INEFFICIENT TIMER!//public GatesUpdate(){   for( new i = 0; i < MAX_PLAYERS; i++ )      {        if( IsPlayerConnected(i) )        {         if(gateAirportLVInfo == 0)         {            if((IsPlayerInArea(i, 1715.0, 1695.0,  1617.0, 1597.0)) && (PilotLisence[ i ] == 1))            {               MoveObject(gateAirportLVa, 1703.622681, 1600.933838, 10.0630, 2.5);//Opening gates               MoveObject(gateAirportLVb, 1707.760132, 1614.666260, 10.0630, 2.5);//Opening gates            }            else if((IsPlayerInArea(i, 1715.0, 1695.0,  1617.0, 1597.0)) && (PilotLisence[ i ] == 0))            {               SendClientMessage( i, COLOR_RED, "You cannot enter the airport without a pilot license!" );            }else                   {               MoveObject(gateAirportLVa, 1704.848877, 1605.037842, 10.0630, 2.5);//Closing gates               MoveObject(gateAirportLVb, 1706.433838, 1610.362061, 10.0630, 2.5);//Closing gates            }         }      }   }}//// NEW CODE - MUCH MORE EFFICIENT, BUT STILL CLOSES THE GATE FOR EVERY ONLINE PLAYER NOT NEAR THE AREA!//            public GatesUpdate(){   if(!gateAirportLVInfo)   for(new i; i<MAX_PLAYERS; i++) if(IsPlayerConnected(i)){      if(IsPlayerInArea(i, 1715.0, 1695.0,  1617.0, 1597.0)){         if((PilotLisence[i]==1){            MoveObject(gateAirportLVa, 1703.622681, 1600.933838, 10.0630, 2.5); //Opening gates            MoveObject(gateAirportLVb, 1707.760132, 1614.666260, 10.0630, 2.5); //Opening gates         }else if(PilotLisence[i]==0)            SendClientMessage( i, COLOR_RED, "You cannot enter the airport without a pilot license!");      }else{         MoveObject(gateAirportLVa, 1704.848877, 1605.037842, 10.0630, 2.5); //Closing gates         MoveObject(gateAirportLVb, 1706.433838, 1610.362061, 10.0630, 2.5); //Closing gates      }   }}//// FINAL CODE - EFFICIENT AS IT CAN BE!//public GatesUpdate(){   if(!gateAirportLVInfo){      new flag;      for(new i; i<MAX_PLAYERS; i++)         if(IsPlayerConnected(i) && IsPlayerInArea(i, 1715.0, 1695.0,  1617.0, 1597.0)){            if((PilotLisence[i]==1){               flag = 1;               MoveObject(gateAirportLVa, 1703.622681, 1600.933838, 10.0630, 2.5); //Opening gates               MoveObject(gateAirportLVb, 1707.760132, 1614.666260, 10.0630, 2.5); //Opening gates            }else if(PilotLisence[i]==0){               SendClientMessage( i, COLOR_RED, "You cannot enter the airport without a pilot license!");            }         }      if(!flag)         MoveObject(gateAirportLVa, 1704.848877, 1605.037842, 10.0630, 2.5); //Closing gates         MoveObject(gateAirportLVb, 1706.433838, 1610.362061, 10.0630, 2.5); //Closing gates   }}