Advertisement
Guest User

Untitled

a guest
Oct 24th, 2010
582
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 5.96 KB | None | 0 0
  1. //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  2. ///                                                                                                                    ///
  3. ///                             This script requires Kalcor's (Kye) MapAndreas plugin to work!                         ///
  4. ///                                                                                                                    ///
  5. //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  6. #include <a_samp>
  7. #include <mapandreas>
  8. #define COLOR_BLUE 0x0000FFFF
  9. #if defined MAX_PLAYERS
  10.     #undef MAX_PLAYERS
  11.     #define MAX_PLAYERS 500 //Enter your maximum player amount here. Saves resources.
  12. #endif
  13. new Cow[MAX_PLAYERS] = {-1,-1,...};
  14. new CowJump[MAX_PLAYERS];
  15. new CowTimer[MAX_PLAYERS];
  16. forward OnCowUpdate(playerid);
  17. public OnFilterScriptInit()
  18. {
  19.     print(" ______________________________________");
  20.     print("|                                      |");
  21.     print("|   The Cowly Cow FilterScript         |");
  22.     print("|  Originally produced by Hiddos       |");
  23.     print("|    Milk it                McFaik     |");
  24.     print("|______________________________________|");
  25.     MapAndreas_Init(MAP_ANDREAS_MODE_FULL);
  26.     return 1;
  27. }
  28.  
  29.  
  30. public OnPlayerDisconnect(playerid, reason)
  31. {
  32.     if(Cow[playerid] != -1)
  33.     {
  34.         DestroyObject(Cow[playerid]);
  35.         Cow[playerid] = -1;
  36.         KillTimer(CowTimer[playerid]);
  37.     }
  38.     return 1;
  39. }
  40.  
  41. public OnPlayerCommandText(playerid, cmdtext[])
  42. {
  43.     if(!strcmp("/ride", cmdtext, true))
  44.     {
  45.         new Float:a;
  46.         new Float:x, Float:y, Float:z;
  47.         if(Cow[playerid] != -1)
  48.         {
  49.             GetObjectRot(Cow[playerid], x, y, a);
  50.             GetObjectPos(Cow[playerid], x, y, z);
  51.             DestroyObject(Cow[playerid]);
  52.             SendClientMessage(playerid,COLOR_BLUE,"You've stopped enjoying a ride on a cow.");
  53.             Cow[playerid] = -1;
  54.             TogglePlayerSpectating(playerid,0);
  55.             SetPlayerPos(playerid, x, y, z);
  56.             SetPlayerFacingAngle(playerid, a);
  57.             KillTimer(CowTimer[playerid]);
  58.             return 1;
  59.         }
  60.         GetPlayerPos(playerid,x,y,z);
  61.         GetPlayerFacingAngle(playerid,a);
  62.         a+=90;
  63.         Cow[playerid] = CreateObject(16442,x+5,y,z+2,0,0,a);
  64.         SendClientMessage(playerid,COLOR_BLUE,"You've climbed into the head of a cow and are now in full control of her brain.");
  65.         TogglePlayerSpectating(playerid,1);
  66.         OnCowUpdate(playerid);
  67.         CowTimer[playerid] = SetTimerEx("OnCowUpdate", 30, 1, "d", playerid);
  68.         return 1;
  69.     }
  70.     return 0;
  71. }
  72.  
  73.    
  74. public OnCowUpdate(playerid)
  75. {
  76.     new Keys[3];
  77.     new Float:Pos[7]; //x-y-z-X-Y-Z-a
  78.     GetPlayerKeys(playerid, Keys[0], Keys[1], Keys[2]); // Keys - Left/Right Value - Up/Down Value
  79.     GetObjectRot(Cow[playerid], Pos[0], Pos[1], Pos[6]);
  80.     GetObjectPos(Cow[playerid], Pos[0], Pos[1], Pos[2]);
  81.    
  82.     if(Keys[2] != 0)
  83.     {
  84.         SetObjectRot(Cow[playerid], 0, 0, ((Keys[2] > 0 && Keys[1] <= 0) || (Keys[2] < 0 && Keys[1] > 0)) ? (Pos[6] - 3.5) : (Pos[6] + 3.5));
  85.     }
  86.  
  87.     Pos[6] += 90;
  88.  
  89.     if(Keys[1] < 0)
  90.     {
  91.         Pos[3] = Pos[0] - (((Keys[0] & KEY_SPRINT) ? (0.58) : (0.26)) * floatsin(-Pos[6], degrees));
  92.         Pos[4] = Pos[1] - (((Keys[0] & KEY_SPRINT) ? (0.58) : (0.26)) * floatcos(-Pos[6], degrees));
  93.        
  94.         MapAndreas_FindZ_For2DCoord(Pos[3], Pos[4], Pos[5]);
  95.        
  96.         //PROBLEM
  97.         if(Pos[5] - Pos[2] < 4.5)
  98.         {
  99.             if(Pos[2] - Pos[5] > 4 || CowJump[playerid] > 0)
  100.             {
  101.                 SetObjectPos(Cow[playerid], Pos[3], Pos[4], Pos[2] + ((CowJump[playerid] <= 0) ? (-0.32) : (0.6)));
  102.             }
  103.                 else
  104.             {
  105.                 CowJump[playerid] = 0;
  106.                 if(Keys[0] & KEY_JUMP) CowJump[playerid] = 6;
  107.                 SetObjectPos(Cow[playerid], Pos[3], Pos[4], Pos[5] + ((CowJump[playerid] > 0) ? (2.6) : (2.0)));
  108.             }
  109.         }
  110.         //PROBLEM END
  111.        
  112.         SetPlayerCameraLookAt(playerid, Pos[3], Pos[4], Pos[((Pos[2] - Pos[5] > 4.5) ? (2):(5))]+ 2.5);
  113.         if(Keys[0] & KEY_LOOK_BEHIND)
  114.         {
  115.             Pos[3] -= (7.8 * floatsin(-Pos[6], degrees));
  116.             Pos[4] -= (7.8 * floatcos(-Pos[6], degrees));
  117.         }
  118.             else
  119.         {
  120.             Pos[3] += (7.8 * floatsin(-Pos[6], degrees));
  121.             Pos[4] += (7.8 * floatcos(-Pos[6], degrees));
  122.         }
  123.         SetPlayerCameraPos(playerid,Pos[3], Pos[4], Pos[2] + 3.2);
  124.     }
  125.         else if(Keys[1] > 0)
  126.     {
  127.         Pos[3] = Pos[0] + (0.2 * floatsin(-Pos[6], degrees));
  128.         Pos[4] = Pos[1] + (0.2 * floatcos(-Pos[6], degrees));
  129.         MapAndreas_FindZ_For2DCoord(Pos[3], Pos[4], Pos[5]);
  130.         if(Pos[5] - Pos[2] < 2)
  131.         {
  132.             if(Pos[2] - Pos[5] > 4.5 || CowJump[playerid] > 0) SetObjectPos(Cow[playerid], Pos[3], Pos[4], Pos[2] + ((CowJump[playerid] > 0) ? (0.6) : (-0.32)));
  133.             else SetObjectPos(Cow[playerid], Pos[3], Pos[4], Pos[5] + 2);
  134.         }
  135.  
  136.         SetPlayerCameraLookAt(playerid, Pos[3], Pos[4], Pos[((Pos[2] - Pos[5] > 4.5) ? (2):(5))] + 2.5);
  137.         if(Keys[0] & KEY_LOOK_BEHIND)
  138.         {
  139.             Pos[3] -= (7.8 * floatsin(-Pos[6], degrees));
  140.             Pos[4] -= (7.8 * floatcos(-Pos[6], degrees));
  141.         }
  142.             else
  143.         {
  144.             Pos[3] += (7.8 * floatsin(-Pos[6], degrees));
  145.             Pos[4] += (7.8 * floatcos(-Pos[6], degrees));
  146.         }
  147.     //  Pos[3] = Pos[0] +(7.8 * floatsin(-Pos[6], degrees));
  148.     //  Pos[4] = Pos[1] +(7.8 * floatcos(-Pos[6], degrees));
  149.         SetPlayerCameraPos(playerid, Pos[3], Pos[4], Pos[2] + 3.2);
  150.     }
  151.         else
  152.     {
  153.         MapAndreas_FindZ_For2DCoord(Pos[0], Pos[1], Pos[5]);
  154.         if(Pos[2] - Pos[5] > 4.5 || CowJump[playerid] > 0) SetObjectPos(Cow[playerid], Pos[0], Pos[1], Pos[2] + ((CowJump[playerid] > 0) ? (0.6) : (-0.32)));
  155.         else if(Keys[0] & KEY_JUMP)
  156.         {
  157.             CowJump[playerid] = 6;
  158.             SetObjectPos(Cow[playerid], Pos[0], Pos[1], Pos[5] + 2.6);
  159.         }
  160.         else SetObjectPos(Cow[playerid], Pos[0], Pos[1], Pos[5] + 2);
  161.         SetPlayerCameraLookAt(playerid, Pos[0], Pos[1], Pos[2] + 0.1);
  162.         if(Keys[0] & KEY_LOOK_BEHIND)
  163.         {
  164.             Pos[0] -= (7 * floatsin(-Pos[6], degrees));
  165.             Pos[1] -= (7 * floatcos(-Pos[6], degrees));
  166.         }
  167.             else
  168.         {
  169.             Pos[0] += (7 * floatsin(-Pos[6], degrees));
  170.             Pos[1] += (7 * floatcos(-Pos[6], degrees));
  171.         }
  172.         SetPlayerCameraPos(playerid, Pos[0], Pos[1], Pos[2] + 2.9);
  173.     }
  174.     CowJump[playerid]--;
  175. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement