SHOW:
|
|
- or go back to the newest paste.
| 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 StreamTimer; | |
| 15 | new PlayerHasCow[MAX_PLAYERS]; | |
| 16 | ||
| 17 | stock StopCowFollow(playerid) {
| |
| 18 | PlayerHasCow[playerid] = 0; | |
| 19 | KillTimer(StreamTimer); | |
| 20 | for(new i=0; i<sizeof(CowObject); ++i) DestroyObject(CowObject[playerid][i]); | |
| 21 | StopAudioStreamForPlayer(playerid); | |
| 22 | } | |
| 23 | ||
| 24 | stock StartCowFollow(playerid) {
| |
| 25 | new Float:pos[3]; | |
| 26 | GetPlayerPos(playerid, pos[0], pos[1], pos[2]); | |
| 27 | CowObject[playerid][0] = CreateObject(16442, pos[0] + 10, pos[1] + 10, pos[2], 0.0, -76.0, 0.0); | |
| 28 | MoveObject(CowObject[playerid][0], pos[0], pos[1], pos[2], 11.0); | |
| 29 | CowObject[playerid][1] = CreateObject(335, 1.89596, -0.42760, 0.17158, 0.0, 0.0, 0.0); | |
| 30 | AttachObjectToObject(CowObject[playerid][1], CowObject[playerid][0], 0.65, -0.4, -1.7, 0.0, 0.0, 0.0, 0); | |
| 31 | PlayerHasCow[playerid] = 1; | |
| 32 | PlayAudioStreamForPlayer(playerid, "http://ge.tt/api/1/files/9l5QsKZ/0/blob?download"); | |
| 33 | StreamTimer = SetTimerEx("CowStream", 4000, 1, "i", playerid);
| |
| 34 | } | |
| 35 | ||
| 36 | stock IsObjectInRangeOfPoint( Float:radi, objectid, Float:x, Float:y, Float:z ) {
| |
| 37 | new Float:oldposx, Float:oldposy, Float:oldposz; | |
| 38 | new Float:tempposx, Float:tempposy, Float:tempposz; | |
| 39 | GetObjectPos( objectid, oldposx, oldposy, oldposz ); | |
| 40 | tempposx = ( oldposx -x ); | |
| 41 | tempposy = ( oldposy -y ); | |
| 42 | tempposz = ( oldposz -z ); | |
| 43 | if (((tempposx < radi) && (tempposx > -radi)) && ((tempposy < radi) && (tempposy > -radi)) && ((tempposz < radi) && (tempposz > -radi))) {
| |
| 44 | return 1; | |
| 45 | } | |
| 46 | return 0; | |
| 47 | } | |
| 48 | ||
| 49 | public OnFilterScriptInit() {
| |
| 50 | printf("COWS COWS COWS");
| |
| 51 | return 1; | |
| 52 | } | |
| 53 | ||
| 54 | public OnPlayerDisconnect(playerid) {
| |
| 55 | StopCowFollow(playerid); | |
| 56 | return 1; | |
| 57 | } | |
| 58 | ||
| 59 | public OnPlayerDeath(playerid) {
| |
| 60 | StopCowFollow(playerid); | |
| 61 | return 1; | |
| 62 | } | |
| 63 | ||
| 64 | public OnObjectMoved(objectid) {
| |
| 65 | foreach(Player, playerid) {
| |
| 66 | if(CowObject[playerid][0] == objectid) {
| |
| 67 | new Float:pos[3]; | |
| 68 | GetPlayerPos(playerid, pos[0], pos[1], pos[2]); | |
| 69 | ||
| 70 | // THIS PART OF CODE IS FROM HIDDOS'S SCRIPT | |
| 71 | new Float:Pos[7]; | |
| 72 | GetObjectPos(CowObject[playerid][0], Pos[0], Pos[1], Pos[2]); | |
| 73 | if(IsPlayerInAnyVehicle(playerid)) GetVehiclePos(GetPlayerVehicleID(playerid), Pos[3], Pos[4], Pos[5]); | |
| 74 | else GetPlayerPos(playerid, Pos[3], Pos[4], Pos[5]); | |
| 75 | Pos[3] += float(random(10) - 5); | |
| 76 | Pos[4] += float(random(10) - 5); | |
| 77 | Pos[6] = atan( floatdiv(abs(Pos[4] - Pos[1]), abs(Pos[3] - Pos[0])) ); | |
| 78 | if(Pos[3] < Pos[0] && Pos[4] < Pos[1]) Pos[6] += 180; | |
| 79 | else if(!(Pos[3] > Pos[0] && Pos[4] > Pos[1])) {
| |
| 80 | Pos[6] *= float(-1); | |
| 81 | Pos[6] += float((Pos[3] > Pos[0] && Pos[4] < Pos[1]) ? (90) : (270)); | |
| 82 | Pos[6] -= float(90); | |
| 83 | } | |
| 84 | // END HIDDOS CODE | |
| 85 | ||
| 86 | MoveObject(CowObject[playerid][0], pos[0], pos[1], pos[2], 10, 0.0, -76.0, Pos[6]); | |
| 87 | if(IsObjectInRangeOfPoint(4.0, CowObject[playerid][0], pos[0], pos[1], pos[2]) && GetPlayerState(playerid) != PLAYER_STATE_WASTED) {
| |
| 88 | SetPlayerHealth(playerid, 0); | |
| 89 | SendClientMessage(playerid, 0xFF0000AA, "You just got killed by the KILLER COW!"); | |
| 90 | } | |
| 91 | } | |
| 92 | } | |
| 93 | return 1; | |
| 94 | } | |
| 95 | ||
| 96 | CMD:cowon(playerid, params[]) {
| |
| 97 | if(PlayerHasCow[playerid] == 1) return SendClientMessage(playerid, -1, "You already have a pet cow."); | |
| 98 | StartCowFollow(playerid); | |
| 99 | SendClientMessage(playerid, -1, "You're SO DEAD!"); | |
| 100 | return 1; | |
| 101 | } | |
| 102 | ||
| 103 | CMD:cowoff(playerid, params[]) {
| |
| 104 | if(PlayerHasCow[playerid] == 0) return SendClientMessage(playerid, -1, "You don't have a pet cow, get one now @ /cowon!"); | |
| 105 | StopCowFollow(playerid); | |
| 106 | SendClientMessage(playerid, -1, "You've stopped the cow!"); | |
| 107 | return 1; | |
| 108 | } | |
| 109 | ||
| 110 | PUB:CowStream(playerid) {
| |
| 111 | StopAudioStreamForPlayer(playerid); | |
| 112 | PlayAudioStreamForPlayer(playerid, "http://ge.tt/api/1/files/9l5QsKZ/0/blob?download"); | |
| 113 | return 1; | |
| 114 | } |