http://forum.sa-mp.com/index.php?topic=140857.0
video at the webpage
you should put these around your base and have it shoot down unathourized aircarft/vehicle
This is my first release.
What is it?
This include is a dynamic system of Surface-to-Air-Missile batteries. Better known the Anti-Air guns at Area 69. With this include you can place one of these systems ANYWHERE around San Andreas.
How does it work?
The system is built with two timers that update the SAM's and the missiles. When you trigger the SAM site it will fire what looks to be a missile, which is actually a hydra flare. The missile travels at selected speed and once it gets close to you it triggers 3 explosions and destroys your plane/helicopter. The system works on ALL aircraft, civilian and military.
SA:MP Surface to Air Missiles by Awaran[Enemy_Plus] 0.1.2 DQ | by Aeva
How to install?
Place the file "SAMsites##.inc" into your "pawno/include/" folder in your SA:MP Server directory.
To install into the GameMode place this at the top of your script under "#include <a_samp>"
PAWN Code:
#include <SAMsites##>## = version
So you do not get these four errors:
PAWN Code:
pawno\include\SAMsites0.4.inc(**) : error 004: function "OnSamSiteUpdate" is not implemented
pawno\include\SAMsites0.4.inc(**) : error 004: function "OnSamSiteUpdate" is not implemented
pawno\include\SAMsites0.4.inc(**) : error 004: function "OnSamSiteRestarted" is not implemented
pawno\include\SAMsites0.4.inc(**) : error 004: function "OnSamSiteRestarted" is not implemented
add this into your script:
PAWN Code:
public OnSamSiteRestarted()
{
return 1;
}
public OnSamSiteUpdate(samid, playerid)
{
return 1;
}
Place this into your OnGameModeInit()
PAWN Code:
SAM_start();WARNING: Make sure this function goes UNDER all your SAM Site creating functions
How to add SAM Sites?
There are 4 ways to create SAM Sites, which are the following:
PAWN Code:
native AddStaticSAM(samid,Float:X, Float:Y, Float:Z);
native AddStaticSAMEx(samid, Float:X, Float:Y, Float:Z, srange, sspeed);
native CreateSAM(samid, Float:X, Float:Y, Float:Z, Float:rX, Float:rY, Float:rZ); // BUGGED
native CreateSAMEx(samid, Float:X, Float:Y, Float:Z, Float:rX, Float:rY, Float:rZ, srange, sspeed); // BUGGED
AddStaticSAM(Ex) is for creating a SAM Site system over an existing SAM Site object.
CreateSAM(Ex) is for creating a SAM Site System and SAM Site object.
You can choose the range and missile speeds for each SAM Site you create. This is done by using AddStaticSAMEx and CreateSAMEx.
For speed, anything lower than 60 will just be really slow, and you have to travel really slow for it to catch you. (Not for hydra)
You need to return the SAM with a variable. The system will return an ID but you can use your variable as reference.
By default you only have 20 SAM sites. You can change this by seeking the SAMsites##.inc file.
Find System Config and change
PAWN Code:
#define MAX_SAMS 32
to what ever it is you want. I suggest not going for an extreme number.
Team Compatibility:
WARNING: As of v0.3 the default team compatibility has been removed, see below.
The new callback "OnSamSiteUpdate" allows for you to cancel a SAM from firing. This can now host any team script like gTeam.
Example:
PAWN Code:
public OnSamSiteUpdate(samid, playerid)
{
if(samid == 1)
{
if(gTeam[playerid] == TEAM_ARMY)
{
SAM_cancel(samid);
}
}
return 1;
}
How to return SAMS with variables?
The system does support variable returned samid's.
Create a new variable at the top of your script and add the variable's name followed by a '=' before any of your SAM Site creation functions.
SAM Site Labels
Now it is possible to add 3D Text labels to your SAM Sites through the script, basically no work at all.
Simply add under SAM_start(); in OnGameModeInit()
PAWN Code:
CreateSamLabel(samid, label[], color, Float:DrawDistance, LOS);
Area 69 SAM locations:
PAWN Code:
AddStaticSAM(237.5797,1698.6908,23.8673);
AddStaticSAM(15.3281,1720.9646,23.8673);
AddStaticSAM(188.2694,2083.4644,23.9063);
AddStaticSAM(354.5453,2030.3062,23.8750);
Dead Sam Bug
In v0.4 there is an attempt to fix the SAMS from dying after a while. You have a define called RESTART_INTERVAL.
Change this to your desired time in milliseconds for the sams to restart. This timer will call a callback, also resetting all SAMSite information to 0 and all IDs to INVALID_SAM_ID.
The callback is used by getting everything (excluding SamLabel functions) you used with the SAMSites include that create SAMsites and place this inside this callback. Then at the bottom place SAM_start(); if not there already.
Example:
PAWN Code:
public OnGameModeInit()
{
AddStaticSAM(237.5797,1698.6908,23.8673);
AddStaticSAM(15.3281,1720.9646,23.8673);
AddStaticSAM(188.2694,2083.4644,23.9063);
AddStaticSAM(354.5453,2030.3062,23.8750);
SAM_start();
return 1;
}
public OnSamSiteRestarted()
{
AddStaticSAM(237.5797,1698.6908,23.8673);
AddStaticSAM(15.3281,1720.9646,23.8673);
AddStaticSAM(188.2694,2083.4644,23.9063);
AddStaticSAM(354.5453,2030.3062,23.8750);
SAM_start();
return 1;
}
Download:
(Older versions removed)
SA:MP SAMSites0.4.inc - See Attachments
Code: (Changelog)
0.1
- First Release
0.1.1
- Now doesn't fire missiles after you are dead from the first missile
- Now there is a "Drag" feature, if the missile is alive for more than 25 seconds, it will blow up.
0.1.2
- Now the missiles DO NOT stay at the place where the detonated.
---
0.2
- Added new functions.
- Added SAM Sites based on Team.
- Added ability to set custom Range and Speed of missiles per samid.
- Added functions that create a SAM Site object - Level to the ground.
---
0.3 BETA
- Added callback OnSamSiteUpdate
- Attempted to fix the missile chase id (should chase correct vehicle)
- Removed default team script
- Added new function
- Removed a function
0.3.1
- Variables cannot be samid's
- Fixed the Array error
- Fixed the Callback
0.3.2
- Variables can now be used as reference to the samid
- Fixed the tracking of missiles, missiles now SHOULD chase the right vehicle
- Added a restart timer, this restarts the SAMS system in attempt to stop a bug
- Added Sam Labels
0.3.3
- Fixed the buged SAMS at 0.0,0.0,0.0 - Credit to rs2fun111 for finding this bug
0.4
- Added new callback OnSamSiteRestarted
- Attempted fix of "Dead Sam Bug"
- Added 'under the radar' checking
- Updated the Default limit to SPEED and MAX_SAMS
Code: (Bugs)
- Sam Sites stop working after a period of time (Since 0.1)
Credits:
If you can add credits to me for this, and not re-release it under your own name it would be appreciated.
Please post any bugs that you may encounter. I unfortunately can't guarantee a fully bug-free script with this first release. None have been found so far.
Thank-you to Μαστερμινδ, lrZ^ aka LarzI and [HiC]TheKiller who helped with an array error.