Advertisement
Guest User

Untitled

a guest
May 12th, 2013
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 3.13 KB | None | 0 0
  1. public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
  2. {
  3.      /*
  4.     If Player is holding gun && pressing fire button && some time since the last report passed
  5.     {
  6.         GunReport(playerid);
  7.     }
  8.     */
  9.     return 1;
  10. }
  11.  
  12. new AREA_ARRAY [23][5] = //[Nr of Areas][X1, Y1, X2, Y2, AreaLevel]
  13. {
  14.     { 114, 1400, 206, 1527, 4 },
  15.     { 152, 1400, 333, 1117, 4 },
  16.     { 206, 1117, 508, 1064, 4 },
  17.     { 332, 1247, 488, 1117, 4 },
  18.     { 508, 1117, 736, 984, 4 },
  19.     { 736, 1018, 762, 984, 4 },
  20.     { 627, 984, 762, 895, 4 },
  21.     { 762, 936, 896, 724, 4 },
  22.     { 724, 724, 896, 601, 4 },
  23.     { 896, 895, 1037, 601, 4 },
  24.     { 1037, 882, 1152, 601, 4 },
  25.     { 1152, 960, 1355, 725, 4 },
  26.     { 1272, 725, 1590, 545, 4 },
  27.     { 1450, 895, 1590, 725, 4 },
  28.     { 1395, 945, 1450, 852, 4 },
  29.     { 1450, 945, 1537, 895, 4 },
  30.     { 1537, 922, 1565, 895, 4 },
  31.     { 1036, 1582, 1214, 1401, 4 },
  32.     { 1068, 1401, 1292, 1286, 4 },
  33.     { 562, 1327, 644, 1225, 4 },
  34.     { 1392, 1843, 1590, 1738, 4 },
  35.     { 1427, 1738, 1590, 1591, 4 },
  36.     { 1550, 2401, 1848, 2180, 4 }
  37. };
  38.  
  39. public GunReport(playerid)
  40. {
  41.     new arealevel = GetPVarInt(playerid, "Area_Level");
  42.     new randomNr = random(100);
  43.     if ( arealevel == 4 )
  44.     {
  45.         if ( (randomNr+90) >= 100)
  46.         {
  47.             //Send Report
  48.         }
  49.     }
  50.     if ( arealevel == 3 )
  51.     {
  52.         if ( (randomNr+50) >= 100)
  53.         {
  54.             //Send Report
  55.         }
  56.     }
  57.     if ( arealevel == 2 )
  58.     {
  59.         if ( (randomNr+20) >= 100)
  60.         {
  61.             //Send Report
  62.         }
  63.     }
  64.     if ( arealevel == 1 )
  65.     {
  66.         if ( (randomNr+5) >= 100)
  67.         {
  68.             //Send Report
  69.         }
  70.     }
  71.    
  72. }
  73.  
  74. public AreaCheck(playerid)
  75. {
  76.     new Float:PX, Float:PY, Float:PZ;
  77.     for(new i=0; i < MAX_PLAYERS; i++)
  78.     {
  79.         new highestlevel=0;
  80.         GetPlayerPos(i, PX, PY, PZ);
  81.         for ( new index = 0; index < sizeof AREA_ARRAY; index++ )
  82.         {
  83.             new Float:x1=AREA_ARRAY [index][0],
  84.                 Float:y1=AREA_ARRAY [index][1],
  85.                 Float:x2=AREA_ARRAY [index][2],
  86.                 Float:y2=AREA_ARRAY [index][3];
  87.             new arealevel = AREA_ARRAY [index][4];
  88.             if (x1 < x2)
  89.             {
  90.                 if (y1 < y2)
  91.                 {
  92.                     if( (PX > x1) && (PX < x2) && (PY > y1) && (PY < y2) )
  93.                     {
  94.                         if (highestlevel < arealevel)
  95.                         {
  96.                             highestlevel = arealevel;
  97.                         }
  98.                     }
  99.                 }
  100.                 if (y2 < y1)
  101.                 {
  102.                     if( (PX > x1) && (PX < x2) && (PY < y1) && (PY > y2) )
  103.                     {
  104.                         if (highestlevel < arealevel)
  105.                         {
  106.                             highestlevel = arealevel;
  107.                         }
  108.                     }
  109.                 }
  110.             }
  111.             if (x2 < x1)
  112.             {
  113.                 if (y1 < y2)
  114.                 {
  115.                     if( (PX < x1) && (PX > x2) && (PY > y1) && (PY > y2) )
  116.                     {
  117.                         if (highestlevel < arealevel)
  118.                         {
  119.                             highestlevel = arealevel;
  120.                         }
  121.                     }
  122.                 }
  123.                 if (y2 < y1)
  124.                 {
  125.                     if( (PX < x1) && (PX > x2) && (PY < y1) && (PY < y2) )
  126.                     {
  127.                         if (highestlevel < arealevel)
  128.                         {
  129.                             highestlevel = arealevel;
  130.                         }
  131.                     }
  132.                 }
  133.             }
  134.         }
  135.         SetAreaLevel(playerid, highestlevel);
  136.     }
  137. }
  138.  
  139. public SetAreaLevel(playerid, alvl)
  140. {
  141.     new currentlevel = GetPVarInt(playerid, "Area_Level");
  142.     if ( currentlevel < alvl )
  143.     {
  144.         SetPVarInt(playerid, "Area_Level", alvl);
  145.     }
  146.     if ( currentlevel > alvl )
  147.     {
  148.         SetPVarInt(playerid, "Area_Level", alvl);
  149.     }
  150. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement