[Include] [INC] Shoot the cow
#1

What is this?
This is a script which allows you to shoot and kill cows... and also resurrect them, and shoot and kill them again I guess.


Video:
https://*****.com/50134010


Credits:
- ****** for foreach & randomEx functions,
- whoever created the IsPlayerAimingAt and other functions for it.


How to install?
It's easy and simple - download and put the cshoot.inc into the \pawno\include\ folder and do the same thing with the foreach.inc file.
Open your script and put this:
pawn Code:
#include <foreach>
#include <cshoot>
right after the
pawn Code:
#include <a_samp>
Put the cows in the OnGameModeInit callback.
Example:
pawn Code:
/*
CreateCow(Float:x, Float:y, Float:z, health, Float:speed, Float:range);
*/

CreateCow(261.24, -1809.09, 5.25, 200,  3.0, 6.5);
CreateCow(282.52, -1804.90, 5.29, 200, 2.25, 8.0);
CreateCow(264.51, -1790.43, 5.24, 200, 2.75, 5.0);
These 3 cows are located at the Santa Maria Beach. Here are the spawn coordinates:
pawn Code:
290.0, -1800.0, 4.45

Functions:
CreateCow
Adds a cow to the server.
@Float: x = Cow spawn X position.
@Float: y = Cow spawn Y position.
@Float: z = Cow spawn Z position.
@health = Cow health.
@Float: speed = Cow speed.
@Float: range = Cow range in which cow will move.
returns the cow ID which starts with 0. If you exceed the MAX_COWS define then it will return the invalid ID which is -1.
If you set the health which is higher than MAX_COW_HEALTH, then the function will automatically set it to the MAX_COW_HEALTH. The similar thing will happen if you set the health which is lower than MIN_COW_HEALTH, the function will set it to the MIN_COW_HEALTH. The same thing will happen with the speed - MAX_COW_SPEED / MIN_COW_SPEED.
Example:
pawn Code:
new
        gCow = -1;

public OnGameModeInit()
{
    gCow = CreateCow(261.24, -1809.09, 5.25, 200, 3.0, 6.5);
    return true;
}
DestroyCow
Deletes the cow from the server.
@cowid = The cow ID.
returns true if the cow is valid and false if it's not.
Example:
pawn Code:
DestroyCow(gCow);
IsCowCreated
Checks if cow is created.
@cowid = The cow ID.
returns true if the cow is valid and false if it's not.
Example:
pawn Code:
if(IsCowCreated(gCow)) printf("Cow is created.");
else printf("Cow is NOT created.");
SetCowHealth
Sets the new amount of health for the cow.
@cowid = The cow ID.
@health = Cow health.
returns true if the cow is valid and false if it's not.
If you set the health which is higher than MAX_COW_HEALTH, then the function will automatically set it to the MAX_COW_HEALTH. The similar thing will happen if you set the health which is lower than 0, the function will set it to 0.
Example:
pawn Code:
SetCowHealth(gCow, 150);
GetCowHealth
Returns the current amount of health for the cow.
@cowid = The cow ID.
returns amount of health if the cow is valid and false if it's not.
Example:
pawn Code:
printf("Health of cow with ID %i: %i", gCow, GetCowHealth(gCow));
KillCow
Kills the cow - this function won't call the OnCowDeath callback.
@cowid = The cow ID.
returns true if the cow is valid and false if it's not.
Example:
pawn Code:
KillCow(gCow);
ResurrectCow | RespawnCow
Resurrects/respawns the cow and sets a new health for it.
@cowid = The cow ID.
@health = Cow health.
returns true if the cow is valid and false if it's not or if cow is not dead.
If you set the health which is higher than MAX_COW_HEALTH, then the function will automatically set it to the MAX_COW_HEALTH. The similar thing will happen if you set the health which is lower than MIN_COW_HEALTH, the function will set it to the MIN_COW_HEALTH.
Example:
pawn Code:
ResurrectCow(gCow, 100);
IsCowDead
Checks if cow is dead.
@cowid = The cow ID.
returns true if the cow is dead and false if it's not or if cow isn't created.
Example:
pawn Code:
if(IsCowDead(gCow)) printf("Cow is dead.");
else printf("Cow is NOT dead.");

Callbacks:
OnCowDeath
Callback will be called when the cow dies.
@cowid = The cow ID.
@killerid = The killer ID.
@reason = Weapon ID.
Example:
pawn Code:
public OnCowDeath(cowid, killerid, reason)
{
    new
            string[96];
    GetPlayerName(killerid, string, MAX_PLAYER_NAME);
    format(string, 96, "OnCowDeath(Cow ID: %i, Killer name: %s, Weapon ID: %i)",
        cowid, string, reason);
    SendClientMessage(killerid, -1, string);
    return true;
}
OnCowTakeDamage
Callback will be called when the cow takes damage.
@cowid = The cow ID.
@shooterid = The shooter ID.
@reason = Weapon ID.
@damage = The amount of health cow has lost.
Example:
pawn Code:
public OnCowTakeDamage(cowid, shooterid, reason, damage)
{
    new
            string[108];
    GetPlayerName(shooterid, string, MAX_PLAYER_NAME);
    format(string, 108, "OnCowTakeDamage(Cow ID: %i, Shooter name: %s, Weapon ID: %i, Damage: %i)",
        cowid, string, reason, damage);
    SendClientMessage(shooterid, -1, string);
    return true;
}

Defines:
pawn Code:
#define MAX_COWS (3)
#define ENABLE_SOUND (0)
#define MIN_COW_SPEED (1.0)
#define MAX_COW_SPEED (5.0)
#define MIN_COW_HEALTH (10)
#define MAX_COW_HEALTH (200)
MAX_COWS - The maximum amount of cows allowed for script to load on the server.
ENABLE_SOUND - If this is setted to 1, then you will hear the cow moo-sound on the cow damage/death (I didn't enable it in the video, because it "lags" a bit for a player).
MIN_COW_SPEED / MAX_COW_SPEED - The minimum / maximum speed of the cow.
MIN_COW_HEALTH / MAX_COW_HEALTH - The minimum / maximum health of the cow.


How to get coordinates for cows?
I myself am using JernejL's REAL Map Editor, in which I place the cow objects (ID: 16442) where I want to have them. This Map Editor is not for people with weak computers, so if you have a weak computer, you can use any other Map Editor.


Download:
http://www.solidfiles.com/d/ce887b8bfa


Other:
When you delete the last cow then the timer will stop so you don't have to do anything, and when you add the first cow then it will start again.

This include supports only these weapons:




If you want to loop through all created cows, then use this example:
pawn Code:
foreach(Cows, a)
{
    RespawnCow(a, 200);
}
Reply
#2

Wow.
Epic script.
Your releases are awesome.

Great JoB and keep going +3

Edit: Need to share reps to somemore because I've reped you in your previous cool map.

I'll rep you soon.
Once again, cool include.

And I'll surely use this.

EDIT2:
REPED!
Reply
#3

Awesome willl this work on 3c ?
Reply
#4

Sounds awesome I will look at the video later!.
Reply
#5

Quote:
Originally Posted by [xB]Lordz
View Post
And I'll surely use this.
Great, report bugs if you find any.

Quote:
Originally Posted by Black Wolf
View Post
Awesome willl this work on 3c ?
I guess it will - I don't see any problem why it wouldn't.
Reply
#6

Hiddos willn't like it.
Reply
#7

y u so disrespectful ((((((
Reply
#8

Quote:
Originally Posted by Hiddos
View Post
y u so disrespectful ((((((
Eh, just shoot it.
Reply
#9

Quote:
Originally Posted by Correlli
View Post
Eh, just shoot it.
So is 'damage' based on the amount of damage guns normally do to players? I've seen this before but that was 1-hit kill.
Reply
#10

Quote:
Originally Posted by Hiddos
View Post
So is 'damage' based on the amount of damage guns normally do to players? I've seen this before but that was 1-hit kill.
Well, if you look at the code, you can see this:
Code:
Weapon ID: 22, 23; damage: between 15 and 20
Weapon ID: 24; damage: between 25 and 30
Weapon ID: 25; damage: between 30 and 40
Weapon ID: 26; damage: between 20 and 25
Weapon ID: 27, 33; damage: between 30 and 35
Weapon ID: 28, 29, 32; damage: between 10 and 15
Weapon ID: 30, 31; damage: between 15 and 25
Weapon ID: 34; damage: between 60 and 75
Weapon ID: 37; damage: between 15 and 30
Weapon ID: 38; damage: between 40 and 50
Every weapon (from these 15) does it's own damage.

Quote:
Originally Posted by nRaike
View Post
Are you still over here?
Sure I am.

Quote:
Originally Posted by nRaike
View Post
Remember of me? :>
Yeah, I think I do. Last time I heard from you, you had some team who was working on some RP gamemode if I remember correctly?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)