25.09.2012, 13:00
(
Last edited by Correlli; 26/09/2012 at 02:45 PM.
)
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:
right after the
Put the cows in the OnGameModeInit callback.
Example:
These 3 cows are located at the Santa Maria Beach. Here are the spawn coordinates:
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:
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:
IsCowCreated
Checks if cow is created.
@cowid = The cow ID.
returns true if the cow is valid and false if it's not.
Example:
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:
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:
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:
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:
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:
Callbacks:
OnCowDeath
Callback will be called when the cow dies.
@cowid = The cow ID.
@killerid = The killer ID.
@reason = Weapon ID.
Example:
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:
Defines:
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:
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>
pawn Code:
#include <a_samp>
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);
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;
}
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);
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.");
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);
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));
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);
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);
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;
}
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)
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);
}