Merged gangvehicles into master
This commit is contained in:
commit
370edb6c58
@ -34,3 +34,7 @@
|
|||||||
- Called when a player accesses an entrance id
|
- Called when a player accesses an entrance id
|
||||||
- `OnPlayerEndModelPreview( playerid, handleid )`
|
- `OnPlayerEndModelPreview( playerid, handleid )`
|
||||||
- Called when a player closes a model preview
|
- Called when a player closes a model preview
|
||||||
|
- `OnGangLoad( gangid )`
|
||||||
|
- Called when a gang is loaded
|
||||||
|
- `OnGangUnload( gangid, bool: deleted )`
|
||||||
|
- Called when a gang is unloaded (or deleted)
|
||||||
|
@ -10,4 +10,7 @@
|
|||||||
#include "irresistible\cnr\features\gangs\facilities.pwn"
|
#include "irresistible\cnr\features\gangs\facilities.pwn"
|
||||||
#include "irresistible\cnr\features\gangs\turfs.pwn"
|
#include "irresistible\cnr\features\gangs\turfs.pwn"
|
||||||
#include "irresistible\cnr\features\gangs\cannon.pwn"
|
#include "irresistible\cnr\features\gangs\cannon.pwn"
|
||||||
// #include "irresistible\features\gangs\gvehicles.pwn"
|
|
||||||
|
#if defined DEBUG_MODE
|
||||||
|
#include "irresistible\cnr\features\gangs\gvehicles.pwn"
|
||||||
|
#endif
|
||||||
|
@ -23,6 +23,10 @@
|
|||||||
// #define DIALOG_FACILITY_AMMU ( 9239 )
|
// #define DIALOG_FACILITY_AMMU ( 9239 )
|
||||||
// #define DIALOG_FACILITY_AMMU_BUY ( 9299 )
|
// #define DIALOG_FACILITY_AMMU_BUY ( 9299 )
|
||||||
|
|
||||||
|
/* ** Macros ** */
|
||||||
|
#define Facility_IsValid(%0) \
|
||||||
|
(0 <= %0 < MAX_FACILITIES && Iter_Contains(gangfacilities, %0))
|
||||||
|
|
||||||
/* ** Variables ** */
|
/* ** Variables ** */
|
||||||
enum E_GANG_FACILITIES
|
enum E_GANG_FACILITIES
|
||||||
{
|
{
|
||||||
@ -34,7 +38,7 @@ enum E_GANG_FACILITIES
|
|||||||
Float: E_X, Float: E_Y, Float: E_Z,
|
Float: E_X, Float: E_Y, Float: E_Z,
|
||||||
|
|
||||||
E_AMMU_CP, E_SHOP_CP, E_CANNON_CP,
|
E_AMMU_CP, E_SHOP_CP, E_CANNON_CP,
|
||||||
E_TRAVEL_CP,
|
E_TRAVEL_CP, E_MECHANIC_CP,
|
||||||
|
|
||||||
bool: E_WAR, E_WAR_TIMER, E_WAR_TICK,
|
bool: E_WAR, E_WAR_TIMER, E_WAR_TICK,
|
||||||
|
|
||||||
@ -51,8 +55,8 @@ enum E_FACILITY_INTERIOR
|
|||||||
Float: E_TRAVEL_POS[ 4 ],
|
Float: E_TRAVEL_POS[ 4 ],
|
||||||
Float: E_ATM_POS[ 4 ],
|
Float: E_ATM_POS[ 4 ],
|
||||||
Float: E_BOMB_POS_1[ 4 ],
|
Float: E_BOMB_POS_1[ 4 ],
|
||||||
Float: E_BOMB_POS_2[ 4 ]
|
Float: E_BOMB_POS_2[ 4 ],
|
||||||
//Float: E_MECHANIC_POS[ 4 ]
|
Float: E_MECHANIC_POS[ 4 ]
|
||||||
};
|
};
|
||||||
|
|
||||||
new
|
new
|
||||||
@ -66,8 +70,9 @@ new
|
|||||||
{ 259.9110, 1850.9300, 1858.7600, 0.000000 },
|
{ 259.9110, 1850.9300, 1858.7600, 0.000000 },
|
||||||
{ 261.0079, 1869.5808, 1858.7600, 90.00000 },
|
{ 261.0079, 1869.5808, 1858.7600, 90.00000 },
|
||||||
{ 262.5575, 1850.0053, 1858.3671, 180.0000 },
|
{ 262.5575, 1850.0053, 1858.3671, 180.0000 },
|
||||||
{ 246.722503, 1816.183593, 1855.371826, 90.000000 },
|
{ 246.7225, 1816.1835, 1855.3718, 90.00000 },
|
||||||
{ 246.722503, 1827.754516, 1855.371826, 90.000000 }
|
{ 246.7225, 1827.7545, 1855.3718, 90.00000 },
|
||||||
|
{ 244.6742, 1843.2554, 1858.7576, 0.000000 }
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
g_gangFacilities [ MAX_FACILITIES ] [ E_GANG_FACILITIES ],
|
g_gangFacilities [ MAX_FACILITIES ] [ E_GANG_FACILITIES ],
|
||||||
@ -167,6 +172,12 @@ hook OnPlayerEnterDynamicCP( playerid, checkpointid )
|
|||||||
return ShowPlayerAirportMenu( playerid );
|
return ShowPlayerAirportMenu( playerid );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// mechanic
|
||||||
|
else if ( checkpointid == g_gangFacilities[ facility ] [ E_MECHANIC_CP ] )
|
||||||
|
{
|
||||||
|
return ShowPlayerGangVehicleMenu( playerid, facility );
|
||||||
|
}
|
||||||
|
|
||||||
// orbital cannon
|
// orbital cannon
|
||||||
else if ( checkpointid == g_gangFacilities[ facility ] [ E_CANNON_CP ] )
|
else if ( checkpointid == g_gangFacilities[ facility ] [ E_CANNON_CP ] )
|
||||||
{
|
{
|
||||||
@ -443,11 +454,19 @@ thread OnGangFaciltiesLoad( )
|
|||||||
g_gangFacilities[ id ] [ E_TRAVEL_CP ] = CreateDynamicCP( infront_x, infront_y, g_gangFacilityInterior[ type ] [ E_TRAVEL_POS ] [ 2 ], 1.0, .worldid = g_gangFacilities[ id ] [ E_WORLD ] );
|
g_gangFacilities[ id ] [ E_TRAVEL_CP ] = CreateDynamicCP( infront_x, infront_y, g_gangFacilityInterior[ type ] [ E_TRAVEL_POS ] [ 2 ], 1.0, .worldid = g_gangFacilities[ id ] [ E_WORLD ] );
|
||||||
CreateDynamic3DTextLabel( "[FAST TRAVEL]", COLOR_GOLD, infront_x, infront_y, g_gangFacilityInterior[ type ] [ E_TRAVEL_POS ] [ 2 ], 20.0, .worldid = g_gangFacilities[ id ] [ E_WORLD ] );
|
CreateDynamic3DTextLabel( "[FAST TRAVEL]", COLOR_GOLD, infront_x, infront_y, g_gangFacilityInterior[ type ] [ E_TRAVEL_POS ] [ 2 ], 20.0, .worldid = g_gangFacilities[ id ] [ E_WORLD ] );
|
||||||
|
|
||||||
|
// mechanic actor
|
||||||
|
CreateDynamicActor( 268, g_gangFacilityInterior[ type ] [ E_MECHANIC_POS ] [ 0 ], g_gangFacilityInterior[ type ] [ E_MECHANIC_POS ] [ 1 ], g_gangFacilityInterior[ type ] [ E_MECHANIC_POS ] [ 2 ], g_gangFacilityInterior[ type ] [ E_MECHANIC_POS ] [ 3 ], true, 100.0, .worldid = g_gangFacilities[ id ] [ E_WORLD ] );
|
||||||
|
|
||||||
|
infront_x = g_gangFacilityInterior[ type ] [ E_MECHANIC_POS ] [ 0 ] + 2.0 * floatsin( -g_gangFacilityInterior[ type ] [ E_MECHANIC_POS ] [ 3 ], degrees );
|
||||||
|
infront_y = g_gangFacilityInterior[ type ] [ E_MECHANIC_POS ] [ 1 ] + 2.0 * floatcos( -g_gangFacilityInterior[ type ] [ E_MECHANIC_POS ] [ 3 ], degrees );
|
||||||
|
|
||||||
|
g_gangFacilities[ id ] [ E_MECHANIC_CP ] = CreateDynamicCP( infront_x, infront_y, g_gangFacilityInterior[ type ] [ E_MECHANIC_POS ] [ 2 ], 1.0, .worldid = g_gangFacilities[ id ] [ E_WORLD ] );
|
||||||
|
CreateDynamic3DTextLabel( "[GANG VEHICLES]", COLOR_GOLD, infront_x, infront_y, g_gangFacilityInterior[ type ] [ E_MECHANIC_POS ] [ 2 ], 20.0, .worldid = g_gangFacilities[ id ] [ E_WORLD ] );
|
||||||
|
|
||||||
// create atm
|
// create atm
|
||||||
CreateATM( g_gangFacilityInterior[ type ] [ E_ATM_POS ] [ 0 ], g_gangFacilityInterior[ type ] [ E_ATM_POS ] [ 1 ], g_gangFacilityInterior[ type ] [ E_ATM_POS ] [ 2 ], g_gangFacilityInterior[ type ] [ E_ATM_POS ] [ 3 ], 0.0, g_gangFacilities[ id ] [ E_WORLD ] );
|
CreateATM( g_gangFacilityInterior[ type ] [ E_ATM_POS ] [ 0 ], g_gangFacilityInterior[ type ] [ E_ATM_POS ] [ 1 ], g_gangFacilityInterior[ type ] [ E_ATM_POS ] [ 2 ], g_gangFacilityInterior[ type ] [ E_ATM_POS ] [ 3 ], 0.0, g_gangFacilities[ id ] [ E_WORLD ] );
|
||||||
|
|
||||||
// more actors
|
// more actors
|
||||||
CreateDynamicActor( 268, 244.6742, 1843.2554, 1858.7576, 0.000000, true, 100.0, .worldid = g_gangFacilities[ id ] [ E_WORLD ] );
|
|
||||||
ApplyDynamicActorAnimation( CreateDynamicActor( 70, 212.868576, 1819.894531, 1856.413818, 117.200050, true, 100.0, .worldid = g_gangFacilities[ id ] [ E_WORLD ] ), "COP_AMBIENT", "Coplook_loop", 4.1, 1, 1, 1, 1, 0 );
|
ApplyDynamicActorAnimation( CreateDynamicActor( 70, 212.868576, 1819.894531, 1856.413818, 117.200050, true, 100.0, .worldid = g_gangFacilities[ id ] [ E_WORLD ] ), "COP_AMBIENT", "Coplook_loop", 4.1, 1, 1, 1, 1, 0 );
|
||||||
ApplyDynamicActorAnimation( CreateDynamicActor( 70, 213.705627, 1827.192993, 1856.413818, 60.300289, true, 100.0, .worldid = g_gangFacilities[ id ] [ E_WORLD ] ), "COP_AMBIENT", "Coplook_think", 4.1, 1, 1, 1, 1, 0 );
|
ApplyDynamicActorAnimation( CreateDynamicActor( 70, 213.705627, 1827.192993, 1856.413818, 60.300289, true, 100.0, .worldid = g_gangFacilities[ id ] [ E_WORLD ] ), "COP_AMBIENT", "Coplook_think", 4.1, 1, 1, 1, 1, 0 );
|
||||||
|
|
||||||
@ -497,12 +516,18 @@ stock GetFacilityInteriorType( gang_sql_id )
|
|||||||
}
|
}
|
||||||
|
|
||||||
stock GetGangIDFromFacilityID( facilityid ) {
|
stock GetGangIDFromFacilityID( facilityid ) {
|
||||||
foreach ( new f : gangs ) if ( g_gangFacilities[ facilityid ] [ E_GANG_SQL_ID ] == g_gangData[ g ] [ E_SQL_ID ] ) {
|
foreach ( new f : gangs ) if ( g_gangFacilities[ facilityid ] [ E_GANG_SQL_ID ] == g_gangData[ f ] [ E_SQL_ID ] ) {
|
||||||
return f;
|
return f;
|
||||||
}
|
}
|
||||||
return ITER_NONE;
|
return ITER_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
stock GetGangFacilityPos( facilityid, &Float: X, &Float: Y, &Float: Z ) {
|
||||||
|
X = g_gangFacilities[ facilityid ] [ E_X ];
|
||||||
|
Y = g_gangFacilities[ facilityid ] [ E_Y ];
|
||||||
|
Z = g_gangFacilities[ facilityid ] [ E_Z ];
|
||||||
|
}
|
||||||
|
|
||||||
#if FACILITY_TAKEOVER_ENABLED == true
|
#if FACILITY_TAKEOVER_ENABLED == true
|
||||||
CMD:plant( playerid, params[ ] ) {
|
CMD:plant( playerid, params[ ] ) {
|
||||||
PlantFacilityC4( playerid, GetPVarInt( playerid, "in_facility" ) );
|
PlantFacilityC4( playerid, GetPVarInt( playerid, "in_facility" ) );
|
||||||
|
@ -16,8 +16,11 @@
|
|||||||
|
|
||||||
/* ** Macros ** */
|
/* ** Macros ** */
|
||||||
#define IsGangPrivate(%0) ( g_gangData[ %0 ] [ E_INVITE_ONLY ] )
|
#define IsGangPrivate(%0) ( g_gangData[ %0 ] [ E_INVITE_ONLY ] )
|
||||||
|
#define GetGangSqlID(%0) ( g_gangData[ %0 ] [ E_SQL_ID ] )
|
||||||
#define GetPlayerGang(%0) ( p_GangID[ %0 ] )
|
#define GetPlayerGang(%0) ( p_GangID[ %0 ] )
|
||||||
|
|
||||||
|
#define IsValidGangID(%0) (0 <= %0 < MAX_GANGS && Iter_Contains(gangs, %0))
|
||||||
|
|
||||||
/* ** Variables ** */
|
/* ** Variables ** */
|
||||||
enum e_gang_data
|
enum e_gang_data
|
||||||
{
|
{
|
||||||
@ -764,6 +767,9 @@ stock CreateGang( const gang_name[ 30 ], leader, gang_color, kills = 1, deaths =
|
|||||||
g_gangData[ handle ] [ E_RESPECT ] = respect;
|
g_gangData[ handle ] [ E_RESPECT ] = respect;
|
||||||
g_gangData[ handle ] [ E_INVITE_ONLY ] = invite_only;
|
g_gangData[ handle ] [ E_INVITE_ONLY ] = invite_only;
|
||||||
g_gangData[ handle ] [ E_HAS_FACILITY ] = has_facility;
|
g_gangData[ handle ] [ E_HAS_FACILITY ] = has_facility;
|
||||||
|
|
||||||
|
// callback
|
||||||
|
CallLocalFunction( "OnGangLoad", "d", handle );
|
||||||
}
|
}
|
||||||
return handle;
|
return handle;
|
||||||
}
|
}
|
||||||
@ -786,6 +792,9 @@ stock DestroyGang( gangid, bool: soft_delete, bool: iter_remove = true )
|
|||||||
p_GangID[ i ] = INVALID_GANG_ID;
|
p_GangID[ i ] = INVALID_GANG_ID;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Callback
|
||||||
|
CallLocalFunction( "OnGangUnload", "dd", gangid, ! soft_delete );
|
||||||
|
|
||||||
// Reset gang data
|
// Reset gang data
|
||||||
g_gangData[ gangid ] [ E_SQL_ID ] = 0;
|
g_gangData[ gangid ] [ E_SQL_ID ] = 0;
|
||||||
g_gangData[ gangid ] [ E_LEADER ] = 0;
|
g_gangData[ gangid ] [ E_LEADER ] = 0;
|
||||||
@ -979,6 +988,7 @@ stock SetPlayerGang( playerid, joining_gang )
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
stock GetGangCash( gangid ) return g_gangData[ gangid ] [ E_BANK ];
|
||||||
stock GiveGangCash( gangid, cash ) {
|
stock GiveGangCash( gangid, cash ) {
|
||||||
g_gangData[ gangid ] [ E_BANK ] += cash;
|
g_gangData[ gangid ] [ E_BANK ] += cash;
|
||||||
}
|
}
|
||||||
|
@ -1,17 +1,691 @@
|
|||||||
/*
|
/*
|
||||||
* Irresistible Gaming (c) 2018
|
* Irresistible Gaming (c) 2018
|
||||||
* Developed by Lorenc Pekaj
|
* Developed by Lorenc Pekaj
|
||||||
* Module:
|
* Module: cnr\features\gangs\gvehicles.pwn
|
||||||
* Purpose:
|
* Purpose: gang vehicles (requires a gang facility to spawn the vehicles) for gangs
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* ** Includes ** */
|
/* ** Includes ** */
|
||||||
#include < YSI\y_hooks >
|
#include < YSI\y_hooks >
|
||||||
|
|
||||||
/* ** Definitions ** */
|
/* ** Definitions ** */
|
||||||
|
#define MAX_GANG_VEHICLES ( 5 )
|
||||||
|
|
||||||
|
#define DIALOG_GANG_VEHICLE_MENU 2399
|
||||||
|
#define DIALOG_GANG_VEHICLE_SPAWN 2400
|
||||||
|
#define DIALOG_GANG_VEHICLE_SELL 2401
|
||||||
|
#define DIALOG_GANG_VD_BUY 2402
|
||||||
|
#define DIALOG_GANG_VD_OPTIONS 2403
|
||||||
|
#define DIALOG_GANG_VD_CATEGORY 2404
|
||||||
|
|
||||||
|
#define PREVIEW_MODEL_GVEHICLE ( 6 )
|
||||||
|
|
||||||
|
/* ** Macros ** */
|
||||||
|
#define IsValidGangVehicle(%0,%1) \
|
||||||
|
( 0 <= %1 < MAX_GANG_VEHICLES && Iter_Contains( gangvehicles<%0>, %1 ) )
|
||||||
|
|
||||||
|
/* ** Constants ** */
|
||||||
|
static const GANG_VEHICLE_PRICE_FACTOR = 4;
|
||||||
|
static const GANG_VEHICLE_SPAWN_COOLDOWN = 180;
|
||||||
|
|
||||||
/* ** Variables ** */
|
/* ** Variables ** */
|
||||||
|
enum E_GANG_VEHICLE_DATA
|
||||||
|
{
|
||||||
|
E_SQL_ID, E_VEHICLE_ID, E_ACTIVATION_TIME,
|
||||||
|
|
||||||
|
E_COLOR[ 2 ], E_MODEL, E_PAINTJOB
|
||||||
|
};
|
||||||
|
|
||||||
|
new g_gangVehicleData [ MAX_GANGS ] [ MAX_GANG_VEHICLES ] [ E_GANG_VEHICLE_DATA ];
|
||||||
|
new g_gangVehicleModifications [ MAX_GANGS ] [ MAX_GANG_VEHICLES ] [ MAX_CAR_MODS ];
|
||||||
|
new Iterator: gangvehicles < MAX_GANGS, MAX_GANG_VEHICLES >;
|
||||||
|
new bool: g_gangVehicle [ MAX_VEHICLES char ];
|
||||||
|
|
||||||
/* ** Hooks ** */
|
/* ** Hooks ** */
|
||||||
|
hook OnDialogResponse( playerid, dialogid, response, listitem, inputtext[ ] )
|
||||||
|
{
|
||||||
|
new
|
||||||
|
current_time = GetServerTime( );
|
||||||
|
|
||||||
|
if ( dialogid == DIALOG_GANG_VEHICLE_MENU && response )
|
||||||
|
{
|
||||||
|
new gangid = GetPVarInt( playerid, "gang_vehicle_gang" );
|
||||||
|
new facilityid = GetPVarInt( playerid, "gang_vehicle_facility" );
|
||||||
|
|
||||||
|
if ( ! IsValidGangID ( gangid ) || ! Facility_IsValid( facilityid ) ) {
|
||||||
|
return SendError( playerid, "There was an error processing gang vehicles, please try again." );
|
||||||
|
}
|
||||||
|
|
||||||
|
switch ( listitem )
|
||||||
|
{
|
||||||
|
// spawn vehicle
|
||||||
|
case 0:
|
||||||
|
{
|
||||||
|
if ( ! Iter_Count( gangvehicles< gangid > ) ) {
|
||||||
|
SendError( playerid, "This gang does not have any vehicles purchased." );
|
||||||
|
return ShowPlayerGangVehicleMenu( playerid, facilityid );
|
||||||
|
}
|
||||||
|
|
||||||
|
return GangVehicles_ShowSpawnList( playerid, gangid );
|
||||||
|
}
|
||||||
|
|
||||||
|
// buy vehicle
|
||||||
|
case 1: ShowBuyableVehiclesList( playerid, DIALOG_GANG_VD_CATEGORY, "Back" );
|
||||||
|
|
||||||
|
// sell vehicle
|
||||||
|
case 2:
|
||||||
|
{
|
||||||
|
if ( ! Iter_Count( gangvehicles< gangid > ) ) {
|
||||||
|
SendError( playerid, "This gang does not have any vehicles purchased." );
|
||||||
|
return ShowPlayerGangVehicleMenu( playerid, facilityid );
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( ! IsPlayerGangLeader( playerid, gangid ) ) {
|
||||||
|
SendError( playerid, "You are not the leader of this gang." );
|
||||||
|
return ShowPlayerGangVehicleMenu( playerid, facilityid );
|
||||||
|
}
|
||||||
|
|
||||||
|
szBigString = ""COL_WHITE"Vehicle\t"COL_WHITE"Sell Price\n";
|
||||||
|
|
||||||
|
foreach ( new slotid : gangvehicles< gangid > )
|
||||||
|
{
|
||||||
|
new
|
||||||
|
sell_price = ( GetBuyableVehiclePrice( g_gangVehicleData[ gangid ] [ slotid ] [ E_MODEL ] ) * GANG_VEHICLE_PRICE_FACTOR ) / 2;
|
||||||
|
|
||||||
|
format( szBigString, sizeof( szBigString ), "%s%s\t"COL_GOLD"%s\n", szBigString, GetVehicleName( g_gangVehicleData[ gangid ] [ slotid ] [ E_MODEL ] ), cash_format( sell_price ) );
|
||||||
|
}
|
||||||
|
return ShowPlayerDialog( playerid, DIALOG_GANG_VEHICLE_SELL, DIALOG_STYLE_TABLIST_HEADERS, ""COL_WHITE"Gang Vehicles - Sell", szBigString, "Sell", "Back" );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
else if ( dialogid == DIALOG_GANG_VEHICLE_SELL )
|
||||||
|
{
|
||||||
|
new gangid = GetPVarInt( playerid, "gang_vehicle_gang" );
|
||||||
|
new facilityid = GetPVarInt( playerid, "gang_vehicle_facility" );
|
||||||
|
|
||||||
|
if ( ! IsValidGangID ( gangid ) || ! Facility_IsValid( facilityid ) ) {
|
||||||
|
return SendError( playerid, "There was an error processing gang vehicles, please try again." );
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( ! response ) {
|
||||||
|
return ShowPlayerGangVehicleMenu( playerid, facilityid );
|
||||||
|
}
|
||||||
|
|
||||||
|
new
|
||||||
|
x = 0;
|
||||||
|
|
||||||
|
foreach ( new slotid : gangvehicles< gangid > )
|
||||||
|
{
|
||||||
|
if ( x == listitem )
|
||||||
|
{
|
||||||
|
if ( ! IsPlayerGangLeader( playerid, gangid ) ) {
|
||||||
|
return SendError( playerid, "You are not the leader of this gang." );
|
||||||
|
}
|
||||||
|
|
||||||
|
new
|
||||||
|
sell_price = ( GetBuyableVehiclePrice( g_gangVehicleData[ gangid ] [ slotid ] [ E_MODEL ] ) * GANG_VEHICLE_PRICE_FACTOR ) / 2;
|
||||||
|
|
||||||
|
GiveGangCash( gangid, sell_price );
|
||||||
|
SendServerMessage( playerid, "You have sold %s's %s for "COL_GOLD"%s"COL_WHITE".", g_gangData[ gangid ] [ E_NAME ], GetVehicleName( g_gangVehicleData[ gangid ] [ slotid ] [ E_MODEL ] ), cash_format( sell_price ) );
|
||||||
|
|
||||||
|
DestroyGangVehicle( gangid, slotid );
|
||||||
|
ShowPlayerGangVehicleMenu( playerid, facilityid );
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
x ++;
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
else if ( dialogid == DIALOG_GANG_VD_BUY )
|
||||||
|
{
|
||||||
|
if ( response )
|
||||||
|
{
|
||||||
|
new
|
||||||
|
type_id = GetPVarInt( playerid, "vehicle_preview" );
|
||||||
|
|
||||||
|
for ( new id = 0, x = 0; id < sizeof( g_BuyableVehicleData ); id ++ )
|
||||||
|
{
|
||||||
|
if ( g_BuyableVehicleData[ id ] [ E_TYPE ] == type_id )
|
||||||
|
{
|
||||||
|
if ( x == listitem )
|
||||||
|
{
|
||||||
|
SetPVarInt( playerid, "buying_vehicle", id );
|
||||||
|
ShowPlayerDialog( playerid, DIALOG_GANG_VD_OPTIONS, DIALOG_STYLE_LIST, "{FFFFFF}Gang Vehicles - Purchase", "Purchase This Vehicle\nPreview Vehicle", "Select", "Back" );
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
x++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ShowBuyableVehiclesList( playerid, DIALOG_GANG_VD_CATEGORY, "Back" );
|
||||||
|
}
|
||||||
|
else if ( dialogid == DIALOG_GANG_VD_OPTIONS )
|
||||||
|
{
|
||||||
|
new gangid = GetPVarInt( playerid, "gang_vehicle_gang" );
|
||||||
|
new facilityid = GetPVarInt( playerid, "gang_vehicle_facility" );
|
||||||
|
|
||||||
|
if ( ! IsValidGangID ( gangid ) || ! Facility_IsValid( facilityid ) ) {
|
||||||
|
return SendError( playerid, "There was an error processing gang vehicles, please try again." );
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( ! response ) {
|
||||||
|
return GangVehicles_ShowBuyableList( playerid, GetPVarInt( playerid, "vehicle_preview" ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
switch ( listitem )
|
||||||
|
{
|
||||||
|
// bought the vehicle
|
||||||
|
case 0:
|
||||||
|
{
|
||||||
|
if ( ! IsPlayerGangLeader( playerid, gangid ) ) {
|
||||||
|
ShowPlayerDialog( playerid, DIALOG_GANG_VD_OPTIONS, DIALOG_STYLE_LIST, "{FFFFFF}Gang Vehicles - Purchase", "Purchase This Vehicle\nPreview Vehicle", "Select", "Back" );
|
||||||
|
return SendError( playerid, "You are not the leader of this gang." );
|
||||||
|
}
|
||||||
|
|
||||||
|
new
|
||||||
|
num_vehicles = Iter_Count( gangvehicles< gangid > );
|
||||||
|
|
||||||
|
if ( num_vehicles >= MAX_GANG_VEHICLES ) {
|
||||||
|
ShowPlayerDialog( playerid, DIALOG_GANG_VD_OPTIONS, DIALOG_STYLE_LIST, "{FFFFFF}Gang Vehicles - Purchase", "Purchase This Vehicle\nPreview Vehicle", "Select", "Back" );
|
||||||
|
return SendError( playerid, "Your gang has reached the gang vehicle limit of %d.", MAX_GANG_VEHICLES );
|
||||||
|
}
|
||||||
|
|
||||||
|
new
|
||||||
|
data_id = GetPVarInt( playerid, "buying_vehicle" );
|
||||||
|
|
||||||
|
// VIP Check
|
||||||
|
if ( g_BuyableVehicleData[ data_id ] [ E_VIP ] )
|
||||||
|
{
|
||||||
|
if ( p_VIPLevel[ playerid ] < VIP_REGULAR ) {
|
||||||
|
ShowPlayerDialog( playerid, DIALOG_GANG_VD_OPTIONS, DIALOG_STYLE_LIST, "{FFFFFF}Gang Vehicles - Purchase", "Purchase This Vehicle\nPreview Vehicle", "Select", "Back" );
|
||||||
|
return SendError( playerid, "You are not a V.I.P, to become one visit "COL_GREY"donate.sfcnr.com" );
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( ( ( p_VIPExpiretime[ playerid ] - g_iTime ) / 86400 ) < 3 ) {
|
||||||
|
ShowPlayerDialog( playerid, DIALOG_GANG_VD_OPTIONS, DIALOG_STYLE_LIST, "{FFFFFF}Gang Vehicles - Purchase", "Purchase This Vehicle\nPreview Vehicle", "Select", "Back" );
|
||||||
|
return SendError( playerid, "You need more than 3 days of V.I.P in order to complete this." );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
new
|
||||||
|
final_price = g_BuyableVehicleData[ data_id ] [ E_PRICE ] * GANG_VEHICLE_PRICE_FACTOR;
|
||||||
|
|
||||||
|
// Money check
|
||||||
|
if ( GetGangCash( gangid ) < final_price ) {
|
||||||
|
ShowPlayerDialog( playerid, DIALOG_GANG_VD_OPTIONS, DIALOG_STYLE_LIST, "{FFFFFF}Gang Vehicles - Purchase", "Purchase This Vehicle\nPreview Vehicle", "Select", "Back" );
|
||||||
|
return SendError( playerid, "Your gang does not have enough money for this vehicle (%s).", cash_format( final_price ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
new
|
||||||
|
slotid = CreateGangVehicle( gangid, g_BuyableVehicleData[ data_id ] [ E_MODEL ] );
|
||||||
|
|
||||||
|
if ( slotid == ITER_NONE ) {
|
||||||
|
ShowPlayerDialog( playerid, DIALOG_GANG_VD_OPTIONS, DIALOG_STYLE_LIST, "{FFFFFF}Gang Vehicles - Purchase", "Purchase This Vehicle\nPreview Vehicle", "Select", "Back" );
|
||||||
|
return SendError( playerid, "Your gang has reached the gang vehicle limit of %d.", MAX_GANG_VEHICLES );
|
||||||
|
}
|
||||||
|
|
||||||
|
GiveGangCash( gangid, -final_price );
|
||||||
|
StockMarket_UpdateEarnings( E_STOCK_VEHICLE_DEALERSHIP, final_price, 0.05 );
|
||||||
|
|
||||||
|
printf( "[gang vehicle] %s(%d) bought %s for %s", ReturnPlayerName( playerid ), GetPlayerAccountID( playerid ), g_BuyableVehicleData[ data_id ] [ E_NAME ], g_gangData[ gangid ] [ E_NAME ] );
|
||||||
|
SendServerMessage( playerid, "You have bought an "COL_GREY"%s"COL_WHITE" for "COL_GOLD"%s"COL_WHITE"!", g_BuyableVehicleData[ data_id ] [ E_NAME ], cash_format( final_price ) );
|
||||||
|
SendServerMessage( playerid, "You can spawn this vehicle using the mechanic at any gang facility.", g_BuyableVehicleData[ data_id ] [ E_NAME ], cash_format( final_price ) );
|
||||||
|
return ShowPlayerGangVehicleMenu( playerid, facilityid );
|
||||||
|
}
|
||||||
|
|
||||||
|
// preview
|
||||||
|
case 1:
|
||||||
|
{
|
||||||
|
return ShowPlayerModelPreview( playerid, PREVIEW_MODEL_GVEHICLE, "Gang Vehicle Preview", g_BuyableVehicleData[ GetPVarInt( playerid, "buying_vehicle" ) ] [ E_MODEL ] );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
else if ( dialogid == DIALOG_GANG_VD_CATEGORY )
|
||||||
|
{
|
||||||
|
new gangid = GetPVarInt( playerid, "gang_vehicle_gang" );
|
||||||
|
new facilityid = GetPVarInt( playerid, "gang_vehicle_facility" );
|
||||||
|
|
||||||
|
if ( ! IsValidGangID ( gangid ) || ! Facility_IsValid( facilityid ) ) {
|
||||||
|
return SendError( playerid, "There was an error processing gang vehicles, please try again." );
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( ! response ) {
|
||||||
|
return ShowPlayerGangVehicleMenu( playerid, facilityid );
|
||||||
|
}
|
||||||
|
|
||||||
|
return GangVehicles_ShowBuyableList( playerid, listitem + 1 );
|
||||||
|
}
|
||||||
|
else if ( dialogid == DIALOG_GANG_VEHICLE_SPAWN )
|
||||||
|
{
|
||||||
|
new gangid = GetPVarInt( playerid, "gang_vehicle_gang" );
|
||||||
|
new facilityid = GetPVarInt( playerid, "gang_vehicle_facility" );
|
||||||
|
|
||||||
|
if ( ! IsValidGangID ( gangid ) || ! Facility_IsValid( facilityid ) ) {
|
||||||
|
return SendError( playerid, "There was an error processing gang vehicles, please try again." );
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( ! response ) {
|
||||||
|
return ShowPlayerGangVehicleMenu( playerid, facilityid );
|
||||||
|
}
|
||||||
|
|
||||||
|
new
|
||||||
|
x = 0;
|
||||||
|
|
||||||
|
foreach ( new slotid : gangvehicles< gangid > )
|
||||||
|
{
|
||||||
|
if ( x == listitem )
|
||||||
|
{
|
||||||
|
if ( g_gangVehicleData[ gangid ] [ slotid ] [ E_ACTIVATION_TIME ] > current_time ) {
|
||||||
|
GangVehicles_ShowSpawnList( playerid, gangid );
|
||||||
|
return SendError( playerid, "This vehicle cannot be spawned for another %s.", secondstotime( g_gangVehicleData[ gangid ] [ slotid ] [ E_ACTIVATION_TIME ] - current_time ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
new Float: facility_x, Float: facility_y, Float: facility_z, Float: rotation;
|
||||||
|
GetGangFacilityPos( facilityid, facility_x, facility_y, facility_z );
|
||||||
|
|
||||||
|
// find nearest dock
|
||||||
|
if ( IsBoatVehicle( g_gangVehicleData[ gangid ] [ slotid ] [ E_MODEL ] ) ) {
|
||||||
|
GetClosestBoatPort( facility_x, facility_y, facility_z, facility_x, facility_y, facility_z );
|
||||||
|
}
|
||||||
|
|
||||||
|
// spawn air vehicles in the sky
|
||||||
|
else if ( IsAirVehicle( g_gangVehicleData[ gangid ] [ slotid ] [ E_MODEL ] ) ) {
|
||||||
|
facility_z += 300.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// spawn vehicles at the closest road
|
||||||
|
else {
|
||||||
|
new Float: nodeX, Float: nodeY, Float: nodeZ, Float: nextX, Float: nextY;
|
||||||
|
new nodeid = NearestNodeFromPoint( facility_x, facility_y, facility_z );
|
||||||
|
new nextNodeid = NearestNodeFromPoint( facility_x, facility_y, facility_z, 9999.9, nodeid );
|
||||||
|
|
||||||
|
GetNodePos( nextNodeid, nextX, nextY, nodeZ );
|
||||||
|
GetNodePos( nodeid, nodeX, nodeY, nodeZ );
|
||||||
|
|
||||||
|
rotation = atan2( nextY - nodeY, nextX - nodeX ) - 90.0;
|
||||||
|
|
||||||
|
facility_x = nodeX, facility_y = nodeY, facility_z = nodeZ;
|
||||||
|
}
|
||||||
|
|
||||||
|
new
|
||||||
|
vehicleid = SpawnGangVehicle( gangid, slotid, facility_x, facility_y, facility_z + 2.0, rotation );
|
||||||
|
|
||||||
|
if ( vehicleid ) {
|
||||||
|
SetPlayerInterior( playerid, 0 );
|
||||||
|
SetPlayerVirtualWorld( playerid, 0 );
|
||||||
|
PutPlayerInVehicle( playerid, vehicleid, 0 );
|
||||||
|
} else {
|
||||||
|
SendError( playerid, "Could not spawn gang vehicle due to an unexpected error." );
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
x ++;
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
hook OnGangLoad( gangid )
|
||||||
|
{
|
||||||
|
mysql_tquery( dbHandle, sprintf( "SELECT * FROM `GANG_VEHICLES` WHERE `GANG_ID` = %d ", GetGangSqlID( gangid ) ), "GangVehicles_LoadVehicles", "d", gangid );
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
hook OnGangUnload( gangid, bool: deleted )
|
||||||
|
{
|
||||||
|
foreach ( new slotid : gangvehicles< gangid > ) {
|
||||||
|
RemoveGangVehicle( gangid, slotid );
|
||||||
|
Iter_SafeRemove( gangvehicles< gangid >, slotid, slotid );
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
hook OnPlayerEndModelPreview( playerid, handleid )
|
||||||
|
{
|
||||||
|
if ( handleid == PREVIEW_MODEL_GVEHICLE )
|
||||||
|
{
|
||||||
|
SendServerMessage( playerid, "You have finished looking at the gang vehicle preview." );
|
||||||
|
ShowPlayerDialog( playerid, DIALOG_GANG_VD_OPTIONS, DIALOG_STYLE_LIST, "{FFFFFF}Gang Vehicles - Purchase", "Purchase This Vehicle\nPreview Vehicle", "Select", "Back" );
|
||||||
|
return Y_HOOKS_BREAK_RETURN_1;
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
hook OnEnterExitModShop( playerid, enterexit, interiorid )
|
||||||
|
{
|
||||||
|
if ( enterexit == 0 )
|
||||||
|
{
|
||||||
|
new
|
||||||
|
vehicleid = GetPlayerVehicleID( playerid );
|
||||||
|
|
||||||
|
if ( IsValidVehicle( vehicleid ) )
|
||||||
|
{
|
||||||
|
if ( g_gangVehicle{ vehicleid } )
|
||||||
|
{
|
||||||
|
new
|
||||||
|
gangid, slotid;
|
||||||
|
|
||||||
|
GetGangVehicleData( vehicleid, gangid, slotid );
|
||||||
|
|
||||||
|
printf("%d %d", gangid, slotid );
|
||||||
|
|
||||||
|
if ( IsValidGangID( gangid ) && IsValidGangVehicle( gangid, slotid ) )
|
||||||
|
{
|
||||||
|
new
|
||||||
|
szMods[ MAX_CAR_MODS * 10 ];
|
||||||
|
|
||||||
|
// save vehicle mods to variable
|
||||||
|
for ( new i = 0; i < MAX_CAR_MODS; i ++ )
|
||||||
|
{
|
||||||
|
// check if valid mod
|
||||||
|
if ( ( g_gangVehicleModifications[ gangid ] [ slotid ] [ i ] = GetVehicleComponentInSlot( vehicleid, i ) ) < 1000 ) {
|
||||||
|
g_gangVehicleModifications[ gangid ] [ slotid ] [ i ] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// save as a sql delimited string
|
||||||
|
format( szMods, sizeof( szMods ), "%s%d.", szMods, g_gangVehicleModifications[ gangid ] [ slotid ] [ i ] );
|
||||||
|
}
|
||||||
|
|
||||||
|
// update sql
|
||||||
|
mysql_format( dbHandle, szBigString, sizeof( szBigString ), "UPDATE `GANG_VEHICLES` SET `MODS`='%e' WHERE `ID`=%d", szMods, g_gangVehicleData[ gangid ] [ slotid ] [ E_SQL_ID ] );
|
||||||
|
mysql_single_query( szBigString );
|
||||||
|
print( szBigString );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
hook OnVehicleSpawn( vehicleid )
|
||||||
|
{
|
||||||
|
if ( g_gangVehicle{ vehicleid } )
|
||||||
|
{
|
||||||
|
new
|
||||||
|
gangid, slotid;
|
||||||
|
|
||||||
|
GetGangVehicleData( vehicleid, gangid, slotid );
|
||||||
|
|
||||||
|
if ( IsValidGangID( gangid ) && IsValidGangVehicle( gangid, slotid ) ) {
|
||||||
|
RemoveGangVehicle( gangid, slotid );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
hook OnVehiclePaintjob( playerid, vehicleid, paintjobid )
|
||||||
|
{
|
||||||
|
if ( g_gangVehicle{ vehicleid } )
|
||||||
|
{
|
||||||
|
new
|
||||||
|
gangid, slotid;
|
||||||
|
|
||||||
|
GetGangVehicleData( vehicleid, gangid, slotid );
|
||||||
|
|
||||||
|
if ( IsValidGangID( gangid ) && IsValidGangVehicle( gangid, slotid ) )
|
||||||
|
{
|
||||||
|
g_gangVehicleData[ gangid ] [ slotid ] [ E_PAINTJOB ] = paintjobid;
|
||||||
|
mysql_single_query( sprintf( "UPDATE `GANG_VEHICLES` SET `PAINTJOB` = %d WHERE `ID` = %d", paintjobid, g_gangVehicleData[ gangid ] [ slotid ] [ E_SQL_ID ] ) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
hook OnVehicleRespray( playerid, vehicleid, color1, color2 )
|
||||||
|
{
|
||||||
|
if ( g_gangVehicle{ vehicleid } )
|
||||||
|
{
|
||||||
|
new
|
||||||
|
gangid, slotid;
|
||||||
|
|
||||||
|
GetGangVehicleData( vehicleid, gangid, slotid );
|
||||||
|
|
||||||
|
if ( IsValidGangID( gangid ) && IsValidGangVehicle( gangid, slotid ) )
|
||||||
|
{
|
||||||
|
g_gangVehicleData[ gangid ] [ slotid ] [ E_COLOR ] [ 0 ] = color1;
|
||||||
|
g_gangVehicleData[ gangid ] [ slotid ] [ E_COLOR ] [ 1 ] = color2;
|
||||||
|
mysql_single_query( sprintf( "UPDATE `GANG_VEHICLES` SET `COLOR1` = %d, `COLOR2` = %d WHERE `ID` = %d", color1, color2, g_gangVehicleData[ gangid ] [ slotid ] [ E_SQL_ID ] ) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
hook OnPlayerDriveVehicle( playerid, vehicleid )
|
||||||
|
{
|
||||||
|
if ( g_gangVehicle{ vehicleid } )
|
||||||
|
{
|
||||||
|
new
|
||||||
|
gangid, slotid;
|
||||||
|
|
||||||
|
GetGangVehicleData( vehicleid, gangid, slotid );
|
||||||
|
|
||||||
|
if ( IsValidGangID( gangid ) && IsValidGangVehicle( gangid, slotid ) )
|
||||||
|
{
|
||||||
|
new
|
||||||
|
player_gang = GetPlayerGang( playerid );
|
||||||
|
|
||||||
|
if ( player_gang == gangid )
|
||||||
|
{
|
||||||
|
SendClientMessageFormatted( playerid, g_gangData[ gangid ] [ E_COLOR ], "[GANG VEHICLE]"COL_WHITE" Welcome to %s's vehicle.", g_gangData[ gangid ] [ E_NAME ] );
|
||||||
|
Beep( playerid );
|
||||||
|
}
|
||||||
|
else if ( ! IsPlayerAdminOnDuty( playerid ) )
|
||||||
|
{
|
||||||
|
SyncObject( playerid, 1 ); // Just sets the players position where the vehicle is.
|
||||||
|
SendError( playerid, "This vehicle is restricted to gang members of %s.", g_gangData[ gangid ] [ E_NAME ] );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ** SQL Threads ** */
|
||||||
|
thread GangVehicles_LoadVehicles( gangid )
|
||||||
|
{
|
||||||
|
new
|
||||||
|
rows = cache_get_row_count( );
|
||||||
|
|
||||||
|
if ( rows )
|
||||||
|
{
|
||||||
|
static
|
||||||
|
paintjob[ 90 ];
|
||||||
|
|
||||||
|
for ( new row = 0; row < rows; row ++ )
|
||||||
|
{
|
||||||
|
new slotid = CreateGangVehicle(
|
||||||
|
gangid,
|
||||||
|
cache_get_field_content_int( row, "MODEL_ID" ),
|
||||||
|
cache_get_field_content_int( row, "COLOR1" ),
|
||||||
|
cache_get_field_content_int( row, "COLOR2" ),
|
||||||
|
cache_get_field_content_int( row, "PAINTJOB" ),
|
||||||
|
cache_get_field_content_int( row, "ID" )
|
||||||
|
);
|
||||||
|
|
||||||
|
// load the paintjobs in
|
||||||
|
if ( slotid != ITER_NONE ) {
|
||||||
|
cache_get_field_content( row, "MODS", paintjob );
|
||||||
|
sscanf( paintjob, "p<.>e<ddddddddddddddd>", g_gangVehicleModifications[ gangid ] [ slotid ] );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
thread GangVehicles_InsertVehicle( gangid, slotid ) {
|
||||||
|
g_gangVehicleData[ gangid ] [ slotid ] [ E_SQL_ID ] = cache_insert_id( );
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
/* ** Functions ** */
|
/* ** Functions ** */
|
||||||
|
stock CreateGangVehicle( gangid, modelid, color1 = -1, color2 = -1, paintjob = 3, sql_id = -1 )
|
||||||
|
{
|
||||||
|
new
|
||||||
|
slotid = Iter_Free( gangvehicles< gangid > );
|
||||||
|
|
||||||
|
if ( slotid != ITER_NONE )
|
||||||
|
{
|
||||||
|
g_gangVehicleData[ gangid ] [ slotid ] [ E_ACTIVATION_TIME ] = 0;
|
||||||
|
g_gangVehicleData[ gangid ] [ slotid ] [ E_COLOR ] [ 0 ] = color1;
|
||||||
|
g_gangVehicleData[ gangid ] [ slotid ] [ E_COLOR ] [ 1 ] = color2;
|
||||||
|
g_gangVehicleData[ gangid ] [ slotid ] [ E_PAINTJOB ] = paintjob;
|
||||||
|
g_gangVehicleData[ gangid ] [ slotid ] [ E_MODEL ] = modelid;
|
||||||
|
g_gangVehicleData[ gangid ] [ slotid ] [ E_VEHICLE_ID ] = -1;
|
||||||
|
|
||||||
|
// insert if not exists
|
||||||
|
if ( sql_id != -1 ) {
|
||||||
|
g_gangVehicleData[ gangid ] [ slotid ] [ E_SQL_ID ] = sql_id;
|
||||||
|
} else {
|
||||||
|
mysql_format( dbHandle, szBigString, sizeof( szBigString ), "INSERT INTO `GANG_VEHICLES` (`GANG_ID`,`MODEL_ID`,`COLOR1`,`COLOR2`,`PAINTJOB`,`MODS`) VALUES (%d,%d,%d,%d,%d,'0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.')", GetGangSqlID( gangid ), modelid, color1, color2, paintjob );
|
||||||
|
mysql_tquery( dbHandle, szBigString, "GangVehicles_InsertVehicle", "dd", gangid, slotid );
|
||||||
|
}
|
||||||
|
|
||||||
|
ResetGangVehicleMods( gangid, slotid );
|
||||||
|
Iter_Add( gangvehicles< gangid >, slotid );
|
||||||
|
}
|
||||||
|
return slotid;
|
||||||
|
}
|
||||||
|
|
||||||
|
stock DestroyGangVehicle( gangid, slotid )
|
||||||
|
{
|
||||||
|
if ( Iter_Contains( gangvehicles< gangid >, slotid ) ) {
|
||||||
|
RemoveGangVehicle( gangid, slotid );
|
||||||
|
mysql_single_query( sprintf( "DELETE FROM `GANG_VEHICLES` WHERE `ID` = %d", g_gangVehicleData[ gangid ] [ slotid ] [ E_SQL_ID ] ) );
|
||||||
|
Iter_Remove( gangvehicles< gangid >, slotid );
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
stock RemoveGangVehicle( gangid, slotid )
|
||||||
|
{
|
||||||
|
if ( Iter_Contains( gangvehicles< gangid >, slotid ) ) {
|
||||||
|
if ( g_gangVehicleData[ gangid ] [ slotid ] [ E_VEHICLE_ID ] != -1 ) {
|
||||||
|
g_gangVehicle{ g_gangVehicleData[ gangid ] [ slotid ] [ E_VEHICLE_ID ] } = false;
|
||||||
|
}
|
||||||
|
DestroyVehicle( g_gangVehicleData[ gangid ] [ slotid ] [ E_VEHICLE_ID ] );
|
||||||
|
g_gangVehicleData[ gangid ] [ slotid ] [ E_VEHICLE_ID ] = -1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
stock SpawnGangVehicle( gangid, slotid, Float: X, Float: Y, Float: Z, Float: RZ )
|
||||||
|
{
|
||||||
|
new
|
||||||
|
vehicleid = 0;
|
||||||
|
|
||||||
|
if ( Iter_Contains( gangvehicles< gangid >, slotid ) )
|
||||||
|
{
|
||||||
|
// reset special data
|
||||||
|
ResetVehicleMethlabData( g_gangVehicleData[ gangid ] [ slotid ] [ E_VEHICLE_ID ], true );
|
||||||
|
|
||||||
|
// make sure vehicle does not exist
|
||||||
|
RemoveGangVehicle( gangid, slotid );
|
||||||
|
|
||||||
|
// create vehicle
|
||||||
|
if ( IsValidVehicle( ( vehicleid = CreateVehicle( g_gangVehicleData[ gangid ] [ slotid ] [ E_MODEL ], X, Y, Z, RZ, g_gangVehicleData[ gangid ] [ slotid ] [ E_COLOR ] [ 0 ], g_gangVehicleData[ gangid ] [ slotid ] [ E_COLOR ] [ 1 ], GANG_VEHICLE_SPAWN_COOLDOWN, .addsiren = 1 ) ) ) )
|
||||||
|
{
|
||||||
|
// set vehicle id
|
||||||
|
g_gangVehicleData[ gangid ] [ slotid ] [ E_VEHICLE_ID ] = vehicleid;
|
||||||
|
g_gangVehicleData[ gangid ] [ slotid ] [ E_ACTIVATION_TIME ] = GetServerTime( ) + GANG_VEHICLE_SPAWN_COOLDOWN;
|
||||||
|
g_gangVehicle{ vehicleid } = true;
|
||||||
|
|
||||||
|
// restore data
|
||||||
|
SetVehicleNumberPlate( g_gangVehicleData[ gangid ] [ slotid ] [ E_VEHICLE_ID ], g_gangData[ gangid ] [ E_NAME ] );
|
||||||
|
ChangeVehiclePaintjob( g_gangVehicleData[ gangid ] [ slotid ] [ E_VEHICLE_ID ], g_gangVehicleData[ gangid ] [ slotid ] [ E_PAINTJOB ] );
|
||||||
|
|
||||||
|
// restore car mods
|
||||||
|
for ( new i = 0; i < MAX_CAR_MODS; i ++ ) {
|
||||||
|
if ( g_gangVehicleModifications[ gangid ] [ slotid ] [ i ] >= 1000 && g_gangVehicleModifications[ gangid ] [ slotid ] [ i ] < 1193 ) {
|
||||||
|
if ( CarMod_IsLegalCarMod( GetVehicleModel( g_gangVehicleData[ gangid ] [ slotid ] [ E_VEHICLE_ID ] ), g_gangVehicleModifications[ gangid ] [ slotid ] [ i ] ) ) {
|
||||||
|
AddVehicleComponent( g_gangVehicleData[ gangid ] [ slotid ] [ E_VEHICLE_ID ], g_gangVehicleModifications[ gangid ] [ slotid ] [ i ] );
|
||||||
|
} else {
|
||||||
|
g_gangVehicleModifications[ gangid ] [ slotid ] [ i ] = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return vehicleid;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
stock ResetGangVehicleMods( gangid, slotid, fordestroy=1 )
|
||||||
|
{
|
||||||
|
if ( ! IsValidGangVehicle( gangid, slotid ) )
|
||||||
|
return;
|
||||||
|
|
||||||
|
for ( new i = 0; i < MAX_CAR_MODS; i++ )
|
||||||
|
{
|
||||||
|
if ( ! fordestroy && IsValidVehicle( g_gangVehicleData[ gangid ] [ slotid ] [ E_VEHICLE_ID ] ) ) {
|
||||||
|
if ( CarMod_IsLegalCarMod( GetVehicleModel( g_gangVehicleData[ gangid ] [ slotid ] [ E_VEHICLE_ID ] ), g_gangVehicleModifications[ gangid ] [ slotid ] [ i ] ) ) {
|
||||||
|
RemoveVehicleComponent( g_gangVehicleData[ gangid ] [ slotid ] [ E_VEHICLE_ID ], g_gangVehicleModifications[ gangid ] [ slotid ] [ i ] );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
g_gangVehicleModifications[ gangid ] [ slotid ] [ i ] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
format( szNormalString, sizeof( szNormalString ), "UPDATE `GANG_VEHICLES` SET `MODS`='0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.' WHERE `ID`=%d", g_gangVehicleData[ gangid ] [ slotid ] [ E_SQL_ID ] );
|
||||||
|
mysql_single_query( szNormalString );
|
||||||
|
}
|
||||||
|
|
||||||
|
stock ShowPlayerGangVehicleMenu( playerid, facilityid )
|
||||||
|
{
|
||||||
|
SetPVarInt( playerid, "gang_vehicle_facility", facilityid );
|
||||||
|
SetPVarInt( playerid, "gang_vehicle_gang", GetGangIDFromFacilityID( facilityid ) );
|
||||||
|
ShowPlayerDialog( playerid, DIALOG_GANG_VEHICLE_MENU, DIALOG_STYLE_LIST, ""COL_WHITE"Gang Vehicles", "Spawn Gang Vehicle\nBuy Gang Vehicle\nSell Gang Vehicle", "Select", "Close" );
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static stock GangVehicles_ShowBuyableList( playerid, type_id )
|
||||||
|
{
|
||||||
|
static
|
||||||
|
buyable_vehicles[ 1400 ], i;
|
||||||
|
|
||||||
|
for ( i = 0, buyable_vehicles = ""COL_WHITE"Vehicle\t"COL_WHITE"Price ($)\n"; i < sizeof( g_BuyableVehicleData ); i ++ ) if ( g_BuyableVehicleData[ i ] [ E_TYPE ] == type_id ) {
|
||||||
|
format( buyable_vehicles, sizeof( buyable_vehicles ), "%s%s%s\t"COL_GREEN"%s\n", buyable_vehicles, g_BuyableVehicleData[ i ] [ E_VIP ] ? ( COL_GOLD ) : ( COL_WHITE ), g_BuyableVehicleData[ i ] [ E_NAME ], cash_format( g_BuyableVehicleData[ i ] [ E_PRICE ] * GANG_VEHICLE_PRICE_FACTOR ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
SetPVarInt( playerid, "vehicle_preview", type_id );
|
||||||
|
return ShowPlayerDialog( playerid, DIALOG_GANG_VD_BUY, DIALOG_STYLE_TABLIST_HEADERS, "{FFFFFF}Vehicle Dealership", buyable_vehicles, "Select", "Back" );
|
||||||
|
}
|
||||||
|
|
||||||
|
stock GetGangVehicleData( vehicleid, &gangid, &slotid ) {
|
||||||
|
foreach ( new g : gangs ) {
|
||||||
|
foreach ( new v : gangvehicles< g > ) if ( g_gangVehicleData[ g ] [ v ] [ E_VEHICLE_ID ] == vehicleid ) {
|
||||||
|
gangid = g;
|
||||||
|
slotid = v;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static stock GangVehicles_ShowSpawnList( playerid, gangid ) {
|
||||||
|
new
|
||||||
|
current_time = GetServerTime( );
|
||||||
|
|
||||||
|
szBigString = ""COL_WHITE"Vehicle\t"COL_WHITE"Availablity\n";
|
||||||
|
|
||||||
|
foreach ( new slotid : gangvehicles< gangid > )
|
||||||
|
{
|
||||||
|
format( szBigString, sizeof( szBigString ), "%s%s\t%s\n", szBigString,
|
||||||
|
GetVehicleName( g_gangVehicleData[ gangid ] [ slotid ] [ E_MODEL ] ),
|
||||||
|
g_gangVehicleData[ gangid ] [ slotid ] [ E_ACTIVATION_TIME ] > current_time ? ( secondstotime( g_gangVehicleData[ gangid ] [ slotid ] [ E_ACTIVATION_TIME ] - current_time ) ) : ( COL_GREEN # "Available" )
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return ShowPlayerDialog( playerid, DIALOG_GANG_VEHICLE_SPAWN, DIALOG_STYLE_TABLIST_HEADERS, ""COL_WHITE"Gang Vehicles - Spawn", szBigString, "Select", "Close" );
|
||||||
|
}
|
||||||
|
/* ** Migrations ** */
|
||||||
|
/*
|
||||||
|
CREATE TABLE IF NOT EXISTS `GANG_VEHICLES` (
|
||||||
|
`ID` int(11) auto_increment primary key,
|
||||||
|
`GANG_ID` int(11),
|
||||||
|
`MODEL_ID` int(11),
|
||||||
|
`COLOR1` int(4),
|
||||||
|
`COLOR2` int(4),
|
||||||
|
`PAINTJOB` tinyint(2),
|
||||||
|
`MODS` varchar(90),
|
||||||
|
FOREIGN KEY (GANG_ID) REFERENCES GANGS (ID) ON DELETE CASCADE
|
||||||
|
);
|
||||||
|
*/
|
||||||
|
@ -85,7 +85,7 @@ hook OnScriptInit( )
|
|||||||
// ID NAME SYMBOL MAX SHARES IPO_PRICE MAX_PRICE POOL_FACTOR PRICE_FACTOR DESCRIPTION
|
// ID NAME SYMBOL MAX SHARES IPO_PRICE MAX_PRICE POOL_FACTOR PRICE_FACTOR DESCRIPTION
|
||||||
CreateStockMarket( E_STOCK_MINING_COMPANY, "The Mining Company", "MC", 100000.0, 25.0, 500.0, 100000.0, 10.0, "Exporting mined ores" );
|
CreateStockMarket( E_STOCK_MINING_COMPANY, "The Mining Company", "MC", 100000.0, 25.0, 500.0, 100000.0, 10.0, "Exporting mined ores" );
|
||||||
CreateStockMarket( E_STOCK_AMMUNATION, "Ammu-Nation", "A", 100000.0, 25.0, 250.0, 100000.0, 10.0, "Purchases at Ammu-Nation/Weapon Dealers/Facilities" );
|
CreateStockMarket( E_STOCK_AMMUNATION, "Ammu-Nation", "A", 100000.0, 25.0, 250.0, 100000.0, 10.0, "Purchases at Ammu-Nation/Weapon Dealers/Facilities" );
|
||||||
CreateStockMarket( E_STOCK_VEHICLE_DEALERSHIP, "Vehicle Dealership", "VD", 100000.0, 25.0, 250.0, 100000.0, 20.0, "Car jacker exports, vehicle and component sales" );
|
CreateStockMarket( E_STOCK_VEHICLE_DEALERSHIP, "Vehicle Dealership", "VD", 100000.0, 25.0, 500.0, 100000.0, 20.0, "Car jacker exports, vehicle and component sales" );
|
||||||
CreateStockMarket( E_STOCK_SUPA_SAVE, "Supa-Save", "SS", 100000.0, 25.0, 250.0, 100000.0, 10.0, "Purchases at Supa-Save and 24/7" );
|
CreateStockMarket( E_STOCK_SUPA_SAVE, "Supa-Save", "SS", 100000.0, 25.0, 250.0, 100000.0, 10.0, "Purchases at Supa-Save and 24/7" );
|
||||||
CreateStockMarket( E_STOCK_TRUCKING_COMPANY, "The Trucking Company", "TC", 100000.0, 50.0, 250.0, 100000.0, 20.0, "Completed trucking missions" );
|
CreateStockMarket( E_STOCK_TRUCKING_COMPANY, "The Trucking Company", "TC", 100000.0, 50.0, 250.0, 100000.0, 20.0, "Completed trucking missions" );
|
||||||
CreateStockMarket( E_STOCK_CLUCKIN_BELL, "Cluckin' Bell", "CB", 100000.0, 50.0, 250.0, 100000.0, 20.0, "Exporting meth bags" );
|
CreateStockMarket( E_STOCK_CLUCKIN_BELL, "Cluckin' Bell", "CB", 100000.0, 50.0, 250.0, 100000.0, 20.0, "Exporting meth bags" );
|
||||||
|
@ -397,7 +397,7 @@ hook OnPlayerEndModelPreview( playerid, handleid )
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* ** Functions ** */
|
/* ** Functions ** */
|
||||||
stock ShowBuyableVehiclesList( playerid )
|
stock ShowBuyableVehiclesList( playerid, dialogid = DIALOG_VEHDEALER, secondary_button[ ] = "Cancel" )
|
||||||
{
|
{
|
||||||
static
|
static
|
||||||
szCategory[ 16 * sizeof( g_BVCategories ) ];
|
szCategory[ 16 * sizeof( g_BVCategories ) ];
|
||||||
@ -407,23 +407,59 @@ stock ShowBuyableVehiclesList( playerid )
|
|||||||
format( szCategory, sizeof( szCategory ), "%s%s\n", szCategory, g_BVCategories[ i ] );
|
format( szCategory, sizeof( szCategory ), "%s%s\n", szCategory, g_BVCategories[ i ] );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return ShowPlayerDialog( playerid, DIALOG_VEHDEALER, DIALOG_STYLE_LIST, "{FFFFFF}Vehicle Dealership", szCategory, "Select", "Cancel" );
|
return ShowPlayerDialog( playerid, dialogid, DIALOG_STYLE_LIST, "{FFFFFF}Vehicle Dealership", szCategory, "Select", secondary_button );
|
||||||
}
|
}
|
||||||
|
|
||||||
stock ShowBuyableVehiclesTypeDialog( playerid, type_id )
|
stock ShowBuyableVehiclesTypeDialog( playerid, type_id )
|
||||||
{
|
{
|
||||||
static
|
static
|
||||||
szBuyableVehicles[ 1400 ];
|
buyable_vehicles[ 1400 ], i;
|
||||||
|
|
||||||
erase( szBuyableVehicles );
|
for ( i = 0, buyable_vehicles = ""COL_WHITE"Vehicle\t"COL_WHITE"Price ($)\n"; i < sizeof( g_BuyableVehicleData ); i ++ ) if ( g_BuyableVehicleData[ i ] [ E_TYPE ] == type_id ) {
|
||||||
|
format( buyable_vehicles, sizeof( buyable_vehicles ), "%s%s%s\t"COL_GREEN"%s\n", buyable_vehicles, g_BuyableVehicleData[ i ] [ E_VIP ] ? ( COL_GOLD ) : ( COL_WHITE ), g_BuyableVehicleData[ i ] [ E_NAME ], cash_format( g_BuyableVehicleData[ i ] [ E_PRICE ] ) );
|
||||||
for( new i; i < sizeof( g_BuyableVehicleData ); i++ )
|
|
||||||
{
|
|
||||||
if ( g_BuyableVehicleData[ i ] [ E_TYPE ] == type_id )
|
|
||||||
format( szBuyableVehicles, sizeof( szBuyableVehicles ), "%s"COL_GOLD"%s%s%s\t%s\n", szBuyableVehicles, cash_format( g_BuyableVehicleData[ i ] [ E_PRICE ] ), g_BuyableVehicleData[ i ] [ E_VIP ] ? ( "" ) : ( #COL_WHITE ), g_BuyableVehicleData[ i ] [ E_PRICE ] < 100000 ? ( "\t" ) : ( "" ), g_BuyableVehicleData[ i ] [ E_NAME ] );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ShowPlayerDialog( playerid, DIALOG_VEHDEALER_BUY, DIALOG_STYLE_LIST, "{FFFFFF}Vehicle Dealership", szBuyableVehicles, "Options", "Cancel" );
|
ShowPlayerDialog( playerid, DIALOG_VEHDEALER_BUY, DIALOG_STYLE_TABLIST_HEADERS, "{FFFFFF}Vehicle Dealership", buyable_vehicles, "Options", "Cancel" );
|
||||||
SetPVarInt( playerid, "vehicle_preview", type_id );
|
SetPVarInt( playerid, "vehicle_preview", type_id );
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
stock GetBuyableVehiclePrice( modelid ) {
|
||||||
|
for ( new i = 0; i < sizeof ( g_BuyableVehicleData ); i ++ ) if ( g_BuyableVehicleData[ i ] [ E_MODEL ] == modelid ) {
|
||||||
|
return g_BuyableVehicleData[ i ] [ E_PRICE ];
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
stock GetClosestBoatPort( Float: current_x, Float: current_y, Float: current_z, &Float: dest_x, &Float: dest_y, &Float: dest_z, &Float: distance = FLOAT_INFINITY )
|
||||||
|
{
|
||||||
|
static const
|
||||||
|
Float: g_boatSpawnLocations[ ] [ 3 ] =
|
||||||
|
{
|
||||||
|
{ 2950.59080, -2000.382, -0.4033 }, { 1986.55710, -75.03830, -0.1938 },
|
||||||
|
{ 2238.51780, 498.92970, 0.02490 }, { -626.54060, 832.18100, -0.1432 },
|
||||||
|
{ -1448.5302, 679.33510, -0.2547 }, { -1710.0466, 241.71960, -0.3029 },
|
||||||
|
{ -2181.0417, 2488.8093, -0.3036 }, { -2940.6545, 1238.2001, 0.11180 },
|
||||||
|
{ -2974.5994, 543.54410, 0.44440 }, { -1341.1674, -2989.101, -0.1943 }
|
||||||
|
}
|
||||||
|
;
|
||||||
|
|
||||||
|
new
|
||||||
|
final_port = 0;
|
||||||
|
|
||||||
|
// get the closest port based off coordinates
|
||||||
|
for ( new i = 0, Float: fTmp = 0.0; i < sizeof ( g_boatSpawnLocations ); i ++ )
|
||||||
|
{
|
||||||
|
if ( 0.0 < ( fTmp = GetDistanceBetweenPoints( current_x, current_y, current_z, g_boatSpawnLocations[ i ] [ 0 ], g_boatSpawnLocations[ i ] [ 1 ], g_boatSpawnLocations[ i ] [ 2 ] ) ) < distance )
|
||||||
|
{
|
||||||
|
distance = fTmp;
|
||||||
|
final_port = i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// store the destination coordinates
|
||||||
|
dest_x = g_boatSpawnLocations[ final_port ] [ 0 ];
|
||||||
|
dest_y = g_boatSpawnLocations[ final_port ] [ 1 ];
|
||||||
|
dest_z = g_boatSpawnLocations[ final_port ] [ 2 ];
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
@ -801,7 +801,6 @@ stock RespawnBuyableVehicle( samp_veh_id, occupantid = INVALID_PLAYER_ID )
|
|||||||
GetVehicleParamsEx( g_vehicleData[ playerid ] [ id ] [ E_VEHICLE_ID ], engine, lights, alarm, doors, bonnet, boot, objective );
|
GetVehicleParamsEx( g_vehicleData[ playerid ] [ id ] [ E_VEHICLE_ID ], engine, lights, alarm, doors, bonnet, boot, objective );
|
||||||
SetVehicleParamsEx( g_vehicleData[ playerid ] [ id ] [ E_VEHICLE_ID ], VEHICLE_PARAMS_OFF, lights, alarm, doors, bonnet, boot, objective );
|
SetVehicleParamsEx( g_vehicleData[ playerid ] [ id ] [ E_VEHICLE_ID ], VEHICLE_PARAMS_OFF, lights, alarm, doors, bonnet, boot, objective );
|
||||||
}
|
}
|
||||||
|
|
||||||
return g_vehicleData[ playerid ] [ id ] [ E_VEHICLE_ID ];
|
return g_vehicleData[ playerid ] [ id ] [ E_VEHICLE_ID ];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user