07.11.2013, 15:59
(
Последний раз редактировалось HolyScripter; 08.11.2013 в 14:32.
)
Hello i want to show you how to creating Firework system use rocket
there's no bug iam using this script too ,
if you like it you can use it ,
Correct me if i wrong okey ?
define for the script
its new for the variable for firework
after that we must create the variable for firework
for the command, the command is will place the firework and launch the firework , the firework is creating object with rocket , this as your command you can change it to strcmp dcmd ycmd and more
sorry for my bad english i just give a tutorial , you must edit it with your own variable, you can copy and paste mine too there's no bug , if you like it please give me rep ,
edited detailed tutorial
there's no bug iam using this script too ,
if you like it you can use it ,
Correct me if i wrong okey ?
define for the script
pawn Код:
// Define
#define RocketHeight 50//Height Firework
#define RocketSpread 30//
#define MAX_LAUNCH 30//Max Launch on 1 time
#define MAX_FIREWORKS 500 //Max Firework
pawn Код:
// New Firework
new Rocket[MAX_LAUNCH];//Max Firework
new RocketLight[MAX_LAUNCH];//Firework light
new RocketSmoke[MAX_LAUNCH];//Firework smoke
new RocketExplosions[MAX_LAUNCH];//Explosions on firework
new Float:Frx[MAX_LAUNCH];//Float X
new Float:Fry[MAX_LAUNCH];//Float Y
new Float:Frz[MAX_LAUNCH];//Float Z
new FireworkTotal;// Total Firework
new Fired;// If firework launched
pawn Код:
// Variable of firework this variable will destroy object if object already on the sky and make explosions
forward Firework(i);
public Firework(i)
{
new Float:x, Float:y, Float:z;
x = Frx[i];
y = Fry[i];
z = Frz[i];
z += RocketHeight;
if (RocketExplosions[i] == 0)
{
DestroyDynamicObject(Rocket[i]);//It Will Create The Rocket
DestroyDynamicObject(RocketLight[i]);//It Will Create The Light For The Rocket
DestroyDynamicObject(RocketSmoke[i]);// And This for the smoke
CreateExplosion(x ,y, z, 4, 10);
CreateExplosion(x ,y, z, 5, 10);
CreateExplosion(x ,y, z, 6, 10);
}
else if (RocketExplosions[i] >= MAX_FIREWORKS)
{
for (new j = 0; j <= RocketSpread; j++)
{
CreateExplosion(x + float(j - (RocketSpread / 2)), y, z, 7, 10);// Its for the explosions
CreateExplosion(x, y + float(j - (RocketSpread / 2)), z, 7, 10);//Same
CreateExplosion(x, y, z + float(j - (RocketSpread / 2)), 7, 10);//Same
}
RocketExplosions[i] = -1;
FireworkTotal = 0;//Make Firework back to 0
Fired = 0;//Make Fired back to 0
return 1;
}
else
{
x += float(random(RocketSpread) - (RocketSpread / 2));//Random Explosions
y += float(random(RocketSpread) - (RocketSpread / 2));//Random Explosions
z += float(random(RocketSpread) - (RocketSpread / 2));//Random Explosions
CreateExplosion(x, y, z, 7, 10);
}
RocketExplosions[i]++;//Make Explosions
SetTimerEx("Firework", 250, 0, "i", i);//Timer For Explosions
return 1;
}
pawn Код:
CMD:firework(playerid, params[])
{
if(isnull(params))
{
SendClientMessage(playerid, COLOR_WHITE, "USAGE: /firework [name]");//SCM
SendClientMessage(playerid, COLOR_GREY, "place , launch");//SCM
return 1;
}
if(strcmp(params, "place", true) == 0 )//it will detect if you type place
{
if(FireworkTotal == MAX_LAUNCH)//will detect if firework is reach maximum firework
{
SendClientMessage(playerid, COLOR_WHITE, "You have reached maximum number of fireworks!");
return 1;
}
if(Fired == 1)//Will detect if firework on explosions
{
SendClientMessage(playerid, COLOR_WHITE, "Wait till your fireworks are done before placing new ones!");
return 1;
}
new string[128];
format(string, sizeof(string), "%s has placed a special firework.", GetPlayerNameEx(playerid));
new Float:x, Float:y, Float:z, Float:a;
GetPlayerPos(playerid, x, y, z);
foreach(Player, i)
{
if(IsPlayerInRangeOfPoint(i, 30, x, y, z)) {
SendClientMessage(i, COLOR_YELLOW, string);
}
}
GetPlayerFacingAngle(playerid, a);
x += (2 * floatsin(-a, degrees));
y += (2 * floatcos(-a, degrees));
Rocket[FireworkTotal] = CreateDynamicObject(3786, x, y, z, 0, 90, 0);//Just creating rocket
RocketLight[FireworkTotal] = CreateDynamicObject(354, x, y, z + 1, 0, 90, 0);//Creating Firework light
RocketSmoke[FireworkTotal] = CreateDynamicObject(18716, x, y, z - 4, 0, 0, 0);//Creating firework smoke
Frx[FireworkTotal] = x;
Fry[FireworkTotal] = y;
Frz[FireworkTotal] = z;
RocketExplosions[FireworkTotal] = 0;
FireworkTotal++;
}
else if(strcmp(params, "launch", true) == 0 )
{
if(FireworkTotal == 0)
{
SendClientMessage(playerid, COLOR_WHITE, "You dont have any fireworks!");
return 1;
}
if(Fired == 1)
{
SendClientMessage(playerid, COLOR_WHITE, "You have already fired your fireworks!");
return 1;
}
for(new i = 0; i < FireworkTotal; i++)
{
CreateExplosion(Frx[i] ,Fry[i], Frz[i], 12, 5);
new time = MoveDynamicObject(Rocket[i], Frx[i] ,Fry[i], Frz[i] + RocketHeight, 10);// Move The object to the skys
MoveDynamicObject(RocketLight[i], Frx[i] ,Fry[i], Frz[i] + 2 + RocketHeight, 10);//Same
MoveDynamicObject(RocketSmoke[i], Frx[i] ,Fry[i], Frz[i] + RocketHeight, 10);//Same
SetTimerEx("Firework", time, 0, "i", i);
}
Fired = 1;
}
return 1;
}
edited detailed tutorial