Код:
#include <a_samp>
#include <streamer>
// Firework System
#define RocketHeight 50
#define TYPE_COUNTDOWN 2000
#define TYPE_LAUNCH 2001
#define TYPE_EXPLODE 2002
#define MAX_FIREWORKS 100
#define FireworkSpread 30
new Rocket[MAX_PLAYERS];
new RocketLight[MAX_PLAYERS];
new RocketSmoke[MAX_PLAYERS];
forward Firework(playerid, type);
public Firework(playerid, type)
{
if(!IsPlayerConnected(playerid))
{
DestroyDynamicObject(Rocket[playerid]);
DestroyDynamicObject(RocketLight[playerid]);
DestroyDynamicObject(RocketSmoke[playerid]);
return 1;
}
new Float:x, Float:y, Float:z;
x = GetPVarFloat(playerid, "fxpos");
y = GetPVarFloat(playerid, "fypos");
z = GetPVarFloat(playerid, "fzpos");
if (type == TYPE_COUNTDOWN)
{
new string[128];
format(string, sizeof(string), "STAND BACK! 5 seconds till launch!", GetPlayerNameEx(playerid));
ProxDetector(30.0, playerid, string, COLOR_YELLOW,COLOR_YELLOW,COLOR_YELLOW,COLOR_YELLOW,COLOR_YELLOW);
SetTimerEx("Firework", 5000, 0, "ii", playerid, TYPE_LAUNCH);
}
else if(type == TYPE_LAUNCH)
{
CreateExplosion(x ,y, z, 12, 5);
new time = MoveDynamicObject(Rocket[playerid], x, y, z + RocketHeight, 10);
MoveDynamicObject(RocketLight[playerid], x, y, z + 2 + RocketHeight, 10);
MoveDynamicObject(RocketSmoke[playerid], x, y, z + RocketHeight, 10);
SetTimerEx("Firework", time, 0, "ii", playerid, TYPE_EXPLODE);
}
else if(type == TYPE_EXPLODE)
{
z += RocketHeight;
if (RocketExplosions[playerid] == 0)
{
DestroyDynamicObject(Rocket[playerid]);
DestroyDynamicObject(RocketLight[playerid]);
DestroyDynamicObject(RocketSmoke[playerid]);
CreateExplosion(x ,y, z, 4, 10);
CreateExplosion(x ,y, z, 5, 10);
CreateExplosion(x ,y, z, 6, 10);
}
else if (RocketExplosions[playerid] >= MAX_FIREWORKS)
{
for (new i = 0; i <= FireworkSpread; i++)
{
CreateExplosion(x + float(i - (FireworkSpread / 2)), y, z, 7, 10);
CreateExplosion(x, y + float(i - (FireworkSpread / 2)), z, 7, 10);
CreateExplosion(x, y, z + float(i - (FireworkSpread / 2)), 7, 10);
}
RocketExplosions[playerid] = -1;
return 1;
}
else
{
x += float(random(FireworkSpread) - (FireworkSpread / 2));
y += float(random(FireworkSpread) - (FireworkSpread / 2));
z += float(random(FireworkSpread) - (FireworkSpread / 2));
CreateExplosion(x, y, z, 7, 10);
}
RocketExplosions[playerid]++;
SetTimerEx("Firework", 250, 0, "ii", playerid, TYPE_EXPLODE);
}
return 1;
}
CMD:placefirework(playerid, params[])
{
if(GetPVarInt(playerid, "IsInArena") >= 0)
{
SendClientMessageEx(playerid, COLOR_WHITE, "You can't do this while being in an arena!");
return 1;
}
if(WatchingTV[playerid] != 0) {
SendClientMessageEx(playerid, COLOR_GREY, "You can not do this while watching TV!");
return 1;
}
if(GetPVarInt(playerid, "Injured") == 1 || PlayerInfo[playerid][pHospital] == 1 || IsPlayerInAnyVehicle(playerid))
{
SendClientMessageEx(playerid, COLOR_WHITE, "You can't do this right now.");
return 1;
}
if(RocketExplosions[playerid] != -1)
{
SendClientMessageEx(playerid, COLOR_WHITE, "You are already using another firework!");
return 1;
}
if (PlayerInfo[playerid][pVW] != 0 || PlayerInfo[playerid][pInt] != 0)
{
SendClientMessageEx(playerid, COLOR_WHITE, "You can't launch fireworks indoors!");
return 1;
}
if(PlayerInfo[playerid][pAdmin] >= 1337)
{
new string[128];
format(string, sizeof(string), "%s has placed a firework which will go off in 30 seconds!", GetPlayerNameEx(playerid));
ProxDetector(30.0, playerid, string, COLOR_YELLOW,COLOR_YELLOW,COLOR_YELLOW,COLOR_YELLOW,COLOR_YELLOW);
new Float:x, Float:y, Float:z, Float:a;
GetPlayerPos(playerid, x, y, z);
GetPlayerFacingAngle(playerid, a);
ApplyAnimation(playerid,"BOMBER","BOM_Plant_Crouch_In", 4.0, 0, 0, 0, 0, 0, 1);
x += (2 * floatsin(-a, degrees));
y += (2 * floatcos(-a, degrees));
Rocket[playerid] = CreateDynamicObject(3786, x, y, z, 0, 90, 0);
RocketLight[playerid] = CreateDynamicObject(354, x, y, z + 1, 0, 0, 0);
RocketSmoke[playerid] = CreateDynamicObject(18716, x, y, z - 4, 0, 0, 0);
SetPVarFloat(playerid,"fxpos",x);
SetPVarFloat(playerid,"fypos",y);
SetPVarFloat(playerid,"fzpos",z);
RocketExplosions[playerid] = 0;
SetTimerEx("Firework", 25000, 0, "ii", playerid, TYPE_COUNTDOWN);
}
else
{
SendClientMessageEx(playerid, COLOR_GRAD1, "You arent authorized to use this command!");
}
return 1;
}
CMD:clearfirework(playerid, params[])
{
if(PlayerInfo[playerid][pAdmin] < 1337) return SendClientMessageEx(playerid, COLOR_GREY, "You are not authorized to use this command!");
new giveplayerid;
if(sscanf(params, "i", giveplayerid)) return Syntax(playerid, "clearfirework", "[playerid]");
if(!IsPlayerConnected(giveplayerid)) return Error(playerid, "That player is not online!");
if(RocketExplosions[giveplayerid] == 1 || RocketExplosions[giveplayerid] == 0)
{
RocketExplosions[giveplayerid] = -1;
}
return 1;
}