Author Topic: Firework system  (Read 461 times)

0 Members and 1 Guest are viewing this topic.

Offline Life

  • Banned
  • *
  • Posts: 25
  • Country: fo
  • Respect: +2/-0
  • Gender: Male
  • Best Firefighter, Worker Of The Month
    • View Profile
  • MCNR name: [L]ife
  • Discord name: [L]ife#2488
Firework system
« on: March 12, 2023, 10:48:52 am »
Hello today i will be giving you a firework system.

#include <a_samp>
#include <zcmd>

#define COLOR_RED 0xFF0000FF
#define COLOR_GREEN 0x00FF00FF
#define EXPLOSION_FIREWORK 18

// Command to create a fireworks show in the player's location
CMD:fireworks(playerid)
{
    // Get the player's position
    new Float:x, Float:y, Float:z;
    GetPlayerPos(playerid, x, y, z);
   
    // Create fireworks
    for(new i = 0; i < 50; i++)
    {
        new fx = CreateExplosion(x + random(-10, 10), y + random(-10, 10), z + random(5, 50), EXPLOSION_FIREWORK, 0.0);
        SetTimerEx("DestroyFirework", 2000, false, "i", i);
    }
   
    // Send message to player
    SendClientMessage(playerid, COLOR_GREEN, "You have created a fireworks show in your location!");
    return 1;
}

// Function to destroy a firework after it explodes
public DestroyFirework(i)
{
    DestroyObject(i);
    return 1;
}

// Register the command with zcmd
public OnGameModeInit()
{
    RegisterZcmd("fireworks", "Create a fireworks show at your location.", ACCESS_PLAYER);
    return 1;
}