Advertisement
Guest User

Shoting Range

a guest
Jun 5th, 2011
188
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 4.92 KB | None | 0 0
  1. #include <a_samp>
  2. #include <zcmd>
  3. #define SUCCESS 0x1CD5E3AA
  4. #define FAILURE 0x2D49D2AA
  5. forward Tstart(playerid);
  6. forward TObjectC(playerid);
  7. //------------------------------------------------
  8.  
  9. public OnFilterScriptInit()
  10. {
  11.         print("\filterskripta ucitana- napravio Retardedwolf Preveo Smiljan\n");
  12.         return 1;
  13. }
  14.  
  15. new
  16.     Ttimer;
  17. //------------------------------------------------
  18.  
  19. COMMAND:trening(playerid, params[])
  20. {
  21.     new
  22.         Float:x,
  23.         Float:y,
  24.         Float:z;
  25.     GetPlayerPos(playerid, x, y, z);
  26.     if(IsPlayerInRangeOfPoint(playerid, 10, 801.61639404297, 1670.5484619141, 4.9562497138977))
  27.     {
  28.         if(GetPVarInt(playerid, "training") == 0)
  29.         {
  30.             SendClientMessage(playerid, SUCCESS, "Trening ce poceti za sekundu.");
  31.             SendClientMessage(playerid, SUCCESS, "Ako zelis zavrsiti s treningom");
  32.             SendClientMessage(playerid, SUCCESS, "pisi | /zaustavitrening |");
  33.             PlayerPlaySound(playerid, 1052, x, y, z);
  34.             SetTimerEx("Tstart", 100, false, "d" ,playerid);
  35.             SetPVarInt(playerid, "training", 1);
  36.         }
  37.         else
  38.         {
  39.             SendClientMessage(playerid, FAILURE, "Ti si Vec na treningu.");
  40.             PlayerPlaySound(playerid, 1053, x, y, z);
  41.         }
  42.       }
  43.       else
  44.       {
  45.         SendClientMessage(playerid, FAILURE, "Nisi blizu Shooting Range");
  46.       }
  47.     return 1;
  48. }
  49.  
  50. COMMAND:zaustavitrening (playerid, params[])
  51. {
  52.     new
  53.         Float:x,
  54.         Float:y,
  55.         Float:z;
  56.     GetPlayerPos(playerid, x, y, z);
  57.     if(GetPVarInt(playerid, "training") == 1)
  58.     {
  59.         SendClientMessage(playerid, SUCCESS, "Trening je Gotov.");
  60.         SendClientMessage(playerid, SUCCESS, "Ako zelis poceti ponovo");
  61.         SendClientMessage(playerid, SUCCESS, "Pisi | /trening |");
  62.         KillTimer(Ttimer);
  63.         SetPVarInt(playerid, "training", 0);
  64.         PlayerPlaySound(playerid, 1053, x, y, z);
  65.         for(new obj, o=MAX_OBJECTS;obj<o;obj++)
  66.         {
  67.             DestroyPlayerObject(playerid, obj);
  68.         }
  69.     }
  70.     else
  71.     {
  72.         SendClientMessage(playerid, FAILURE, "Nisi na treningu.");
  73.         PlayerPlaySound(playerid, 1052, x, y, z);
  74.     }
  75.     return 1;
  76. }
  77.  
  78. forward ObjectToPoint(playerid, Float:radi, objectid, Float:x, Float:y, Float:z);
  79. stock ObjectToPoint(playerid, Float:radi, objectid, Float:x, Float:y, Float:z) //By misko28
  80. {
  81.    new Float:oldposx, Float:oldposy, Float:oldposz;
  82.    new Float:tempposx, Float:tempposy, Float:tempposz;
  83.    GetPlayerObjectPos(playerid, objectid, oldposx, oldposy, oldposz);
  84.    tempposx = (oldposx -x);
  85.    tempposy = (oldposy -y);
  86.    tempposz = (oldposz -z);
  87.    if (((tempposx < radi) && (tempposx > -radi)) && ((tempposy < radi) && (tempposy > -radi)) && ((tempposz < radi) && (tempposz > -radi)))
  88.    {
  89.       return 1;
  90.    }
  91.    return 0;
  92. }
  93.  
  94. stock GetPosFromView(playerid, Float:distance, &Float:x, &Float:y, &Float:z) //By Crack
  95. {
  96.     new Float:cx,Float:cy,Float:cz,Float:fx,Float:fy,Float:fz;
  97.     GetPlayerCameraPos(playerid, cx, cy, cz);
  98.     GetPlayerCameraFrontVector(playerid, fx, fy, fz);
  99.     x = fx * distance + cx;
  100.     y = fy * distance + cy;
  101.     z = fz * distance + cz;
  102. }
  103.  
  104. public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
  105. {
  106.     if(GetPVarInt(playerid, "training") == 1)
  107.     {
  108.         if(newkeys & KEY_FIRE && GetPlayerWeapon(playerid) != 0)
  109.         {
  110.                 new Float:x,
  111.                 Float:y,
  112.                 Float:z;
  113.                 GetPosFromView(playerid, 80, x, y, z);
  114.             for(new  ob,l=MAX_OBJECTS;ob<l;ob++)
  115.                 {
  116.                 if(ObjectToPoint(playerid, 1,ob, x, y, z) != 0)
  117.                 {
  118.                     DestroyPlayerObject(playerid, ob);
  119.                     }
  120.                 }
  121.         }
  122.         return 1;
  123.         }
  124.         return 0;
  125. }
  126.  
  127. public Tstart(playerid)
  128. {
  129.     if(GetPVarInt(playerid, "training") == 1)
  130.     {
  131.         Ttimer = SetTimerEx("TObjectC", 1000, true, "d", playerid);
  132.     }
  133.     return 1;
  134. }
  135.  
  136. public TObjectC(playerid)
  137. {
  138.     if(GetPVarInt(playerid, "training") == 1)
  139.     {
  140.         if(IsPlayerInRangeOfPoint(playerid, 10, 801.61639404297, 1670.5484619141, 4.9562497138977))
  141.         {
  142.             new randPos = random(19);
  143.             new randObj = random(2);
  144.             CreatePlayerObject(playerid, 1583 + randObj, 790 + randPos, 1640.0859375, 5, 0, 0, 0, 100);
  145.         }
  146.         else
  147.         {
  148.             SetPVarInt(playerid, "training", 0);
  149.             SendClientMessage(playerid, FAILURE, "Napustio si zonu i izbacen si iz iste.");
  150.             for(new obj, o=MAX_OBJECTS;obj<o;obj++)
  151.             {
  152.                 DestroyPlayerObject(playerid, obj);
  153.             }
  154.         }
  155.     }
  156.     return 1;
  157. }
  158.  
  159. COMMAND:gotosr(playerid, params[])
  160. {
  161.     SetPlayerPos(playerid, 801.61639404297, 1670.5484619141, 4.9562497138977);
  162.     SendClientMessage(playerid, SUCCESS, "Teleportiran si, Uzivaj u Treningu");
  163.     return 1;
  164. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement