Guest User

Untitled

a guest
Feb 23rd, 2013
288
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.97 KB | None | 0 0
  1. // By Mean
  2.  
  3. #define FILTERSCRIPT
  4.  
  5. #include <a_samp>
  6. #include <foreach>
  7. #include <zcmd>
  8.  
  9.  
  10. #define abs(%0) ((%0) >= 0 ? (%0) : -(%0))
  11. #define PUB:%0(%1) forward public %0(%1); public %0(%1)
  12.  
  13. new CowObject[MAX_PLAYERS][2];
  14. new CowTimer[2];
  15. new PlayerHasCow[MAX_PLAYERS];
  16.  
  17. public OnFilterScriptInit() {
  18.     printf("COWS COWS COWS");
  19.     return 1;
  20. }
  21.  
  22. public OnPlayerDisconnect(playerid) {
  23.     StopCowFollow(playerid);
  24.     return 1;
  25. }
  26.  
  27. public OnPlayerDeath(playerid) {
  28.     StopCowFollow(playerid);
  29.     return 1;
  30. }
  31.  
  32. stock IsObjectInRangeOfPoint( Float:radi, objectid, Float:x, Float:y, Float:z ) {
  33.     new Float:oldposx, Float:oldposy, Float:oldposz;
  34.     new Float:tempposx, Float:tempposy, Float:tempposz;
  35.     GetObjectPos( objectid, oldposx, oldposy, oldposz );
  36.     tempposx = ( oldposx -x );
  37.     tempposy = ( oldposy -y );
  38.     tempposz = ( oldposz -z );
  39.     if (((tempposx < radi) && (tempposx > -radi)) && ((tempposy < radi) && (tempposy > -radi)) && ((tempposz < radi) && (tempposz > -radi))) {
  40.         return 1;
  41.     }
  42.     return 0;
  43. }
  44.  
  45. stock StartCowFollow(playerid) {
  46.     new Float:pos[3];
  47.     GetPlayerPos(playerid, pos[0], pos[1], pos[2]);
  48.     CowObject[playerid][0] = CreateObject(16442, pos[0] + 10, pos[1] + 10, pos[2], 0.0, -76.0, 0.0);
  49.     CowObject[playerid][1] = CreateObject(335, 1.89596, -0.42760, 0.17158, 0.0, 0.0, 0.0);
  50.     AttachObjectToObject(CowObject[playerid][1], CowObject[playerid][0], 0.65, -0.4, -1.7, 0.0, 0.0, 0.0, 0);
  51.     PlayerHasCow[playerid] = 1;
  52.     PlayAudioStreamForPlayer(playerid, "http://ww100.peejeshare.com/dl/02/23/96/1361651184/tttt.mp3");
  53.     CowTimer[0] = SetTimerEx("CowFollow", 1000, 1, "i", playerid);
  54.     CowTimer[1] = SetTimerEx("CowStream", 3000, 1, "i", playerid);
  55.     SendClientMessage(playerid, -1, "Cow follow started");
  56.     return 1;
  57. }
  58.  
  59. stock StopCowFollow(playerid) {
  60.     StopAudioStreamForPlayer(playerid);
  61.     for(new i=0; i<sizeof(CowObject); ++i) DestroyObject(CowObject[playerid][i]);
  62.     PlayerHasCow[playerid] = 0;
  63.     KillTimer(CowTimer[0]);
  64.     KillTimer(CowTimer[1]);
  65.     StopAudioStreamForPlayer(playerid);
  66.     return 1;
  67. }
  68.  
  69.  
  70. PUB:CowFollow(playerid) {
  71.     if(PlayerHasCow[playerid] == 1) {
  72.         new Float:pos[3];
  73.         GetPlayerPos(playerid, pos[0], pos[1], pos[2]);
  74.  
  75.         // THIS PART OF CODE IS FROM HIDDOS'S SCRIPT
  76.         new Float:Pos[7];
  77.         GetObjectPos(CowObject[playerid][0], Pos[0], Pos[1], Pos[2]);
  78.         if(IsPlayerInAnyVehicle(playerid)) GetVehiclePos(GetPlayerVehicleID(playerid), Pos[3], Pos[4], Pos[5]);
  79.         else GetPlayerPos(playerid, Pos[3], Pos[4], Pos[5]);
  80.         Pos[3] += float(random(10) - 5);
  81.         Pos[4] += float(random(10) - 5);
  82.         Pos[6] = atan( floatdiv(abs(Pos[4] - Pos[1]), abs(Pos[3] - Pos[0])) );
  83.         if(Pos[3] < Pos[0] && Pos[4] < Pos[1])  Pos[6] += 180;
  84.         else if(!(Pos[3] > Pos[0] && Pos[4] > Pos[1])) {
  85.             Pos[6] *= float(-1);
  86.             Pos[6] += float((Pos[3] > Pos[0] && Pos[4] < Pos[1]) ? (90) : (270));
  87.             Pos[6] -= float(90);
  88.         }
  89.         // END HIDDOS CODE
  90.  
  91.         MoveObject(CowObject[playerid][0], pos[0], pos[1], pos[2], 10, 0.0, -76.0, Pos[6]);
  92.         if(IsObjectInRangeOfPoint(4.0, CowObject[playerid][0], pos[0], pos[1], pos[2]) && GetPlayerState(playerid) != PLAYER_STATE_WASTED) {
  93.             SetPlayerHealth(playerid, 0);
  94.             SendClientMessage(playerid, 0xFF0000AA, "You just got killed by the KILLER COW!");
  95.         }
  96.     }
  97.     return 1;
  98. }
  99.  
  100. PUB:CowStream(playerid) {
  101.     if(PlayerHasCow[playerid]) PlayAudioStreamForPlayer(playerid, "http://ww100.peejeshare.com/dl/02/23/96/1361651184/tttt.mp3");
  102.     return 1;
  103. }
  104.  
  105.  
  106. CMD:cowon(playerid, params[]) {
  107.     if(PlayerHasCow[playerid]) return SendClientMessage(playerid, -1, "You already have a pet cow.");
  108.     StartCowFollow(playerid);
  109.     SendClientMessage(playerid, -1, "You're SO DEAD!");
  110.     return 1;
  111. }
  112.  
  113. CMD:cowoff(playerid, params[]) {
  114.     if(!PlayerHasCow[playerid]) return SendClientMessage(playerid, -1, "You don't have a pet cow, get one now @ /cowon!");
  115.     StopCowFollow(playerid);
  116.     SendClientMessage(playerid, -1, "You've stopped the cow!");
  117.     return 1;
  118. }
Advertisement
Add Comment
Please, Sign In to add comment