/* * SA:MP Surface To Air Missiles (SAMsites) * Version: 0.4.1 * Patch: 0.1 * (c) Copyright 2011 - 2012 by BockScar (pagie1111) * @date Jan 18 2010 * @re-distributed May 31 2011 * @webaddress http://forum.sa-mp.com/showthread.php?t=115695 * * Do not re-distribute. File is given 'AS IS' (no warranties) * * Always pay credits to authors * * The purpose of this include is to allow functionality of Surface To Air Missile launchers(SAMS) in San Andreas Multiplayer 0.3a. There is no saying that this current version(0.4.1) will work in future releases of San Andreas Multiplayer, however, future updates are a possibility. The current release of this system has an added attempt to kill the 'Dead Sam Bug'. Information about this bug can be found on the forum main post or at the bottom of this script. */ /*Configuration*/ #define MAX_SAMS 64 #define INVALID_SAM_ID 255 #define DEFAULT_MISSILE_SPEED 70.000 #define DEFAULT_SAM_RANGE 300.000 #define MISSILE_DRAG_TIME 25000 //milliseconds #define SAM_RADAR_LIMIT 15.000 #define RESTART_TIME 1800000 // 30 minutes #define RELOAD_STRING "reloadfs SamSites041" new sOBJECT[MAX_SAMS]; new resttime; new samset; enum SamS { samida, Float:SX, Float:SY, Float:SZ, Float:speed, Float:range, chaseid, Fired, }; new Sam[MAX_SAMS][SamS]; new Missile[MAX_SAMS]; new FireMissileKill[MAX_SAMS]; new FireMissileKill2[MAX_SAMS]; new DragKill[MAX_SAMS]; new Text3D:SamLabel[MAX_SAMS]; forward OnSamSiteUpdate(samid, playerid); /* natives native AddStaticSAM(Float:X, Float:Y, Float:Z, Float:srange=DEFAULT_SAM_RANGE, Float:sspeed=DEFAULT_SAM_SPEED, CSO=false, Float:rX, Float:rY, Float:zZ); native CreateSamLabel(samid, label[], color, Float:DrawDistance, LOS); native SAM_start(); */ stock AddStaticSAM(Float:X, Float:Y, Float:Z, Float:srange=DEFAULT_SAM_RANGE, Float:sspeed=DEFAULT_MISSILE_SPEED, bool:CSO=false,Float:rX=0.0, Float:rY=0.0, Float:rZ=0.0) { new samid = samset; if(samset > MAX_SAMS-1) { print("[SAM] Error - Script exceeds max limit"); samid = INVALID_SAM_ID; return samid; } samset++; Sam[samid][samida] = samid; Sam[samid][SX] = X; Sam[samid][SY] = Y; Sam[samid][SZ] = Z; Sam[samid][speed] = sspeed; Sam[samid][range] = srange; Sam[samid][chaseid] = -1; Sam[samid][Fired] = 0; if(bool:CSO == true) { sOBJECT[samid] = CreateObject(3884,X,Y,X,rX,rY,rZ); printf("[SAM] SAM %d Created - %f,%f,%f -",samid,X,Y,Z); } return samid; } stock SAM_start() { resttime = SetTimer("SamLive",500,true); SetTimer("Restart",RESTART_TIME,false); print("\n--------------------------------------"); print(" Surface To Air Missiles System Loaded"); print(" 0.4.1"); print("--------------------------------------\n"); return 1; } stock CreateSamLabel(samid, label[], color, Float:DrawDistance, LOS) { if(samid == INVALID_SAM_ID) return false; new string[128]; format(string,sizeof(string),"%s(%d)",label,samid); SamLabel[samid] = Create3DTextLabel(string,color,Sam[samid][SX],Sam[samid][SY],Sam[samid][SZ] + 2.00,DrawDistance,0,LOS); return true; } stock GetMaxSams() { return samset; } forward SamLive(); public SamLive() { for(new s = 0; s -vrange)) && ((temppos[1] < vrange) && (temppos[1] > -vrange)) && ((temppos[2] < vrange) && (temppos[2] > -vrange))) { return true; } return false; } forward Restart(); public Restart() { KillTimer(resttime); print("SAM Sites System Reloading\n"); SendRconCommand(RELOAD_STRING); return 1; } /* Dead SAM Bug This bug causes all Sam Sites to stop functionality after a duration of time. This is hopefully the last fix I need to do to this Script. */