Am trying to make an amml system
when i press Y it says You've run out of missiles, wait a couple of seconds for 29 times;
here i create 29 vehicle and 29 objects and attach them
The key press code
On vehicle spawn AMMO should be set to that vehicle should be 4 it too set:
These are the codes.....
Please help me make it working properly...
no missile fired 29 times "You've run out of missiles, wait a couple of seconds" will be told
when i press Y it says You've run out of missiles, wait a couple of seconds for 29 times;
here i create 29 vehicle and 29 objects and attach them
PHP Code:
for (new i = 0; i != 29; ++i)
{
AttachObjectToVehicle(g_Object[i], g_Vehicle[i], 0.0000, -1.6400, 0.0000, 0.0000, 0.0000, 0.0000);
}
PHP Code:
if(PRESSING(newkeys, KEY_YES))
{
if(IsPlayerInAnyVehicle(playerid) && GetVehicleModel(GetPlayerVehicleID(playerid)) == 554)
{
new vid;
vid = GetPlayerVehicleID(playerid);
for(new j = 0; j != 29; ++j)
{
if(g_Vehicle[j])
{
if(AAAmmo[vid] > 0)
{
new Float:vX, Float:vY, Float:vZ;
new Float:X, Float:Y, Float:Z;
new Float:oX, Float:oY, Float:oZ;
new count = 0, string[113], name[MAX_PLAYER_NAME];
for(new k = 0; k != 29; ++k)
{
GetObjectPos(g_Object[k], oX, oY, oZ);
}
GetVehiclePos(vid, vX, vY, vZ);
new tname[MAX_PLAYER_NAME];
GetPlayerName(playerid, tname, sizeof(tname));
foreach(new i:Player)
{
if(IsPlayerInRangeOfPoint(i, 250, vX, vY, vZ))
{
if(IsPlayerInAnyVehicle(i))
{
new vid2;
vid2 = GetPlayerVehicleID(i);
if(GetVehicleModel(vid2) == 520 || GetVehicleModel(vid2) == 525 || GetVehicleModel(vid2) == 476 || GetVehicleModel(vid2) == 487)
{
GetPlayerName(i, name, sizeof(name));
DeletePlayer3DTextLabel(playerid, AntiAir[i]);
GetPlayerPos(i, X, Y, Z);
AAMissile = CreateObject(345, vX, vY, vZ, 0, 0, 0);
new time = MoveObject(AAMissile, X, Y, Z, 70); //abc
SetTimerEx("Detonate", time, 0, "ii", playerid, AAMissile);
GameTextForPlayer(i, "~n~~n~~n~~n~~n~~n~~n~~r~ANTI-AIR MISSILE APPROACHING", 3500, 3);
PlayerPlaySound(i,1057,0.0,0.0,0.0);
format(string, sizeof(string), "* Missile approaching %s[%d]!",name, i);
count++;
new Float:px,Float:py, Float:pAngle;
GetPlayerPos(i, px,py,pAngle);
GetAAAngle(px, py, oX, oY, pAngle);
SetObjectRot(AAObject, oX, oY, pAngle+90);
new P3String[48];
format(P3String, sizeof(P3String), "AntiAir Target: %s", name);
AntiAir[i] = CreatePlayer3DTextLabel(playerid,P3String,0x008080FF,0,0,-1,250.0, i, INVALID_VEHICLE_ID, 1);
printf("%s has pressed 'FIRE' while in the Anti-Air vehicle - %d vehicles detected", tname, count);
printf("Missile heading to %s", name);
}
}
}
}
if(count != 0)
{
SendClientMessage(playerid, COLOR_SWAG, string);
CanUseAAMissile[ playerid ] = false;
AAAmmo[vid]--;
if(AAAmmo[vid] == 0)
{
SetTimerEx("ReloadAmmo", 5500, false, "i", playerid);
}
format(string, sizeof(string), "* %d vehicles detected - Missile fired at one target!", count);
SendClientMessage(playerid, COLOR_SWAG, string);
}
else
{
SendClientMessage(playerid, COLOR_SWAG, "* 0 vehicles detected - No missiles fired!");
}
printf("%s has pressed 'FIRE' while in the Anti-Air vehicle - %d vehicles detected", tname, count);
}
else SendClientMessage(playerid, COLOR_RED, "* You've run out of missiles, wait a couple of seconds!");
}
}
}
}
PHP Code:
if(GetVehicleModel(vehicleid) == 554)
{
AAAmmo[vehicleid] = 5;
}
Please help me make it working properly...
no missile fired 29 times "You've run out of missiles, wait a couple of seconds" will be told