From 02eb8528418eb1572e772c88402b8d6bda3e6358 Mon Sep 17 00:00:00 2001 From: Lorenc Date: Wed, 21 Mar 2018 07:46:02 +1100 Subject: [PATCH] fireworks replacement --- .../features/visage/fireworks.inc | 1452 ++++++++++++----- pawno/include/irresistible/helpers.inc | 5 +- pawno/include/irresistible/main.inc | 3 +- 3 files changed, 1095 insertions(+), 365 deletions(-) diff --git a/pawno/include/irresistible/features/visage/fireworks.inc b/pawno/include/irresistible/features/visage/fireworks.inc index 4134691..4719f40 100644 --- a/pawno/include/irresistible/features/visage/fireworks.inc +++ b/pawno/include/irresistible/features/visage/fireworks.inc @@ -1,424 +1,1150 @@ - /* * Irresistible Gaming (c) 2018 - * Developed by ThreeKingz, edited by Lorenc Pekaj + * Developed by Basssiiie edited by Lorenc Pekaj * Module: fireworks.inc - * Purpose: mathematical fireworks implementation in-game + * Purpose: implements fireworks into sa-mp */ -/* ** Defines ** */ -#define MAX_FIREWORKS 40 -#define FW_MAX_FLARES_PER_LAUNCH 100 -#define FW_TICK_RATE 50 //in milliseconds -#define FW_INVALID_HANDLE -1 -#define FW_VISIBLE_RANGE 500.0 //Drawdistance for the flare objects. -#define FW_EXPLOSION_TYPE 9 -#define FW_EXPLOSION_RANGE 300.0 +/* ** Includes ** */ +#include < YSI\y_hooks > -/* - Exceeding in ranges, tick rates or number of flares could cause the ackslimit to be broken - freezing the server. -*/ +/* ** Definitions ** */ +#define DIALOG_FIREWORKS 29383 +#define DIALOG_FIREWORKS_COLOR 29385 -#define STYLE_AR_SPIRAL ( 0 ) -#define STYLE_FOUNTAIN ( 1 ) -#define STYLE_CIRCLE ( 2 ) +// The maximum amount of firework instances that players can place, per server. (Default: 20) +#define MAX_FIREWORK 20 + +// The maximum amount of particle objects that can be spawned per firework instance. (Default: 75) +#define MAX_FWOBJECT 75 + +// This defines how long the fireworks will stay around before it gets destroyed, after it's finished firing all its rounds. +#define DEF_STAY_TIME 10000 + +// Firework types +#define FW_UNKNOWN 0 +#define FW_FOUNTAIN 1 +#define FW_ROCKET 2 +#define FW_SPLITTER 3 +#define FW_UMBRELLA 4 +#define FW_CAKE 5 + +#define DEF_ANIM_TIME 2500 +#define DEF_DELAY_FIRE 250 + +// Fountain defines +#define FOUNTAIN_LIFE 10000 +#define FOUNTAIN_DELAY 200 + +// Rocket defines +#define ROCKET_DUPLICATES 25 +#define ROCKET_DELAY 1000 + +// Splitter defines +#define SPLITTER_DUPLICATE_1 7 +#define SPLITTER_DUPLICATE_2 10 +#define SPLITTER_DELAY 1000 + +// Umbrella defines +#define UMBRELLA_DUPLICATES 30 +#define UMBRELLA_DELAY 1000 + +// Cake defines +#define CAKE_DUPLICATES 10 +#define CAKE_DELAY 500 +#define CAKE_SINGLE_DELAY 500 +#define CAKE_BIG_DELAY 2500 /* ** Variables ** */ -enum FW_Stages +enum E_FIREWORK_DATA { - FW_S_CREATE_FLARES, - FW_S_MOVE_FLARES + E_CREATOR, E_TYPE, E_LIFETIME, + E_STAGE, E_ATTACHED_VEH, E_COLORS[ 2 ] }; -enum FW_subscripts -{ - bool: FW_IS_FLARE_MOVING[ FW_MAX_FLARES_PER_LAUNCH ], - Float: FW_FLARE_TIME_ELAPSED[ FW_MAX_FLARES_PER_LAUNCH ], - FW_FLARE_OBJECT_ID[ FW_MAX_FLARES_PER_LAUNCH ], +new FW_DATA [ MAX_FIREWORK ] [ E_FIREWORK_DATA ]; +new FW_Object [ MAX_FIREWORK ] [ MAX_FWOBJECT ] [ 2 ]; +new Iterator: fireworks < MAX_FIREWORK >; - Float: FW_ORIGIN_X, Float: FW_ORIGIN_Y, Float: FW_ORIGIN_Z, - Float: FW_ELEVATION_ANGLE, Float: FW_INITIAL_SPEED, Float: FW_GLOBAL_TIME_ELAPSED, - - Float: FW_MAX_HEIGHT, Float: FW_GRAVITY, Float: FW_FL_TIME_DELAY, - - // for spiral only - Float: FW_INCREMENT, Float: FW_CONSTANT_XY, Float: FW_CONSTANT_Z, - - FW_STYLE, FW_Stages: FW_CURRENT_STAGE, - - FW_OBJECT_DESTROYED_COUNT, FW_OBJECT_SPAWNED_COUNT, FW_TIMER_ID, - FW_TOTAL_FLARE_OBJECTS, FW_FL_TIME_DELAY_COUNT, FW_FL_TIME_DELAY_RESULT -}; - -new - FW_Data[MAX_FIREWORKS] [FW_subscripts], - Iterator:fireworks -; - -/* ** Functions ** */ -stock ResetFirework(handle) -{ - if(handle >= MAX_FIREWORKS) - return false; - - // if(!Iter_Contains(fireworks, handle)) - // return false; - - FW_Data[handle][FW_ORIGIN_X] = 0.0; - FW_Data[handle][FW_ORIGIN_Y] = 0.0; - FW_Data[handle][FW_ORIGIN_Z] = 0.0; - FW_Data[handle][FW_ELEVATION_ANGLE] = 0.0; - FW_Data[handle][FW_GRAVITY] = 0.0; - FW_Data[handle][FW_INITIAL_SPEED] = 0.0; - FW_Data[handle][FW_MAX_HEIGHT] = 0.0; - FW_Data[handle][FW_FL_TIME_DELAY] = 0.0; - FW_Data[handle][FW_CONSTANT_Z] = 0.0; - FW_Data[handle][FW_CONSTANT_XY] = 0.0; - FW_Data[handle][FW_INCREMENT] = 0.0; - FW_Data[handle][FW_TOTAL_FLARE_OBJECTS] = 0; - FW_Data[handle][FW_GLOBAL_TIME_ELAPSED] = 0; - - FW_Data[handle][FW_OBJECT_DESTROYED_COUNT] = 0; - FW_Data[handle][FW_OBJECT_SPAWNED_COUNT] = 0; - FW_Data[handle][FW_FL_TIME_DELAY_COUNT] = 0; - FW_Data[handle][FW_FL_TIME_DELAY_RESULT] = 0; - FW_Data[handle][FW_CURRENT_STAGE] = FW_S_CREATE_FLARES; - - for(new i = 0; i < FW_MAX_FLARES_PER_LAUNCH; i++) - { - FW_Data[handle][FW_IS_FLARE_MOVING][i] = false; - FW_Data[handle][FW_FLARE_TIME_ELAPSED][i] = 0; - DestroyDynamicObject(FW_Data[handle][FW_FLARE_OBJECT_ID][i]); - FW_Data[handle][FW_FLARE_OBJECT_ID][i] = INVALID_OBJECT_ID; +/* ** Hooks ** */ +hook OnPlayerDisconnect(playerid, reason) { + if (GetPVarInt(playerid, "FireworkPlaced")) { + foreach (new fw : fireworks) if ( FW_DATA[ fw ] [ E_CREATOR ] == playerid && FW_DATA[ fw ] [ E_STAGE ] ) { + FW_MainDestroy( fw ); + } } - - KillTimer(FW_Data[handle][FW_TIMER_ID]); - FW_Data[handle][FW_TIMER_ID] = 0; - Iter_Remove(fireworks, handle); return 1; } -stock CreateFireworks(total_flares, style, Float:origin_x, Float:origin_y, Float:origin_z, Float:angle, Float:speed, Float:gravity, Float:time_delay, Float:max_height = 50.0, Float:increment = 12.0, Float:constant_xy = 10.0, Float:constant_z = 2.0) +hook OnDialogResponse( playerid, dialogid, response, listitem, inputtext[ ] ) { - new handle = Iter_Free(fireworks); - if(handle == FW_INVALID_HANDLE) + if (dialogid == DIALOG_FIREWORKS) { - printf("[Fireworks] Max number of concurrent 'firework' handles has been reached. Increase MAX_FIREWORKS."); - return FW_INVALID_HANDLE; - } - if(total_flares >= FW_MAX_FLARES_PER_LAUNCH) - { - printf("[Fireworks] The total number of flares is greater than the allowed limit. Current limit is: "#FW_MAX_FLARES_PER_LAUNCH""); - return FW_INVALID_HANDLE; - } - //Resetting: - FW_Data[handle][FW_TOTAL_FLARE_OBJECTS] = 0; - FW_Data[handle][FW_GLOBAL_TIME_ELAPSED] = 0; - FW_Data[handle][FW_OBJECT_DESTROYED_COUNT] = 0; - FW_Data[handle][FW_OBJECT_SPAWNED_COUNT] = 0; - FW_Data[handle][FW_FL_TIME_DELAY_COUNT] = 0; - - FW_Data[handle][FW_CURRENT_STAGE] = FW_S_CREATE_FLARES; - for(new i = 0; i < FW_MAX_FLARES_PER_LAUNCH; i++) - { - FW_Data[handle][FW_IS_FLARE_MOVING][i] = false; - FW_Data[handle][FW_FLARE_TIME_ELAPSED][i] = 0; - FW_Data[handle][FW_FLARE_OBJECT_ID][i] = INVALID_OBJECT_ID; - } - - FW_Data[handle][FW_ORIGIN_X] = origin_x; - FW_Data[handle][FW_ORIGIN_Y] = origin_y; - FW_Data[handle][FW_ORIGIN_Z] = origin_z; - - FW_Data[handle][FW_CONSTANT_Z] = constant_z; - FW_Data[handle][FW_CONSTANT_XY] = constant_xy; - FW_Data[handle][FW_INCREMENT] = increment; - - FW_Data[handle][FW_ELEVATION_ANGLE] = angle; - FW_Data[handle][FW_GRAVITY] = gravity; - FW_Data[handle][FW_INITIAL_SPEED] = speed; - FW_Data[handle][FW_MAX_HEIGHT] = max_height; - FW_Data[handle][FW_FL_TIME_DELAY] = time_delay; - FW_Data[handle][FW_FL_TIME_DELAY_RESULT] = floatround(floatdiv(time_delay, 0.001 * FW_TICK_RATE)); - FW_Data[handle][FW_STYLE] = style; - FW_Data[handle][FW_TOTAL_FLARE_OBJECTS] = total_flares; - Iter_Add(fireworks, handle); - return handle; -} - -stock LaunchFireworks(handle) -{ - if(handle >= MAX_FIREWORKS) - { - printf("[Fireworks] An incorrect value was passed as a handle. (%d). (LaunchFireworks).", _:handle); - return 0; - } - if(!Iter_Contains(fireworks, handle)) - { - print("[Fireworks] An incorrect value was passed as a handle. CreateFirework must be used first."); - return 0; - } - FW_Data[handle][FW_CURRENT_STAGE] = FW_S_CREATE_FLARES; - FW_Data[handle][FW_TIMER_ID] = SetTimerEx("FW_UpdateTick", FW_TICK_RATE, true, "i", _:handle); - return 1; -} - -forward FW_UpdateTick(handle); public FW_UpdateTick(handle) -{ - switch(FW_Data[handle][FW_STYLE]) - { - case STYLE_AR_SPIRAL: + switch ( listitem ) { - switch(FW_Data[handle][FW_CURRENT_STAGE]) + case 0: { - case FW_S_CREATE_FLARES: - { - new object_model = 0; - new const total = FW_Data[handle][FW_TOTAL_FLARE_OBJECTS]; - for(new i = 0; i < total; i++) - { - switch(i & 3) //Same as i % 4 but faster. - { - case 0: object_model = 19297; - case 1: object_model = 19298; - case 2: object_model = 19296; - case 3: object_model = 19295; - } - FW_Data[handle][FW_FLARE_OBJECT_ID][i] = CreateDynamicObject(object_model, FW_Data[handle][FW_ORIGIN_X], FW_Data[handle][FW_ORIGIN_Y], FW_Data[handle][FW_ORIGIN_Z], 0.0, 0.0, 0.0, -1, -1, -1, FW_VISIBLE_RANGE); - FW_Data[handle][FW_FLARE_TIME_ELAPSED][i] = 0; - FW_Data[handle][FW_IS_FLARE_MOVING][i] = false; - } - FW_Data[handle][FW_CURRENT_STAGE] = FW_S_MOVE_FLARES; - } - case FW_S_MOVE_FLARES: - { - new index = 0; - new Float:p_constant_xy = FW_Data[handle][FW_CONSTANT_XY]; - new const Float:p_constant_z = FW_Data[handle][FW_CONSTANT_Z]; - new const Float:increment = FW_Data[handle][FW_INCREMENT]; + SetPVarInt(playerid, "FW_ColorsNumber", 2); + SetPVarInt(playerid, "FW_MenuItem", FW_FOUNTAIN); + ShowPlayerDialog( playerid, DIALOG_FIREWORKS_COLOR, DIALOG_STYLE_LIST, ""COL_WHITE"Fireworks", "White\nRed\nGreen\nBlue", "Select", "Back" ); + } + case 1: + { + SetPVarInt(playerid, "FW_ColorsNumber", 2); + SetPVarInt(playerid, "FW_MenuItem", FW_ROCKET); + ShowPlayerDialog( playerid, DIALOG_FIREWORKS_COLOR, DIALOG_STYLE_LIST, ""COL_WHITE"Fireworks", "White\nRed\nGreen\nBlue", "Select", "Back" ); + } + case 2: + { + SetPVarInt(playerid, "FW_ColorsNumber", 2); + SetPVarInt(playerid, "FW_MenuItem", FW_SPLITTER); + ShowPlayerDialog( playerid, DIALOG_FIREWORKS_COLOR, DIALOG_STYLE_LIST, ""COL_WHITE"Fireworks", "White\nRed\nGreen\nBlue", "Select", "Back" ); + } + case 3: + { + SetPVarInt(playerid, "FW_ColorsNumber", 2); + SetPVarInt(playerid, "FW_MenuItem", FW_UMBRELLA); + ShowPlayerDialog( playerid, DIALOG_FIREWORKS_COLOR, DIALOG_STYLE_LIST, ""COL_WHITE"Fireworks", "White\nRed\nGreen\nBlue", "Select", "Back" ); + } + case 4: + { + SetPVarInt(playerid, "FW_ColorsNumber", 2); + SetPVarInt(playerid, "FW_MenuItem", FW_CAKE); + ShowPlayerDialog( playerid, DIALOG_FIREWORKS_COLOR, DIALOG_STYLE_LIST, ""COL_WHITE"Fireworks", "White\nRed\nGreen\nBlue", "Select", "Back" ); + } + } + return 1; + } + else if ( dialogid == DIALOG_FIREWORKS_COLOR ) + { + if ( ! response ) + { + DeletePVar(playerid, "FW_Color1"); + DeletePVar(playerid, "FW_Color2"); + DeletePVar(playerid, "FW_MenuItem"); + DeletePVar(playerid, "FW_ColorsNumber"); + DeletePVar(playerid, "FW_Big"); + return 1; + } - new const Float:test_expression_value = float(FW_Data[handle][FW_TOTAL_FLARE_OBJECTS]) * increment; - if(FW_Data[handle][FW_OBJECT_SPAWNED_COUNT] != FW_Data[handle][FW_TOTAL_FLARE_OBJECTS]) + if (!GetPVarInt(playerid, "FW_Color1") && !GetPVarInt(playerid, "FW_Color2")) + { + switch (listitem) + { + case 0: SetPVarInt(playerid, "FW_Color1", 19295); // Wit + case 1: SetPVarInt(playerid, "FW_Color1", 19296); // Rood + case 2: SetPVarInt(playerid, "FW_Color1", 19297); // Groen + case 3: SetPVarInt(playerid, "FW_Color1", 19298); // Blauw + } + if (GetPVarInt(playerid, "FW_ColorsNumber") == 1) + { + FW_MainCreate(playerid, GetPVarInt(playerid, "FW_MenuItem")); + return 1; + } + SendServerMessage( playerid, "Please select the primary color for your firework." ); + ShowPlayerDialog( playerid, DIALOG_FIREWORKS_COLOR, DIALOG_STYLE_LIST, ""COL_WHITE"Fireworks", "White\nRed\nGreen\nBlue", "Select", "Back" ); + return 1; + } + if (GetPVarInt(playerid, "FW_Color1") > 1 && !GetPVarInt(playerid, "FW_Color2")) + { + switch (listitem) + { + case 0: SetPVarInt(playerid, "FW_Color2", 19295); + case 1: SetPVarInt(playerid, "FW_Color2", 19296); + case 2: SetPVarInt(playerid, "FW_Color2", 19297); + case 3: SetPVarInt(playerid, "FW_Color2", 19298); + } + SendServerMessage( playerid, "Please select the secondary color of your firework." ); + FW_MainCreate(playerid, GetPVarInt(playerid, "FW_MenuItem")); + DeletePVar(playerid, "FW_MenuItem"); + DeletePVar(playerid, "FW_ColorsNumber"); + return 1; + } + } + return 1; +} + +hook OnPlayerKeyStateChange(playerid, newkeys, oldkeys) +{ + if (newkeys & KEY_FIRE && !(oldkeys & KEY_FIRE)) + { + if(GetPlayerWeapon(playerid) == 40 || GetPVarInt(playerid, "Detonator") == 1) + { + if (GetPVarInt(playerid, "FireworkPlaced") == 1) + { + RemoveWeaponFromSlot(playerid, 12); + DeletePVar(playerid, "FireworkPlaced"); + SetPVarInt(playerid, "TimerMainFire", SetTimerEx("FW_MainFire", DEF_DELAY_FIRE, true, "i", playerid)); + return 1; + } + } + } + return 1; +} + +hook OnPlayerUpdate(playerid) +{ + if (GetPlayerWeapon(playerid) == 40) + { + if (GetPVarInt(playerid, "Detonator") != 1) + { + SetPVarInt(playerid, "Detonator", 1); + } + } + else if (GetPVarInt(playerid, "Detonator") == 1) + { + DeletePVar(playerid, "Detonator"); + } + return 1; +} + +hook OnDynamicObjectMoved(objectid) +{ + foreach ( new fw : fireworks ) + { + if (FW_DATA[ fw ] [ E_TYPE ] != FW_UNKNOWN) + { + for (new fo; fo != MAX_FWOBJECT; fo++) + { + if (FW_Object[fw][fo][0] == objectid) + { + switch(FW_DATA[ fw ] [ E_TYPE ]) { - if(FW_Data[handle][FW_FL_TIME_DELAY_COUNT] == FW_Data[handle][FW_FL_TIME_DELAY_RESULT]) + case FW_FOUNTAIN: { - new i = FW_Data[handle][FW_OBJECT_SPAWNED_COUNT]; - FW_Data[handle][FW_IS_FLARE_MOVING][i] = true; - FW_Data[handle][FW_FL_TIME_DELAY_COUNT] = 0; - FW_Data[handle][FW_OBJECT_SPAWNED_COUNT]++; - } - } - for(new Float:i = 0; i < test_expression_value; i+=increment) - { - if(!IsValidDynamicObject(FW_Data[handle][FW_FLARE_OBJECT_ID][index])) continue; - if(!FW_Data[handle][FW_IS_FLARE_MOVING][index]) continue; - new Float:xpos = p_constant_xy * (i/180.0) * floatcos(floatdiv(i, 30.0)) - 30.0 + FW_Data[handle][FW_ORIGIN_X]; - new Float:ypos = p_constant_xy * (i/180.0) * floatsin(floatdiv(i, 30.0)) - 30.0 + FW_Data[handle][FW_ORIGIN_Y]; - new Float:zpos = p_constant_z * (i / 180.0) + FW_Data[handle][FW_MAX_HEIGHT]; - MoveDynamicObject(FW_Data[handle][FW_FLARE_OBJECT_ID][index], xpos, ypos, zpos, FW_Data[handle][FW_INITIAL_SPEED], 0.0, 0.0, 0.0); - index++; - } - new Float:ct = (FW_Data[handle][FW_FL_TIME_DELAY] * FW_Data[handle][FW_TOTAL_FLARE_OBJECTS]);//An approximate - if(FW_Data[handle][FW_GLOBAL_TIME_ELAPSED] >= ct) - { - new cur = 1; - new total = FW_Data[handle][FW_TOTAL_FLARE_OBJECTS]; - for(new i = 0; i < total; i++) - { - new Float:Pos[3]; - GetDynamicObjectPos(FW_Data[handle][FW_FLARE_OBJECT_ID][i], Pos[0], Pos[1], Pos[2]); - if(total % cur == 0) + switch (FW_Object[fw][fo][1]) { - CreateExplosion(Pos[0], Pos[1], Pos[2], FW_EXPLOSION_TYPE, FW_EXPLOSION_RANGE); + case 1: + { + new Float: fwX, Float: fwY, Float: fwZ; + GetDynamicObjectPos(FW_Object[fw][fo][0], fwX, fwY, fwZ); + MoveDynamicObject(FW_Object[fw][fo][0], fwX, fwY, fwZ-10.0, 2.0+float(random(3))); + FW_Object[fw][fo][1] = 2; + } + case 2: DestroyDynamicObject(FW_Object[fw][fo][0]), FW_Object[fw][fo][0] = 0, FW_Object[fw][fo][1] = 0; } - DestroyDynamicObject(FW_Data[handle][FW_FLARE_OBJECT_ID][i]); - cur++; + return 1; } - ResetFirework(handle); - } - } - } - } - - case STYLE_FOUNTAIN: - { - switch(FW_Data[handle][FW_CURRENT_STAGE]) - { - case FW_S_CREATE_FLARES: - { - new object_model = 0; - FW_Data[handle][FW_ORIGIN_Z] -= 3.0; - for(new i = 0; i < FW_Data[handle][FW_TOTAL_FLARE_OBJECTS]; i++) - { - switch(i % 4) + case FW_ROCKET: { - case 0: object_model = 19297; - case 1: object_model = 19298; - case 2: object_model = 19296; - case 3: object_model = 19295; + switch (FW_Object[fw][fo][1]) + { + case 1: + { + new Float: fwX, Float: fwY, Float: fwZ, stage; + for (new prt; prt != ROCKET_DUPLICATES; prt++) + { + for (new fo2; fo2 != MAX_FWOBJECT; fo2++) + { + if (FW_Object[fw][fo2][0] == 0) + { + new model; + switch (stage) + { + case 0: {model = FW_DATA[ fw ] [ E_COLORS ][0]; stage = 1;} + case 1: {model = FW_DATA[ fw ] [ E_COLORS ][1]; stage = 0;} + } + GetDynamicObjectPos(objectid, fwX, fwY, fwZ); + FW_Object[fw][fo2][0] = CreateDynamicObject(model, fwX, fwY, fwZ, 0.0, 0.0, 0.0, -1, 0, -1, 300.0); + Get3DRandomDistanceAway(fwX, fwY, fwZ, 15, 30); + MoveDynamicObject(FW_Object[fw][fo2][0], fwX, fwY, fwZ, 10.0+(float(random(20))/10.0)); + FW_Object[fw][fo2][1] = 2; + break; + } + } + } + + for (new i = 0, mp = GetPlayerPoolSize(); i <= mp; i++) + { + if(IsPlayerInRangeOfPoint(i,50,fwX, fwY, fwZ)) + { + PlayerPlaySound(i, 1009, 0, 0, 0); + } + } + + DestroyDynamicObject(FW_Object[fw][fo][0]); + FW_Object[fw][fo][0] = 0; + FW_Object[fw][fo][1] = 0; + UpdateStreamerForAll(); + return 1; + } + case 2: + { + DestroyDynamicObject(FW_Object[fw][fo][0]); + FW_Object[fw][fo][0] = 0; + FW_Object[fw][fo][1] = 0; + } + } + return 1; } - FW_Data[handle][FW_FLARE_OBJECT_ID][i] = CreateDynamicObject(object_model, FW_Data[handle][FW_ORIGIN_X], FW_Data[handle][FW_ORIGIN_Y], FW_Data[handle][FW_ORIGIN_Z], 0.0, 0.0, 0.0, -1, -1, -1, FW_VISIBLE_RANGE); - FW_Data[handle][FW_FLARE_TIME_ELAPSED][i] = 0; - FW_Data[handle][FW_IS_FLARE_MOVING][i] = false; - } - FW_Data[handle][FW_CURRENT_STAGE] = FW_S_MOVE_FLARES; - new const Float:vi_z = FW_Data[handle][FW_INITIAL_SPEED] * floatsin(FW_Data[handle][FW_ELEVATION_ANGLE], degrees); - FW_Data[handle][FW_MAX_HEIGHT] = floatdiv((vi_z*vi_z), 2.0 * FW_Data[handle][FW_GRAVITY]) + FW_Data[handle][FW_ORIGIN_Z]; - } - case FW_S_MOVE_FLARES: - { - if(FW_Data[handle][FW_OBJECT_DESTROYED_COUNT] >= FW_Data[handle][FW_TOTAL_FLARE_OBJECTS]) - { - ResetFirework(handle); - return 0; - } - - new const Float:elevation_angle = FW_Data[handle][FW_ELEVATION_ANGLE]; - new const Float:vi_z = FW_Data[handle][FW_INITIAL_SPEED] * floatsin(FW_Data[handle][FW_ELEVATION_ANGLE], degrees); - new const Float:gravity = FW_Data[handle][FW_GRAVITY]; - new const total_flares = FW_Data[handle][FW_TOTAL_FLARE_OBJECTS]; - - if(FW_Data[handle][FW_OBJECT_SPAWNED_COUNT] != total_flares) - { - if(FW_Data[handle][FW_FL_TIME_DELAY_COUNT] == FW_Data[handle][FW_FL_TIME_DELAY_RESULT]) + case FW_SPLITTER: { - new i = FW_Data[handle][FW_OBJECT_SPAWNED_COUNT]; - FW_Data[handle][FW_IS_FLARE_MOVING][i] = true; - FW_Data[handle][FW_FL_TIME_DELAY_COUNT] = 0; - FW_Data[handle][FW_OBJECT_SPAWNED_COUNT]++; + switch (FW_Object[fw][fo][1]) + { + case 1: + { + new Float: fwX, Float: fwY, Float: fwZ; + for (new prt; prt != SPLITTER_DUPLICATE_1; prt++) + { + for (new fo2; fo2 != MAX_FWOBJECT; fo2++) + { + if (FW_Object[fw][fo2][0] == 0) + { + GetDynamicObjectPos(objectid, fwX, fwY, fwZ); + FW_Object[fw][fo2][0] = CreateDynamicObject(FW_DATA[ fw ] [ E_COLORS ][0], fwX, fwY, fwZ, 0.0, 0.0, 0.0, -1, 0, -1, 300.0); + Get3DRandomDistanceAway(fwX, fwY, fwZ, 20, 40); + MoveDynamicObject(FW_Object[fw][fo2][0], fwX, fwY, fwZ, 10.0+(float(random(20))/10.0)); + FW_Object[fw][fo2][1] = 2; + break; + } + } + } + + for (new i = 0, mp = GetPlayerPoolSize(); i <= mp; i++) + { + if(IsPlayerInRangeOfPoint(i,50,fwX, fwY, fwZ)) + { + PlayerPlaySound(i, 1009, 0, 0, 0); + } + } + + DestroyDynamicObject(FW_Object[fw][fo][0]); + FW_Object[fw][fo][0] = 0; + FW_Object[fw][fo][1] = 0; + UpdateStreamerForAll(); + return 1; + } + case 2: + { + new Float: fwX, Float: fwY, Float: fwZ; + for (new prt; prt != SPLITTER_DUPLICATE_2; prt++) + { + for (new fo2; fo2 != MAX_FWOBJECT; fo2++) + { + if (FW_Object[fw][fo2][0] == 0) + { + GetDynamicObjectPos(objectid, fwX, fwY, fwZ); + FW_Object[fw][fo2][0] = CreateDynamicObject(FW_DATA[ fw ] [ E_COLORS ][1], fwX, fwY, fwZ, 0.0, 0.0, 0.0, -1, 0, -1, 300.0); + Get3DRandomDistanceAway(fwX, fwY, fwZ, 15, 30); + MoveDynamicObject(FW_Object[fw][fo2][0], (fwX+(float(random(200))/10.0))-10.0, (fwY+(float(random(200))/10.0))-10.0, (fwZ+(float(random(200))/10.0))-10.0, 7.0+(float(random(20))/10.0)); + FW_Object[fw][fo2][1] = 3; + break; + } + } + } + + for (new i = 0, mp = GetPlayerPoolSize(); i <= mp; i++) + { + if(IsPlayerInRangeOfPoint(i,50,fwX, fwY, fwZ)) + { + PlayerPlaySound(i, 1009, 0, 0, 0); + } + } + + DestroyDynamicObject(FW_Object[fw][fo][0]); + FW_Object[fw][fo][0] = 0; + FW_Object[fw][fo][1] = 0; + UpdateStreamerForAll(); + return 1; + } + case 3: {DestroyDynamicObject(FW_Object[fw][fo][0]); FW_Object[fw][fo][0] = 0; FW_Object[fw][fo][1] = 0;} + } + return 1; } - } - new Float:angle_step = floatdiv(360.0, float(total_flares)); - for(new i = 0; i < total_flares; i++) - { - if(!IsValidDynamicObject(FW_Data[handle][FW_FLARE_OBJECT_ID][i])) continue; - if(!FW_Data[handle][FW_IS_FLARE_MOVING][i]) continue; - - - new const Float:time = FW_Data[handle][FW_FLARE_TIME_ELAPSED][i]; - new const Float:vx = (FW_Data[handle][FW_INITIAL_SPEED] * floatcos(360.0 * floatsin(i * elevation_angle, degrees) * angle_step, degrees)) + floatdiv(float(i), float(total_flares)); - new const Float:vy = (FW_Data[handle][FW_INITIAL_SPEED] * floatsin(360.0 * floatcos(-i * elevation_angle, degrees) * angle_step, degrees)) + floatdiv(float(i), float(total_flares)); - new const Float:xpos = vx * time * floatsin(FW_Data[handle][FW_FLARE_TIME_ELAPSED][i], degrees) + FW_Data[handle][FW_ORIGIN_X]; - new const Float:ypos = vy * time * floatsin(FW_Data[handle][FW_FLARE_TIME_ELAPSED][i], degrees) + FW_Data[handle][FW_ORIGIN_Y]; - new const Float:zpos = vi_z * time - (0.5) * gravity * (time*time) + FW_Data[handle][FW_ORIGIN_Z]; - new const Float:vf_z = vi_z - gravity * time; - - if((vf_z < 0.0 ) && zpos < (FW_Data[handle][FW_MAX_HEIGHT] - fRandomEx(6.0, 10.0))) + case FW_UMBRELLA: { - CreateExplosion(xpos, ypos, zpos, FW_EXPLOSION_TYPE, FW_EXPLOSION_RANGE); - DestroyDynamicObject(FW_Data[handle][FW_FLARE_OBJECT_ID][i]); - FW_Data[handle][FW_FLARE_TIME_ELAPSED][i] = 0; - FW_Data[handle][FW_OBJECT_DESTROYED_COUNT]++; - } - new const Float:v = VectorSize(vx, vy, vf_z); - MoveDynamicObject(FW_Data[handle][FW_FLARE_OBJECT_ID][i], xpos, ypos, zpos, v/2, 0.0, 0.0, 0.0); - FW_Data[handle][FW_FLARE_TIME_ELAPSED][i] += FW_TICK_RATE * 0.001; //Adjusting - angle_step += 0.0001; - } - FW_Data[handle][FW_INITIAL_SPEED]+= 0.001; - } - } - } + switch (FW_Object[fw][fo][1]) + { + case 1: + { + new Float: fwX, Float: fwY, Float: fwZ, stage; + for (new prt; prt != UMBRELLA_DUPLICATES; prt++) + { + for (new fo2; fo2 != MAX_FWOBJECT; fo2++) + { + if (FW_Object[fw][fo2][0] == 0) + { + new model; + switch (stage) + { + case 0: {model = FW_DATA[ fw ] [ E_COLORS ][0]; stage = 1;} + case 1: {model = FW_DATA[ fw ] [ E_COLORS ][1]; stage = 0;} + } - case STYLE_CIRCLE: - { - switch(FW_Data[handle][FW_CURRENT_STAGE]) - { - case FW_S_CREATE_FLARES: - { - new object_model = 0; - for(new i = 0; i < FW_Data[handle][FW_TOTAL_FLARE_OBJECTS]; i++) - { - switch(i % 4) - { - case 0: object_model = 19297; - case 1: object_model = 19298; - case 2: object_model = 19296; - case 3: object_model = 19295; - } - FW_Data[handle][FW_FLARE_OBJECT_ID][i] = CreateDynamicObject(object_model, FW_Data[handle][FW_ORIGIN_X], FW_Data[handle][FW_ORIGIN_Y], FW_Data[handle][FW_ORIGIN_Z], 0.0, 0.0, 0.0, -1, -1, -1, FW_VISIBLE_RANGE); - } - FW_Data[handle][FW_CURRENT_STAGE] = FW_S_MOVE_FLARES; - new const Float:vi_z = FW_Data[handle][FW_INITIAL_SPEED] * floatsin(FW_Data[handle][FW_ELEVATION_ANGLE], degrees); - FW_Data[handle][FW_MAX_HEIGHT] = floatdiv((vi_z*vi_z), 2.0 * FW_Data[handle][FW_GRAVITY]) + FW_Data[handle][FW_ORIGIN_Z]; - } - case FW_S_MOVE_FLARES: - { - if(FW_Data[handle][FW_OBJECT_DESTROYED_COUNT] >= FW_Data[handle][FW_TOTAL_FLARE_OBJECTS]) - { - ResetFirework(handle); - return 0; - } - new const Float:angle_step = floatdiv(360.0, float(FW_Data[handle][FW_TOTAL_FLARE_OBJECTS])); //XY angle step in degrees - new const Float:vi_z = FW_Data[handle][FW_INITIAL_SPEED] * floatsin(FW_Data[handle][FW_ELEVATION_ANGLE], degrees); - new const Float:time = FW_Data[handle][FW_GLOBAL_TIME_ELAPSED]; + GetDynamicObjectPos(objectid, fwX, fwY, fwZ); + FW_Object[fw][fo2][0] = CreateDynamicObject(model, fwX, fwY, fwZ, 0.0, 0.0, 0.0, -1, 0, -1, 300.0); + Get2DRandomDistanceAway(fwX, fwY, 25, 40); + MoveDynamicObject(FW_Object[fw][fo2][0], fwX, fwY, fwZ, 8.0+(float(random(20))/10.0)); + FW_Object[fw][fo2][1] = 2; + break; + } + } + } - new const Float:gravity = FW_Data[handle][FW_GRAVITY]; - for(new i = 0; i < FW_Data[handle][FW_TOTAL_FLARE_OBJECTS]; i++) - { - if(!IsValidDynamicObject(FW_Data[handle][FW_FLARE_OBJECT_ID][i])) continue; - new const Float:vx = (FW_Data[handle][FW_INITIAL_SPEED] * floatcos(FW_Data[handle][FW_ELEVATION_ANGLE], degrees)) * floatcos(float(i)*angle_step, degrees); - new const Float:vy = (FW_Data[handle][FW_INITIAL_SPEED] * floatcos(FW_Data[handle][FW_ELEVATION_ANGLE], degrees)) * floatsin(float(i)*angle_step, degrees); - new const Float:xpos = vx * time + FW_Data[handle][FW_ORIGIN_X]; - new const Float:ypos = vy * time + FW_Data[handle][FW_ORIGIN_Y]; - new const Float:zpos = vi_z * time - (0.5) * gravity * (time*time) + FW_Data[handle][FW_ORIGIN_Z]; - new const Float:vf_z = vi_z - gravity * time; - if((vf_z < 0.0 ) && zpos < (FW_Data[handle][FW_MAX_HEIGHT] - fRandomEx(6.0, 10.0))) - { - CreateExplosion(xpos, ypos, zpos, FW_EXPLOSION_TYPE, FW_EXPLOSION_RANGE); - DestroyDynamicObject(FW_Data[handle][FW_FLARE_OBJECT_ID][i]); - FW_Data[handle][FW_OBJECT_DESTROYED_COUNT]++; + for (new i = 0, mp = GetPlayerPoolSize(); i <= mp; i++) + { + if(IsPlayerInRangeOfPoint(i,50,fwX, fwY, fwZ)) + { + PlayerPlaySound(i, 1009, 0, 0, 0); + } + } + + DestroyDynamicObject(FW_Object[fw][fo][0]); + FW_Object[fw][fo][0] = 0; + FW_Object[fw][fo][1] = 0; + UpdateStreamerForAll(); + return 1; + } + case 2: {DestroyDynamicObject(FW_Object[fw][fo][0]); FW_Object[fw][fo][0] = 0; FW_Object[fw][fo][1] = 0;} + } + return 1; + } + case FW_CAKE: + { + switch (FW_Object[fw][fo][1]) + { + case 1: + { + new Float: fwX, Float: fwY, Float: fwZ; + for (new prt; prt != CAKE_DUPLICATES; prt++) + { + for (new fo2; fo2 != MAX_FWOBJECT; fo2++) + { + if (FW_Object[fw][fo2][0] == 0) + { + GetDynamicObjectPos(objectid, fwX, fwY, fwZ); + FW_Object[fw][fo2][0] = CreateDynamicObject(FW_DATA[ fw ] [ E_COLORS ][1], fwX, fwY, fwZ, 0.0, 0.0, 0.0, -1, 0, -1, 300.0); + Get3DRandomDistanceAway(fwX, fwY, fwZ, 25, 40); + MoveDynamicObject(FW_Object[fw][fo2][0], fwX, fwY, fwZ, 15.0+(float(random(20))/10.0)); + FW_Object[fw][fo2][1] = 2; + break; + } + } + } + + for (new i = 0, mp = GetPlayerPoolSize(); i <= mp; i++) + { + if(IsPlayerInRangeOfPoint(i,50,fwX, fwY, fwZ)) + { + PlayerPlaySound(i, 1009, 0, 0, 0); + } + } + + DestroyDynamicObject(FW_Object[fw][fo][0]); + FW_Object[fw][fo][0] = 0; + FW_Object[fw][fo][1] = 0; + UpdateStreamerForAll(); + return 1; + } + case 2: {DestroyDynamicObject(FW_Object[fw][fo][0]); FW_Object[fw][fo][0] = 0; FW_Object[fw][fo][1] = 0;} + } + return 1; } - new const Float:v = VectorSize(vx, vy, vf_z); - MoveDynamicObject(FW_Data[handle][FW_FLARE_OBJECT_ID][i], xpos, ypos, zpos, v, 0.0, 0.0, 0.0); } + return 0; } } } } - FW_Data[handle][FW_GLOBAL_TIME_ELAPSED] += FW_TICK_RATE * 0.001; - FW_Data[handle][FW_FL_TIME_DELAY_COUNT]++; return 1; } -CMD:fireworks( playerid, params[ ] ) +stock FW_MainCreate(playerid, firework) { - if ( ! IsPlayerAdmin( playerid ) ) return 0; - new - flares, style, Float: speed, Float: gravity, Float: angle, Float: time_delay, Float: max_height; + if (IsPlayerNPC(playerid) || !IsPlayerConnected(playerid)) return 0; - // /fireworks 50 0 10 10.8 50 0.2 50 - spiral - if ( sscanf( params, "ddffffF(50.0)", flares, style, speed, gravity, angle, time_delay, max_height ) ) return SendUsage( playerid, "fireworks [FLARES] [STYLE] [SPEED] [GRAVITY] [ANGLE] [TIME_DELAY] [MAX_HEIGHT]" ); - else + if (GetPlayerInterior(playerid) != 0) + { + SendError( playerid, "You can't light fireworks inside!" ); + return 0; + } + + if (GetPlayerState(playerid) == PLAYER_STATE_ONFOOT) + { + switch(firework) + { + case FW_UNKNOWN: + { + SendError( playerid, "Fireworks couldn't be created!" ); + return 0; + } + case FW_FOUNTAIN, FW_ROCKET, FW_SPLITTER, FW_UMBRELLA, FW_CAKE: + { + ApplyAnimation(playerid, "BOMBER", "BOM_Plant", 1.0, 0, 0, 0, 1, 0, 1); + SetTimerEx("FW_MainCreateEnd", DEF_ANIM_TIME, false, "ii", playerid, firework); + return 1; + } + } + } + else { + SendError( playerid, "You have to be on foot to place fireworks down!" ); + } + return 0; +} + +forward FW_MainCreateEnd(playerid, firework); +public FW_MainCreateEnd(playerid, firework) +{ + if ( !IsPlayerConnected( playerid ) ) + return 0; + + new + fw = Iter_Free( fireworks ); + + if ( fw != ITER_NONE ) { new - Float: X, Float: Y, Float: Z - ; + Float: plX, Float: plY, Float: fwX, Float: fwY, Float: Z; - GetPlayerPos( playerid, X, Y, Z ); + // reset some variables + FW_DATA[ fw ] [ E_CREATOR ] = -1; + FW_DATA[ fw ] [ E_ATTACHED_VEH ] = -1; - CreateFireworks( flares, style, X, Y, Z, angle, speed, gravity, time_delay, max_height ); - return SendServerMessage( playerid, "Fireworks placed! Use /launchfireworks to launch." ); + // add to list + Iter_Add( fireworks, fw ); + + // handle player + ClearAnimations(playerid); + GivePlayerWeapon(playerid, 40, 1); + GetPlayerPos(playerid, plX, plY, Z); + SetPVarInt(playerid, "FireworkPlaced", 1); + GetXYInFrontOfPlayer(playerid, fwX, fwY, Z, 1.0); + new Float: R = atan2( fwY - plY, fwX - fwX ) - 90.0; // GetAngleToPos(plX, plY, fwX, fwY); + + switch(firework) + { + case FW_UNKNOWN: return SendError( playerid, "Fireworks couldn't be created!" ), 0; + case FW_FOUNTAIN: + { + FW_FountainCreate(playerid, fw, fwX, fwY, Z, R, GetPVarInt(playerid, "FW_Color1"), GetPVarInt(playerid, "FW_Color2")); + DeletePVar(playerid, "FW_Color1"); + DeletePVar(playerid, "FW_Color2"); + return 1; + } + case FW_ROCKET: + { + FW_RocketCreate(playerid, fw, fwX, fwY, Z, R, GetPVarInt(playerid, "FW_Color1"), GetPVarInt(playerid, "FW_Color2")); + DeletePVar(playerid, "FW_Color1"); + DeletePVar(playerid, "FW_Color2"); + return 1; + } + case FW_SPLITTER: + { + FW_SplitterCreate(playerid, fw, fwX, fwY, Z, R, GetPVarInt(playerid, "FW_Color1"), GetPVarInt(playerid, "FW_Color2")); + DeletePVar(playerid, "FW_Color1"); + DeletePVar(playerid, "FW_Color2"); + return 1; + } + case FW_UMBRELLA: + { + FW_UmbrelllaCreate(playerid, fw, fwX, fwY, Z, R, GetPVarInt(playerid, "FW_Color1"), GetPVarInt(playerid, "FW_Color2")); + DeletePVar(playerid, "FW_Color1"); + DeletePVar(playerid, "FW_Color2"); + return 1; + } + case FW_CAKE: + { + FW_CakeCreate(playerid, fw, fwX, fwY, Z, R, GetPVarInt(playerid, "FW_Color1"), GetPVarInt(playerid, "FW_Color2")); + DeletePVar(playerid, "FW_Color1"); + DeletePVar(playerid, "FW_Color2"); + return 1; + } + default: return SendError( playerid, "Fireworks couldn't be created!" ); + } } + return SendError( playerid, "Server limit is reached! Light some before you place more." ), 0; } -CMD:launchfireworks( playerid, params[ ] ) +function FW_MainFire(playerid) { - if ( ! IsPlayerAdmin( playerid ) ) return 0; - foreach (new f : fireworks) { - LaunchFireworks( f ); + static + Float: fwX, Float: fwY, Float: fwZ; + + foreach ( new fw : fireworks ) + { + if (FW_DATA[ fw ] [ E_CREATOR ] == playerid && FW_DATA[ fw ] [ E_STAGE ] == 1) + { + switch (FW_DATA[ fw ] [ E_TYPE ]) + { + case FW_UNKNOWN: + { + FW_DATA[ fw ] [ E_CREATOR ] = -1; + SendError( playerid, "Fireworks couldn't be lighted!" ); + return 0; + } + case FW_FOUNTAIN: + { + FW_DATA[ fw ] [ E_LIFETIME ] = FOUNTAIN_LIFE; + FW_DATA[ fw ] [ E_STAGE ] = 2; + GetDynamicObjectPos(FW_Object[fw][0][0], fwX, fwY, fwZ); + + for (new i = 0, mp = GetPlayerPoolSize(); i <= mp; i++) if(IsPlayerInRangeOfPoint(i,50, fwX, fwY, fwZ)) { + PlayerPlaySound(i, 1134, 0, 0, 0); + } + + SetTimerEx("FW_FountainFire", FOUNTAIN_DELAY, false, "ii", fw, 0); + return 1; + } + case FW_ROCKET: + { + FW_DATA[ fw ] [ E_STAGE ] = 2; + GetDynamicObjectPos(FW_Object[fw][0][0], fwX, fwY, fwZ); + FW_Object[fw][3][0] = CreateDynamicObject(18727, fwX, fwY, fwZ, 0.0, 0.0, 0.0, 150); + SetTimerEx("FW_RocketFire", ROCKET_DELAY, false, "i", fw); + return 1; + } + case FW_SPLITTER: + { + FW_DATA[ fw ] [ E_STAGE ] = 2; + GetDynamicObjectPos(FW_Object[fw][0][0], fwX, fwY, fwZ); + FW_Object[fw][3][0] = CreateDynamicObject(18727, fwX, fwY, fwZ, 0.0, 0.0, 0.0, 150); + SetTimerEx("FW_SplitterFire", SPLITTER_DELAY, false, "i", fw); + return 1; + } + case FW_UMBRELLA: + { + FW_DATA[ fw ] [ E_STAGE ] = 2; + GetDynamicObjectPos(FW_Object[fw][0][0], fwX, fwY, fwZ); + FW_Object[fw][3][0] = CreateDynamicObject(18727, fwX, fwY, fwZ, 0.0, 0.0, 0.0, 150); + SetTimerEx("FW_UmbrelllaFire", UMBRELLA_DELAY, false, "i", fw); + return 1; + } + case FW_CAKE: + { + FW_DATA[ fw ] [ E_STAGE ] = 2; + SetTimerEx("FW_CakeFire", CAKE_DELAY, false, "ii", fw, 1); + return 1; + } + } + return 1; + } + } + KillTimer(GetPVarInt(playerid, "TimerMainFire")); + DeletePVar(playerid, "TimerMainFire"); + return 0; +} + +function FW_MainDestroy(fw) +{ + Iter_Remove( fireworks, fw ); + FW_DATA[ fw ] [ E_CREATOR ] = -1; + FW_DATA[ fw ] [ E_TYPE ] = FW_UNKNOWN; + FW_DATA[ fw ] [ E_ATTACHED_VEH ] = -1; + FW_DATA[ fw ] [ E_LIFETIME ] = 0; + FW_DATA[ fw ] [ E_STAGE ] = 0; + FW_DATA[ fw ] [ E_COLORS ][0] = 0; + FW_DATA[ fw ] [ E_COLORS ][1] = 0; + for (new fo; fo != MAX_FWOBJECT; fo++) + { + if (FW_Object[fw][fo][0] != 0) + { + if (IsValidDynamicObject(FW_Object[fw][fo][0])) {DestroyDynamicObject(FW_Object[fw][fo][0]);} + FW_Object[fw][fo][0] = 0; + FW_Object[fw][fo][1] = 0; + } } - SendServerMessage( playerid, "Launching" ); return 1; } -CMD:destroyfireworks( playerid, params[ ] ) +// FOUNTAIN +stock FW_FountainCreate(playerid, fw, Float: X, Float: Y, Float: Z, Float: R, model1, model2) { - if ( ! IsPlayerAdmin( playerid ) ) return 0; - for (new f = 0; f < MAX_FIREWORKS; f++ ) { - ResetFirework( f ); + if ( !IsPlayerConnected( playerid ) ) + return 0; + + FW_DATA[ fw ] [ E_CREATOR ] = playerid; + FW_DATA[ fw ] [ E_STAGE ] = 1; + FW_DATA[ fw ] [ E_TYPE ] = FW_FOUNTAIN; + FW_DATA[ fw ] [ E_COLORS ][0] = model1; + FW_DATA[ fw ] [ E_COLORS ][1] = model2; + if (FW_DATA[ fw ] [ E_COLORS ][0] == 0) {FW_DATA[ fw ] [ E_COLORS ][0] = 19284;} + if (FW_DATA[ fw ] [ E_COLORS ][1] == 0) {FW_DATA[ fw ] [ E_COLORS ][1] = 19281;} + FW_Object[fw][0][0] = CreateDynamicObject(1271, X, Y, Z-0.65, 0.0, 0.0, R, -1, 0, -1, 100.0); + FW_Object[fw][1][0] = CreateDynamicObject(2203, X, Y, Z-0.4, 0.0, 0.0, R, -1, 0, -1, 100.0); + + new surf = GetPlayerSurfingVehicleID(playerid); + if (surf != INVALID_VEHICLE_ID) + { + FW_DATA[ fw ] [ E_ATTACHED_VEH ] = surf; + new Float: vehPos[3]; + GetVehiclePos(surf, vehPos[0], vehPos[1], vehPos[2]); + X -= vehPos[0]; + Y -= vehPos[1]; + Z -= vehPos[2]; + AttachDynamicObjectToVehicle(FW_Object[fw][0][0], surf, X, Y, Z-0.65, 0.0, 0.0, R); + AttachDynamicObjectToVehicle(FW_Object[fw][1][0], surf, X, Y, Z-0.4, 0.0, 0.0, R); } - SendServerMessage( playerid, "Destroyed" ); + UpdateStreamerForAll(); + return 1; +} + +forward FW_FountainFire(fw, stage); +public FW_FountainFire(fw, stage) +{ + for (new fo; fo != MAX_FWOBJECT; fo++) + { + if (FW_Object[fw][fo][0] == 0) + { + new Float: fwX, Float: fwY, Float: fwZ, model; + if (FW_DATA[ fw ] [ E_ATTACHED_VEH ] == -1) {GetDynamicObjectPos(FW_Object[fw][0][0], fwX, fwY, fwZ);} + else + { + GetVehiclePos(FW_DATA[ fw ] [ E_ATTACHED_VEH ], fwX, fwY, fwZ); + new Float: AttachOffset[3]; + Streamer_GetFloatData(0, FW_Object[fw][0][0], E_STREAMER_ATTACH_OFFSET_X, AttachOffset[0]); + Streamer_GetFloatData(0, FW_Object[fw][0][0], E_STREAMER_ATTACH_OFFSET_Y, AttachOffset[1]); + Streamer_GetFloatData(0, FW_Object[fw][0][0], E_STREAMER_ATTACH_OFFSET_Z, AttachOffset[2]); + fwX += AttachOffset[0]; + fwY += AttachOffset[1]; + fwZ += AttachOffset[2]; + } + switch(stage) + { + case 0: {model = FW_DATA[ fw ] [ E_COLORS ][0]; stage = 1;} + case 1: {model = FW_DATA[ fw ] [ E_COLORS ][1]; stage = 0;} + } + FW_Object[fw][fo][0] = CreateDynamicObject(model, (fwX+(float(random(5))/10.0))-0.25, (fwY+(float(random(5))/10.0))-0.25, fwZ, 0.0, 0.0, 0.0, -1, 0, -1, 300.0); + MoveDynamicObject(FW_Object[fw][fo][0], (fwX+(float(random(80))/10.0))-4.0, (fwY+(float(random(80))/10.0))-4.0, fwZ+(20.0+float(random(15))), 15.0+(float(random(20))/10.0)); + FW_Object[fw][fo][1] = 1; + UpdateStreamerForAll(); + break; + } + if (fo == (MAX_FWOBJECT-1)) + { + print( "[FIREWORKS ERROR] ENTITIES LIMIT REACHED! 1" ); + return 0; + } + } + FW_DATA[ fw ] [ E_LIFETIME ] -= FOUNTAIN_DELAY; + if (FW_DATA[ fw ] [ E_LIFETIME ] > 0) {SetTimerEx("FW_FountainFire", FOUNTAIN_DELAY, false, "ii", fw, stage); return 1;} + FW_DATA[ fw ] [ E_STAGE ] = 3; + SetTimerEx("FW_MainDestroy", DEF_STAY_TIME, false, "i", fw); + return 0; +} + +// ROCKET +stock FW_RocketCreate(playerid, fw, Float: X, Float: Y, Float: Z, Float: R, model1, model2) +{ + if ( !IsPlayerConnected( playerid ) ) + return 0; + + FW_DATA[ fw ] [ E_CREATOR ] = playerid; + FW_DATA[ fw ] [ E_STAGE ] = 1; + FW_DATA[ fw ] [ E_TYPE ] = FW_ROCKET; + FW_DATA[ fw ] [ E_COLORS ][0] = model1; + FW_DATA[ fw ] [ E_COLORS ][1] = model2; + if (FW_DATA[ fw ] [ E_COLORS ][0] == 0) {FW_DATA[ fw ] [ E_COLORS ][0] = 19282;} + if (FW_DATA[ fw ] [ E_COLORS ][1] == 0) {FW_DATA[ fw ] [ E_COLORS ][1] = 19281;} + FW_Object[fw][0][0] = CreateDynamicObject(1271, X, Y, Z-0.65, 0.0, 0.0, R, -1, 0, -1, 100.0); + FW_Object[fw][1][0] = CreateDynamicObject(3790, X, Y, Z+0.95, 0.0, 90.0, R, -1, 0, -1, 100.0); + + new surf = GetPlayerSurfingVehicleID(playerid); + if (surf != INVALID_VEHICLE_ID) + { + FW_DATA[ fw ] [ E_ATTACHED_VEH ] = surf; + new Float: vehPos[3]; + GetVehiclePos(surf, vehPos[0], vehPos[1], vehPos[2]); + X -= vehPos[0]; + Y -= vehPos[1]; + Z -= vehPos[2]; + AttachDynamicObjectToVehicle(FW_Object[fw][0][0], surf, X, Y, Z-0.65, 0.0, 0.0, R); + AttachDynamicObjectToVehicle(FW_Object[fw][1][0], surf, X, Y, Z+0.95, 0.0, 90.0, R); + } + + UpdateStreamerForAll(); + return 1; +} + +forward FW_RocketFire(fw); +public FW_RocketFire(fw) +{ + DestroyDynamicObject(FW_Object[fw][3][0]); + new Float: fwX, Float: fwY, Float: fwZ, Float: R; + if (FW_DATA[ fw ] [ E_ATTACHED_VEH ] == -1) {GetDynamicObjectPos(FW_Object[fw][1][0], fwX, fwY, fwZ);} + else + { + GetVehiclePos(FW_DATA[ fw ] [ E_ATTACHED_VEH ], fwX, fwY, fwZ); + new Float: AttachOffset[3]; + Streamer_GetFloatData(0, FW_Object[fw][0][0], E_STREAMER_ATTACH_OFFSET_X, AttachOffset[0]); + Streamer_GetFloatData(0, FW_Object[fw][0][0], E_STREAMER_ATTACH_OFFSET_Y, AttachOffset[1]); + Streamer_GetFloatData(0, FW_Object[fw][0][0], E_STREAMER_ATTACH_OFFSET_Z, AttachOffset[2]); + fwX += AttachOffset[0]; + fwY += AttachOffset[1]; + fwZ += AttachOffset[2]; + } + + for (new i = 0, mp = GetPlayerPoolSize(); i <= mp; i++) + { + if(IsPlayerInRangeOfPoint(i,50,fwX, fwY, fwZ)) + { + PlayerPlaySound(i, 1095, 0, 0, 0); + } + } + DestroyDynamicObject(FW_Object[fw][1][0]); + Streamer_GetFloatData(0, FW_Object[fw][0][0], E_STREAMER_R_Z, R); + FW_Object[fw][1][0] = CreateDynamicObject(3790, fwX, fwY, fwZ+0.95, 0.0, 90.0, R, -1, 0, -1, 300.0); + FW_Object[fw][2][0] = CreateDynamicObject(345, fwX, fwY, fwZ-1.2, 90.0, 0.0, 0.0, -1, 0, -1, 300.0); + fwX += (float(random(30))/10); + fwY += (float(random(30))/10); + fwZ = fwZ + 40 + float(random(5)); + MoveDynamicObject(FW_Object[fw][1][0], fwX, fwY, fwZ, 18.0); + MoveDynamicObject(FW_Object[fw][2][0], fwX, fwY, fwZ-1.2, 18.0); + FW_Object[fw][1][1] = 1; + FW_Object[fw][2][1] = 2; + UpdateStreamerForAll(); + SetTimerEx("FW_MainDestroy", DEF_STAY_TIME, false, "i", fw); + return 0; +} + +// SPLITTER +stock FW_SplitterCreate(playerid, fw, Float: X, Float: Y, Float: Z, Float: R, model1, model2) +{ + if ( !IsPlayerConnected( playerid ) ) + return 0; + + FW_DATA[ fw ] [ E_CREATOR ] = playerid; + FW_DATA[ fw ] [ E_STAGE ] = 1; + FW_DATA[ fw ] [ E_TYPE ] = FW_SPLITTER; + FW_DATA[ fw ] [ E_COLORS ][0] = model1; + FW_DATA[ fw ] [ E_COLORS ][1] = model2; + if (FW_DATA[ fw ] [ E_COLORS ][0] == 0) {FW_DATA[ fw ] [ E_COLORS ][0] = 19282;} + FW_Object[fw][0][0] = CreateDynamicObject(1271, X, Y, Z-0.65, 0.0, 0.0, R, -1, 0, -1, 100.0); + FW_Object[fw][1][0] = CreateDynamicObject(3786, X, Y, Z+0.95, 0.0, 90.0, R, -1, 0, -1, 100.0); + + new surf = GetPlayerSurfingVehicleID(playerid); + if (surf != INVALID_VEHICLE_ID) + { + FW_DATA[ fw ] [ E_ATTACHED_VEH ] = surf; + new Float: vehPos[3]; + GetVehiclePos(surf, vehPos[0], vehPos[1], vehPos[2]); + X -= vehPos[0]; + Y -= vehPos[1]; + Z -= vehPos[2]; + AttachDynamicObjectToVehicle(FW_Object[fw][0][0], surf, X, Y, Z-0.65, 0.0, 0.0, R); + AttachDynamicObjectToVehicle(FW_Object[fw][1][0], surf, X, Y, Z+0.95, 0.0, 90.0, R); + } + + UpdateStreamerForAll(); + return 1; +} + +forward FW_SplitterFire(fw); +public FW_SplitterFire(fw) +{ + DestroyDynamicObject(FW_Object[fw][3][0]); + new Float: fwX, Float: fwY, Float: fwZ, Float: R; + if (FW_DATA[ fw ] [ E_ATTACHED_VEH ] == -1) {GetDynamicObjectPos(FW_Object[fw][1][0], fwX, fwY, fwZ);} + else + { + GetVehiclePos(FW_DATA[ fw ] [ E_ATTACHED_VEH ], fwX, fwY, fwZ); + new Float: AttachOffset[3]; + Streamer_GetFloatData(0, FW_Object[fw][0][0], E_STREAMER_ATTACH_OFFSET_X, AttachOffset[0]); + Streamer_GetFloatData(0, FW_Object[fw][0][0], E_STREAMER_ATTACH_OFFSET_Y, AttachOffset[1]); + Streamer_GetFloatData(0, FW_Object[fw][0][0], E_STREAMER_ATTACH_OFFSET_Z, AttachOffset[2]); + fwX += AttachOffset[0]; + fwY += AttachOffset[1]; + fwZ += AttachOffset[2]; + } + + for (new i = 0, mp = GetPlayerPoolSize(); i <= mp; i++) + { + if(IsPlayerInRangeOfPoint(i,50,fwX, fwY, fwZ)) + { + PlayerPlaySound(i, 1095, 0, 0, 0); + } + } + + DestroyDynamicObject(FW_Object[fw][1][0]); + Streamer_GetFloatData(0, FW_Object[fw][0][0], E_STREAMER_R_Z, R); + + FW_Object[fw][1][0] = CreateDynamicObject(3786, fwX, fwY, fwZ+0.95, 0.0, 90.0, R, -1, 0, -1, 300.0); + FW_Object[fw][2][0] = CreateDynamicObject(345, fwX, fwY, fwZ-1.2, 90.0, 0.0, 0.0, -1, 0, -1, 300.0); + fwX += (float(random(30))/10); + fwY += (float(random(30))/10); + fwZ = fwZ + 40.0 + float(random(5)); + MoveDynamicObject(FW_Object[fw][1][0], fwX, fwY, fwZ, 18.0); + MoveDynamicObject(FW_Object[fw][2][0], fwX, fwY, fwZ-1.2, 18.0); + FW_Object[fw][1][1] = 1; + FW_Object[fw][2][1] = 3; + UpdateStreamerForAll(); + SetTimerEx("FW_MainDestroy", DEF_STAY_TIME, false, "i", fw); + return 0; +} + +// Umbrella +stock FW_UmbrelllaCreate(playerid, fw, Float: X, Float: Y, Float: Z, Float: R, model1, model2) +{ + if ( !IsPlayerConnected( playerid ) ) + return 0; + + FW_DATA[ fw ] [ E_CREATOR ] = playerid; + FW_DATA[ fw ] [ E_STAGE ] = 1; + FW_DATA[ fw ] [ E_TYPE ] = FW_UMBRELLA; + FW_DATA[ fw ] [ E_COLORS ][0] = model1; + FW_DATA[ fw ] [ E_COLORS ][1] = model2; + if (FW_DATA[ fw ] [ E_COLORS ][0] == 0) {FW_DATA[ fw ] [ E_COLORS ][0] = 19282;} + if (FW_DATA[ fw ] [ E_COLORS ][1] == 0) {FW_DATA[ fw ] [ E_COLORS ][1] = 19281;} + FW_Object[fw][0][0] = CreateDynamicObject(1271, X, Y, Z-0.65, 0.0, 0.0, R, -1, 0, -1, 100.0); + FW_Object[fw][1][0] = CreateDynamicObject(3790, X, Y, Z+0.95, 0.0, 90.0, R, -1, 0, -1, 100.0); + + new surf = GetPlayerSurfingVehicleID(playerid); + if (surf != INVALID_VEHICLE_ID) + { + FW_DATA[ fw ] [ E_ATTACHED_VEH ] = surf; + new Float: vehPos[3]; + GetVehiclePos(surf, vehPos[0], vehPos[1], vehPos[2]); + X -= vehPos[0]; + Y -= vehPos[1]; + Z -= vehPos[2]; + AttachDynamicObjectToVehicle(FW_Object[fw][0][0], surf, X, Y, Z-0.65, 0.0, 0.0, R); + AttachDynamicObjectToVehicle(FW_Object[fw][1][0], surf, X, Y, Z+0.95, 0.0, 90.0, R); + } + UpdateStreamerForAll(); + return 1; +} + +function FW_UmbrelllaFire(fw) +{ + DestroyDynamicObject(FW_Object[fw][3][0]); + new Float: fwX, Float: fwY, Float: fwZ, Float: R; + if (FW_DATA[ fw ] [ E_ATTACHED_VEH ] == -1) {GetDynamicObjectPos(FW_Object[fw][1][0], fwX, fwY, fwZ);} + else + { + GetVehiclePos(FW_DATA[ fw ] [ E_ATTACHED_VEH ], fwX, fwY, fwZ); + new Float: AttachOffset[3]; + Streamer_GetFloatData(0, FW_Object[fw][0][0], E_STREAMER_ATTACH_OFFSET_X, AttachOffset[0]); + Streamer_GetFloatData(0, FW_Object[fw][0][0], E_STREAMER_ATTACH_OFFSET_Y, AttachOffset[1]); + Streamer_GetFloatData(0, FW_Object[fw][0][0], E_STREAMER_ATTACH_OFFSET_Z, AttachOffset[2]); + fwX += AttachOffset[0]; + fwY += AttachOffset[1]; + fwZ += AttachOffset[2]; + } + + for (new i = 0, mp = GetPlayerPoolSize(); i <= mp; i++) + { + if(IsPlayerInRangeOfPoint(i,50,fwX, fwY, fwZ)) + { + PlayerPlaySound(i, 1095, 0, 0, 0); + } + } + + DestroyDynamicObject(FW_Object[fw][1][0]); + Streamer_GetFloatData(0, FW_Object[fw][0][0], E_STREAMER_R_Z, R); + + + FW_Object[fw][1][0] = CreateDynamicObject(3790, fwX, fwY, fwZ+0.95, 0.0, 90.0, R, -1, 0, -1, 100.0); + FW_Object[fw][2][0] = CreateDynamicObject(345, fwX, fwY, fwZ-1.2, 90.0, 0.0, 0.0, -1, 0, -1, 300.0); + fwX += (float(random(30))/10); + fwY += (float(random(30))/10); + fwZ = fwZ + 40.0 + float(random(5)); + MoveDynamicObject(FW_Object[fw][1][0], fwX, fwY, fwZ, 18.0); + MoveDynamicObject(FW_Object[fw][2][0], fwX, fwY, fwZ-1.2, 18.0); + FW_Object[fw][1][1] = 1; + FW_Object[fw][2][1] = 2; + UpdateStreamerForAll(); + SetTimerEx("FW_MainDestroy", DEF_STAY_TIME, false, "i", fw); + return 0; +} + +// CAKE (is a lie! ^_^) +stock FW_CakeCreate(playerid, fw, Float: X, Float: Y, Float: Z, Float: R, model1, model2) +{ + if ( !IsPlayerConnected( playerid ) ) + return 0; + + FW_DATA[ fw ] [ E_CREATOR ] = playerid; + FW_DATA[ fw ] [ E_STAGE ] = 1; + FW_DATA[ fw ] [ E_TYPE ] = FW_CAKE; + FW_DATA[ fw ] [ E_COLORS ][0] = model1; + FW_DATA[ fw ] [ E_COLORS ][1] = model2; + if (FW_DATA[ fw ] [ E_COLORS ][0] == 0) {FW_DATA[ fw ] [ E_COLORS ][0] = 19282;} + if (FW_DATA[ fw ] [ E_COLORS ][1] == 0) {FW_DATA[ fw ] [ E_COLORS ][1] = 19281;} + FW_Object[fw][0][0] = CreateDynamicObject(1271, X, Y, Z-0.65, 0.0, 0.0, R, -1, 0, -1, 100.0); + FW_Object[fw][1][0] = CreateDynamicObject(2902, X, Y, Z-0.55, 0.0, -45.0-90.0, R, -1, 0, -1, 100.0); + FW_Object[fw][2][0] = CreateDynamicObject(2902, X, Y, Z-0.5, 0.0, -22.5-90.0, R, -1, 0, -1, 100.0); + FW_Object[fw][3][0] = CreateDynamicObject(2902, X, Y, Z-0.45, 0.0, 0.0-90.0, R, -1, 0, -1, 100.0); + FW_Object[fw][4][0] = CreateDynamicObject(2902, X, Y, Z-0.5, 0.0, 22.5-90.0, R, -1, 0, -1, 100.0); + FW_Object[fw][5][0] = CreateDynamicObject(2902, X, Y, Z-0.55, 0.0, 45.0-90.0, R, -1, 0, -1, 100.0); + + new surf = GetPlayerSurfingVehicleID(playerid); + if (surf != INVALID_VEHICLE_ID) + { + FW_DATA[ fw ] [ E_ATTACHED_VEH ] = surf; + new Float: vehPos[3]; + GetVehiclePos(surf, vehPos[0], vehPos[1], vehPos[2]); + X -= vehPos[0]; + Y -= vehPos[1]; + Z -= vehPos[2]; + AttachDynamicObjectToVehicle(FW_Object[fw][0][0], surf, X, Y, Z-0.65, 0.0, 0.0, R); + AttachDynamicObjectToVehicle(FW_Object[fw][1][0], surf, X, Y, Z-0.55, 0.0, -45.0-90.0, R); + AttachDynamicObjectToVehicle(FW_Object[fw][2][0], surf, X, Y, Z-0.5, 0.0, -22.5-90.0, R); + AttachDynamicObjectToVehicle(FW_Object[fw][3][0], surf, X, Y, Z-0.45, 0.0, 0.0-90.0, R); + AttachDynamicObjectToVehicle(FW_Object[fw][4][0], surf, X, Y, Z-0.5, 0.0, 22.5-90.0, R); + AttachDynamicObjectToVehicle(FW_Object[fw][5][0], surf, X, Y, Z-0.55, 0.0, 45.0-90.0, R); + } + UpdateStreamerForAll(); + return 1; +} + +function FW_CakeFire(fw, stage) +{ + new fwTime; + if (stage != 11) + { + for (new fo; fo != MAX_FWOBJECT; fo++) + { + if (FW_Object[fw][fo][0] == 0) + { + new Float: fwX, Float: fwY, Float: fwZ, Float: fwU, Float: fwR; + if (FW_DATA[ fw ] [ E_ATTACHED_VEH ] == -1) {GetDynamicObjectPos(FW_Object[fw][1][0], fwX, fwY, fwZ);} + else + { + GetVehiclePos(FW_DATA[ fw ] [ E_ATTACHED_VEH ], fwX, fwY, fwZ); + new Float: AttachOffset[3]; + Streamer_GetFloatData(0, FW_Object[fw][0][0], E_STREAMER_ATTACH_OFFSET_X, AttachOffset[0]); + Streamer_GetFloatData(0, FW_Object[fw][0][0], E_STREAMER_ATTACH_OFFSET_Y, AttachOffset[1]); + Streamer_GetFloatData(0, FW_Object[fw][0][0], E_STREAMER_ATTACH_OFFSET_Z, AttachOffset[2]); + fwX += AttachOffset[0]; + fwY += AttachOffset[1]; + fwZ += AttachOffset[2]; + } + + GetDynamicObjectRot(FW_Object[fw][0][0], fwU, fwU, fwR); + + for (new i = 0, mp = GetPlayerPoolSize(); i <= mp; i++) + { + if(IsPlayerInRangeOfPoint(i,50,fwX, fwY, fwZ)) + { + PlayerPlaySound(i, 1095, 0, 0, 0); + } + } + + FW_Object[fw][fo][0] = CreateDynamicObject(FW_DATA[ fw ] [ E_COLORS ][0], fwX, fwY, fwZ-0.5, 0.0, 0.0, 0.0, -1, 0, -1, 300.0); + switch (stage) + { + case 1, 10, 12:{GetOffsetPos(fwX, fwY, 30.0, fwR+90); fwZ += 25.0;} + case 2, 9, 13: {GetOffsetPos(fwX, fwY, 20.0, fwR+90); fwZ += 35.0;} + case 3, 8, 14: { fwZ += 40.0;} + case 4, 7, 15: {GetOffsetPos(fwX, fwY, 20.0, fwR-90); fwZ += 35.0;} + case 5, 6, 16: {GetOffsetPos(fwX, fwY, 30.0, fwR-90); fwZ += 25.0;} + } + MoveDynamicObject(FW_Object[fw][fo][0], fwX, fwY, fwZ, 25.0); + FW_Object[fw][fo][1] = 1; + break; + } + if (fo == (MAX_FWOBJECT-1)) + { + print( "[FIREWORKS ERROR] ENTITIES LIMIT REACHED! 2" ); + return 0; + } + } + if (FW_DATA[ fw ] [ E_STAGE ] != 2) {return 1;} + switch (stage) + { + case 1..4, 6..9: {fwTime = CAKE_SINGLE_DELAY;} + case 5, 10: {fwTime = CAKE_BIG_DELAY;} + } + UpdateStreamerForAll(); + stage++; + SetTimerEx("FW_CakeFire", fwTime, false, "ii", fw, stage); + return 1; + } + else + { + FW_DATA[ fw ] [ E_STAGE ] = 3; + FW_CakeFire( fw, 12 ); + FW_CakeFire( fw, 13 ); + FW_CakeFire( fw, 14 ); + FW_CakeFire( fw, 15 ); + FW_CakeFire( fw, 16 ); + UpdateStreamerForAll(); + SetTimerEx("FW_MainDestroy", DEF_STAY_TIME, false, "i", fw); + return 0; + } +} + +// Other things +stock UpdateStreamerForAll() +{ + for (new p = 0, mp = GetPlayerPoolSize(); p <= mp; p++) + { + Streamer_Update(p); + } + return 1; +} + +stock GetOffsetPos(&Float:x, &Float:y, Float:distance, Float: r) +{ // Created by Y_Less + x += (distance * floatsin(-r, degrees)); + y += (distance * floatcos(-r, degrees)); +} + +stock Get2DRandomDistanceAway(&Float: fwX, &Float: fwY, min_distance, max_distance = 100) +{ + new Float: tempX = fwX, Float: tempY = fwY; + new rX = random(max_distance); + new rY = random(max_distance); + tempX += float(rX-(max_distance/2)); + tempY += float(rY-(max_distance/2)); + while (GetDistanceBetweenPoints(tempX, tempY, 10.0, fwX, fwY, 10.0) < min_distance/2) + { + tempX = fwX; + tempY = fwY; + rX = random(max_distance); + rY = random(max_distance); + tempX += float(rX-(max_distance/2)); + tempY += float(rY-(max_distance/2)); + } + fwX = tempX; + fwY = tempY; + return 1; +} + +stock Get3DRandomDistanceAway(&Float: fwX, &Float: fwY, &Float: fwZ, min_distance, max_distance = 100) +{ + new Float: tempX = fwX, Float: tempY = fwY, Float: tempZ = fwZ; + new rX = random(max_distance); + new rY = random(max_distance); + new rZ = random(max_distance); + tempX += float(rX-(max_distance/2)); + tempY += float(rY-(max_distance/2)); + tempZ += float(rZ-(max_distance/2)); + while (GetDistanceBetweenPoints(tempX, tempY, tempZ, fwX, fwY, fwZ) < min_distance/2) + { + tempX = fwX; + tempY = fwY; + tempZ = fwZ; + rX = random(max_distance); + rY = random(max_distance); + rZ = random(max_distance); + tempX += float(rX-(max_distance/2)); + tempY += float(rY-(max_distance/2)); + tempZ += float(rZ-(max_distance/2)); + } + fwX = tempX; + fwY = tempY; + fwZ = tempZ; + return 1; +} + +stock RemoveWeaponFromSlot(playerid, weaponslot) +{ + new weapons[13][2]; + for(new i = 0; i < 13; i++) { + GetPlayerWeaponData(playerid, i, weapons[i][0], weapons[i][1]); + } + weapons[weaponslot][0] = 0; + ResetPlayerWeapons(playerid); + for(new i = 0; i < 13; i++) { + GivePlayerWeapon(playerid, weapons[i][0], weapons[i][1]); + } + return 1; +} + +/* ** Commands ** */ +CMD:fireworks( playerid, params[] ) +{ + if ( ! IsPlayerAdmin( playerid ) ) return 0; + ShowPlayerDialog( playerid, DIALOG_FIREWORKS, DIALOG_STYLE_LIST, ""COL_WHITE"Fireworks", "Fountain\nRocket\nSplitter\nUmbrella\nCake", "Select", "Back" ); return 1; } diff --git a/pawno/include/irresistible/helpers.inc b/pawno/include/irresistible/helpers.inc index 825447d..51d0e24 100644 --- a/pawno/include/irresistible/helpers.inc +++ b/pawno/include/irresistible/helpers.inc @@ -5,6 +5,9 @@ * Purpose: functions that help scripting */ +/* ** Includes ** */ +#include < YSI\y_va > + /* ** Macros ** */ #define function%1(%2) forward%1(%2); public%1(%2) #define RandomEx(%0,%1) (random((%1) - (%0)) + (%0)) @@ -17,7 +20,7 @@ #define SetObjectInvisible(%0) (SetDynamicObjectMaterialText(%0, 0, " ", 140, "Arial", 64, 1, -32256, 0, 1)) #define fRandomEx(%1,%2) (floatrandom(%2-%1)+%1) #define strmatch(%1,%2) (!strcmp(%1,%2,true)) -#define Beep(%1) PlayerPlaySound(%1, 1137, 0.0, 0.0, 5.0) +#define Beep(%1) PlayerPlaySound(%1, 1137, 0.0, 0.0, 0.0) #define StopSound(%1) PlayerPlaySound(%1,1186,0.0,0.0,0.0) #define erase(%0) (%0[0]='\0') #define positionToString(%0) (%0==1?("st"):(%0==2?("nd"):(%0==3?("rd"):("th")))) diff --git a/pawno/include/irresistible/main.inc b/pawno/include/irresistible/main.inc index d7bd206..4c45f03 100644 --- a/pawno/include/irresistible/main.inc +++ b/pawno/include/irresistible/main.inc @@ -29,12 +29,13 @@ // features #include < irresistible\features\fps > #include < irresistible\features\radio > +// #include < irresistible\features\vote > // visage casino #include < irresistible\features\visage\roulette > #include < irresistible\features\visage\blackjack > #include < irresistible\features\visage\poker > -// #include < irresistible\features\visage\fireworks > +#include < irresistible\features\visage\fireworks > #include < irresistible\features\visage\casino > #include < irresistible\features\visage\apartments >