Advertisement
Guest User

Untitled

a guest
Oct 4th, 2012
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 4.25 KB | None | 0 0
  1.     #include <a_samp>
  2.  
  3.     #define FILTERSCRIPT
  4.  
  5.     new g_bCrackState[MAX_PLAYERS];
  6.     new g_tCrackTick[MAX_PLAYERS];
  7.     new g_bDownState[MAX_PLAYERS];
  8.  
  9.     main( ) { }
  10.  
  11.      #undef MAX_PLAYERS
  12.      #define MAX_PLAYERS 40
  13.  
  14.     forward AutoCrack(playerid);
  15.    
  16.  
  17.     public OnPlayerSpawn(playerid)
  18.     {
  19.         SetTimer("AutoCrack", 2500, true);
  20.         return 1;
  21.     }
  22.  
  23.     public OnPlayerCommandText(playerid, cmdtext[])
  24.     {
  25.         new
  26.             Float:health;
  27.  
  28.         GetPlayerHealth(playerid, health);
  29.  
  30.         if (strcmp("/getup", cmdtext, true, 6) == 0)
  31.         {
  32.             GetPlayerHealth(playerid,health);
  33.             if(health < 20.0)
  34.             if ((GetTickCount() - g_tCrackTick[playerid]) > 15000)
  35.             {
  36.                 SetPlayerHealth(playerid, 21);
  37.                 TogglePlayerControllable(playerid, true);
  38.                 ApplyAnimation(playerid,"PED","getup_front",5.0,0,1,1,1,1,1);
  39.                 SendClientMessage(playerid, 0x4AF8FF, "You've successfully got up! Remember to roleplay your injuries. ");
  40.                 g_bCrackState[playerid] = 0;
  41.                 g_tCrackTick[playerid] = GetTickCount();
  42.              }
  43.         }
  44.         if (strcmp("/tackle", cmdtext, true, 7) == 0) {
  45.             new victimid = GetClosestPlayer(playerid);
  46.             if(GetDistanceBetweenPlayers(playerid,victimid) < 2)
  47.             {
  48.                 new Chance = random(10);
  49.                 {
  50.                    switch(Chance)
  51.                    {
  52.                       case 5,10:
  53.                       {
  54.                         ApplyAnimation(playerid,"DODGE","Cover_Dive_01",5.0,0,1,1,1,1,1);
  55.                         TogglePlayerControllable(victimid, false);
  56.                         ApplyAnimation(victimid,"PARACHUTE","FALL_skyDive_DIE",5.0,0,1,1,1,1,1);
  57.                         g_bDownState[victimid] = 1;
  58.                         SendClientMessage(playerid, 0x4AF8FF, " You have successfully downed your target! ");
  59.                         SendClientMessage(victimid, 0x4AF8FF, " You have been tackle'd down by someone! ");
  60.                         SetTimer("Tackle", 30000, false);
  61.                       }
  62.                       case 1,2,3,4,7,8,9:
  63.                       {
  64.                         SendClientMessage(playerid, 0x4AF8FF, " You've failed to tackle your target. ");
  65.                         SendClientMessage(victimid, 0x4AF8FF, " Someone tried to tackle you! ");
  66.                       }
  67.                    }
  68.                 }
  69.             }
  70.             return 1;
  71.         }
  72.         return 1;
  73.     }
  74.  
  75.     public AutoCrack(playerid)
  76.     {
  77.         new Float:health;
  78.  
  79.         GetPlayerHealth(playerid,health);
  80.         if(health < 20.0 && !g_bCrackState[playerid])
  81.         {
  82.             TogglePlayerControllable(playerid, false);
  83.             ApplyAnimation(playerid,"PED","KO_spin_L",3.0,0,1,1,1,1,1);
  84.             g_bCrackState[playerid] = 1;
  85.             g_tCrackTick[playerid] = GetTickCount();
  86.         }
  87.         return 1;
  88.     }
  89.  
  90.     forward Tackle(victimid);
  91.     public Tackle(victimid)
  92.     {
  93.         if ((g_bDownState[victimid] = 1))
  94.         {
  95.             TogglePlayerControllable(victimid, false);
  96.         }
  97.         return 1;
  98.     }
  99.  
  100.     forward Float:GetDistanceBetweenPlayers(p1,p2);
  101.     public Float:GetDistanceBetweenPlayers(p1,p2)
  102.     {
  103.         new Float:x1,Float:y1,Float:z1,Float:x2,Float:y2,Float:z2;
  104.         if(!IsPlayerConnected(p1) || !IsPlayerConnected(p2)) {
  105.             return -1.00;
  106.         }
  107.         GetPlayerPos(p1,x1,y1,z1);
  108.         GetPlayerPos(p2,x2,y2,z2);
  109.         return floatsqroot(floatpower(floatabs(floatsub(x2,x1)),2)+floatpower(floatabs(floatsub(y2,y1)),2)+floatpower(floatabs(floatsub(z2,z1)),2));
  110.     }
  111.  
  112.  
  113.     forward GetClosestPlayer(p1);
  114.     public GetClosestPlayer(p1)
  115.     {
  116.         new x,Float:dis,Float:dis2,player;
  117.         player = -1;
  118.         dis = 99999.99;
  119.         for (x=0;x<MAX_PLAYERS;x++) {
  120.             if(IsPlayerConnected(x)) {
  121.                 if(x != p1) {
  122.                     dis2 = GetDistanceBetweenPlayers(x,p1);
  123.                     if(dis2 < dis && dis2 != -1.00) {
  124.                         dis = dis2;
  125.                         player = x;
  126.                     }
  127.                 }
  128.             }
  129.         }
  130.         return player;
  131.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement