From 76d4b4e8fe3c3919b903730d8b9e66383010b9fd Mon Sep 17 00:00:00 2001 From: Lorenc Pekaj Date: Thu, 11 Oct 2018 11:09:37 +1100 Subject: [PATCH 1/9] updates.txt update --- scriptfiles/updates.txt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/scriptfiles/updates.txt b/scriptfiles/updates.txt index 8e9442d..f6596fa 100644 --- a/scriptfiles/updates.txt +++ b/scriptfiles/updates.txt @@ -2,5 +2,11 @@ (+) Pilot and train minijobs are now saved to the database (and in /highscores). (+) Adds some strippers in the LV brothel (for fun). (+) Adds Hide From Minimap perk (costs $25,000) ... hides you for 1 minute. +(/) You can now set spikes in non-air and non-sea vehicles using your AIM key. +(/) Car jackers now need to wait only 1 min before exporting another vehicle (before 2 min). +(/) Players with level 100 in a specific level are able to accrue more XP in the level. (*) Should be faster to place multiple drills using left alt. (*) Fixes death bug with players suiciding in a vehicle. +(*) Fixed Alcatraz map escaping issues. +(*) Addressed issue with being unable to rob ChuffSec. +(-) Removed a counter in cluckin' bell for ease of access to the safe. \ No newline at end of file From 05cd9b17222ce52db3c7b7bbcd27c3ec898f401e Mon Sep 17 00:00:00 2001 From: Lorenc Pekaj Date: Thu, 11 Oct 2018 20:19:30 +1100 Subject: [PATCH 2/9] fire system retouched - use /fires ... based off map icons ... no more textdraws --- gamemodes/irresistible/cnr/features/fires.pwn | 352 ++++++++++++------ .../cnr/features/houses/house.pwn | 3 - gamemodes/irresistible/cnr/textdraws.pwn | 20 +- gamemodes/sf-cnr.pwn | 119 ------ 4 files changed, 243 insertions(+), 251 deletions(-) diff --git a/gamemodes/irresistible/cnr/features/fires.pwn b/gamemodes/irresistible/cnr/features/fires.pwn index dea8bc7..9505756 100644 --- a/gamemodes/irresistible/cnr/features/fires.pwn +++ b/gamemodes/irresistible/cnr/features/fires.pwn @@ -11,17 +11,20 @@ /* ** Definitions ** */ #define MAX_FIRES ( 10 ) +#define FIRE_EXTINGUISH_PAYOUT ( 5000 ) + /* ** Variables ** */ enum E_FIRE_DATA { - bool: E_CREATED, E_OBJECT, Float: E_HEALTH, - E_HOUSE, Text3D: E_LABEL + E_OBJECT, Float: E_HEALTH, E_HOUSE, + Text3D: E_LABEL, E_MAP_ICON }; static stock g_fireData [ MAX_FIRES ] [ E_FIRE_DATA ], - p_FireDistanceTimer [ MAX_PLAYERS ] = { -1, ... }, - bool: fire_toggled = false + Iterator: fires < MAX_FIRES >, + + p_FireTracker [ MAX_PLAYERS char ] ; /* ** Forwards ** */ @@ -55,48 +58,45 @@ hook OnPlayerUpdateEx( playerid ) if ( p_Class[ playerid ] == CLASS_FIREMAN && ( iKeys & KEY_FIRE ) || ( iKeys & KEY_WALK ) ) { new - iVehicle = GetPlayerVehicleID( playerid ); + using_firetruck = GetVehicleModel( GetPlayerVehicleID( playerid ) ) == 407; - if ( GetPlayerWeapon( playerid ) == 42 || GetVehicleModel( iVehicle ) == 407 ) + if ( GetPlayerWeapon( playerid ) == 42 || using_firetruck ) { - for( new i = 0; i < sizeof( g_fireData ); i ++ ) if ( g_fireData[ i ] [ E_CREATED ] ) + foreach ( new i : fires ) { static Float: fX, Float: fY, Float: fZ; if ( GetDynamicObjectPos( g_fireData[ i ] [ E_OBJECT ], fX, fY, fZ ) ) { + // add a bit of height cause of the fire fZ += 2.3; - if ( IsPlayerInRangeOfPoint( playerid, ( GetVehicleModel( iVehicle ) == 407 ? 25.0 : 10.0 ), fX, fY, fZ ) ) + // check if range of point + if ( IsPlayerInRangeOfPoint( playerid, ( using_firetruck ? 30.0 : 10.0 ), fX, fY, fZ ) ) { - if ( IsPlayerAimingAt( playerid, fX, fY, fZ, ( GetVehicleModel( iVehicle ) == 407 ? 3.0 : 1.0 ) ) ) + if ( IsPlayerAimingAt( playerid, fX, fY, fZ, ( using_firetruck ? 3.5 : 1.0 ) ) ) { - if ( g_fireData[ i ] [ E_HEALTH ] > 0.0 ) - { - if ( ( g_fireData[ i ] [ E_HEALTH ] -= GetVehicleModel( iVehicle ) == 407 ? ( 2.85 + fRandomEx( 1.0, 5.0 ) ) : ( 1.25 + fRandomEx( 1.0, 5.0 ) ) ) < 0.0 ) - g_fireData[ i ] [ E_HEALTH ] = 0.0; - UpdateDynamic3DTextLabelText( g_fireData[ i ] [ E_LABEL ], COLOR_YELLOW, sprintf( "%0.1f", g_fireData[ i ] [ E_HEALTH ] ) ); + new + Float: removed_health = ( 2.5 + fRandomEx( 1.0, 5.0 ) ) * ( using_firetruck ? 2.5 : 1.0 ); + + if ( ( g_fireData[ i ] [ E_HEALTH ] -= removed_health ) < 0.0 ) { + g_fireData[ i ] [ E_HEALTH ] = 0.0; } - else + + UpdateDynamic3DTextLabelText( g_fireData[ i ] [ E_LABEL ], 0xA83434FF, sprintf( "House Fire %0.1f%", g_fireData[ i ] [ E_HEALTH ] ) ); + + if ( g_fireData[ i ] [ E_HEALTH ] <= 0.0 ) { ach_HandleExtinguishedFires( playerid ); - SendClientMessageToFireman( -1, "{A83434}[FIREMAN]{FFFFFF} %s(%d) has extinguished house fire %d.", ReturnPlayerName( playerid ), playerid, i ); + SendClientMessageToFireman( -1, "{A83434}[FIREMAN]"COL_WHITE" %s(%d) has earned "COL_GOLD"%s"COL_WHITE" for extinguishing a house fire.", ReturnPlayerName( playerid ), playerid, cash_format( FIRE_EXTINGUISH_PAYOUT ) ); GivePlayerScore( playerid, 2 ); //GivePlayerExperience( playerid, E_FIREMAN ); - GivePlayerCash( playerid, 5000 ); - - g_fireData[ i ] [ E_CREATED ] = false; - g_fireData[ i ] [ E_HOUSE ] = -1; - DestroyDynamicObject( g_fireData[ i ] [ E_OBJECT ] ); - g_fireData[ i ] [ E_OBJECT ] = INVALID_OBJECT_ID; - DestroyDynamic3DTextLabel( g_fireData[ i ] [ E_LABEL ] ); - g_fireData[ i ] [ E_LABEL ] = Text3D: INVALID_3DTEXT_ID; - g_fireData[ i ] [ E_HEALTH ] = 0.0; - UpdateDynamic3DTextLabelText( g_fireData[ i ] [ E_LABEL ], COLOR_YELLOW, sprintf( "%0.1f", g_fireData[ i ] [ E_HEALTH ] ) ); + GivePlayerCash( playerid, FIRE_EXTINGUISH_PAYOUT ); + HouseFire_Remove( i ); } - break; + return 1; } } } @@ -106,74 +106,140 @@ hook OnPlayerUpdateEx( playerid ) return 1; } +hook OnServerUpdate( ) +{ + // create fires if there are no fires existing and houses available + if ( ! Iter_Count( fires ) && Iter_Count( houses ) ) { + HouseFire_Create( ); + } + return 1; +} + +hook OnServerGameDayEnd( ) +{ + HouseFire_Create( ); + return 1; +} + +hook OnPlayerDriveVehicle( playerid, vehicleid ) +{ + new + modelid = GetVehicleModel( vehicleid ); + + if ( modelid == 407 ) { + ShowPlayerHelpDialog( playerid, 2500, "You can see where fires are using ~g~/fires" ); + } + return 1; +} + /* ** Commands ** */ -CMD:firetracker( playerid, params[ ] ) +CMD:firetracker( playerid, params[ ] ) cmd_fires( playerid, params ); +CMD:fires( playerid, params[ ] ) { if ( p_Class[ playerid ] != CLASS_FIREMAN ) return SendError( playerid, "You are not a fireman." ); - if ( p_FireDistanceTimer[ playerid ] != -1 ) - return StopPlayerFireTracker( playerid ), SendServerMessage( playerid, "You have turned off your fire tracker." ); + p_FireTracker{ playerid } = ! p_FireTracker{ playerid }; - KillTimer( p_FireDistanceTimer[ playerid ] ); - p_FireDistanceTimer[ playerid ] = SetTimerEx( "OnPlayerFireDistanceUpdate", 1000, true, "d", playerid ); - SendServerMessage( playerid, "Find the fires and extinguish them." ); - return 1; -} - -stock StopPlayerFireTracker( playerid ) -{ - KillTimer( p_FireDistanceTimer[ playerid ] ); - p_FireDistanceTimer[ playerid ] = -1; - - PlayerTextDrawHide( playerid, p_FireDistance1[ playerid ] ); - PlayerTextDrawHide( playerid, p_FireDistance2[ playerid ] ); - return 1; -} - -/* ** Functions ** */ -stock CreateFire( ) -{ - if ( fire_toggled ) + if ( p_FireTracker{ playerid } ) { - for ( new i = 0; i < sizeof( g_fireData ); i ++ ) if ( g_fireData[ i ] [ E_CREATED ] == true ) - { - g_fireData[ i ] [ E_CREATED ] = false; - g_fireData[ i ] [ E_HOUSE ] = -1; - DestroyDynamicObject( g_fireData[ i ] [ E_OBJECT ] ); - g_fireData[ i ] [ E_OBJECT ] = INVALID_OBJECT_ID; - DestroyDynamic3DTextLabel( g_fireData[ i ] [ E_LABEL ] ); - g_fireData[ i ] [ E_LABEL ] = Text3D: INVALID_3DTEXT_ID; - } - - fire_toggled = false; - CreateFire( ); + UpdatePlayerFireTracker( playerid ); + return SendServerMessage( playerid, "All house fires are now in your minimap as red markers." ); } else { - static - Float: X, Float: Y, Float: Z; + StopPlayerFireTracker( playerid ); + return SendServerMessage( playerid, "You have hidden all the fires from your radar." ); + } +} - for ( new i = 0; i < sizeof( g_fireData ); i ++ ) - { - new - house = GetRandomCreatedHouse( ); +/* ** Functions ** */ +stock HouseFire_Create( ) +{ + // create house house fires for random homes + for ( new fireid = 0; fireid < MAX_FIRES; fireid ++ ) if ( ! Iter_Contains( fires, fireid ) ) + { + new + houseid = HouseFire_GetRandomHome( ); - if ( Iter_Contains( houses, house ) ) - { - GetHousePos( house, X, Y, Z ); - g_fireData[ i ] [ E_HEALTH ] = 100.0 + fRandomEx( 1, 25 ); - g_fireData[ i ] [ E_HOUSE ] = house; - g_fireData[ i ] [ E_CREATED ] = true; - g_fireData[ i ] [ E_LABEL ] = CreateDynamic3DTextLabel( sprintf( "%0.1f", g_fireData[ i ] [ E_HEALTH ] ), COLOR_YELLOW, X, Y, Z + 0.5, 20.0, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 0, -1 ); - g_fireData[ i ] [ E_OBJECT ] = CreateDynamicObject( 18691, X, Y, Z - 2.3, 0.0, 0.0, 0.0 ); - } + if ( Iter_Contains( houses, houseid ) ) + { + static + Float: X, Float: Y, Float: Z; + + GetHousePos( houseid, X, Y, Z ); + + g_fireData[ fireid ] [ E_HEALTH ] = 100.0 + fRandomEx( 1, 25 ); + g_fireData[ fireid ] [ E_HOUSE ] = houseid; + g_fireData[ fireid ] [ E_LABEL ] = CreateDynamic3DTextLabel( sprintf( "House Fire %0.1f%", g_fireData[ fireid ] [ E_HEALTH ] ), 0xA83434FF, X, Y, Z + 0.5, 20.0, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 0, -1 ); + g_fireData[ fireid ] [ E_OBJECT ] = CreateDynamicObject( 18691, X, Y, Z - 2.3, 0.0, 0.0, 0.0 ); + + // fire map icons + g_fireData[ fireid ] [ E_MAP_ICON ] = CreateDynamicMapIcon( X, Y, Z, 0, 0xA83434FF, -1, -1, 0, 6000.0, MAPICON_GLOBAL ); + Streamer_RemoveArrayData( STREAMER_TYPE_MAP_ICON, g_fireData[ fireid ] [ E_MAP_ICON ], E_STREAMER_PLAYER_ID, 0 ); + + Iter_Add( fires, fireid ); } - fire_toggled = true; + } + + // show on radar when it is created + foreach ( new playerid : Player ) if ( GetPlayerClass( playerid ) == CLASS_FIREMAN && p_FireTracker{ playerid } ) { + UpdatePlayerFireTracker( playerid ); } return 1; } +stock HouseFire_Remove( fireid ) +{ + DestroyDynamicObject( g_fireData[ fireid ] [ E_OBJECT ] ); + g_fireData[ fireid ] [ E_OBJECT ] = INVALID_OBJECT_ID; + DestroyDynamic3DTextLabel( g_fireData[ fireid ] [ E_LABEL ] ); + g_fireData[ fireid ] [ E_LABEL ] = Text3D: INVALID_3DTEXT_ID; + DestroyDynamicMapIcon( g_fireData[ fireid ] [ E_MAP_ICON ] ); + g_fireData[ fireid ] [ E_MAP_ICON ] = -1; + Iter_Remove( fires, fireid ); + return 1; +} + +stock HouseFire_GetRandomHome( ) +{ + if ( ! Iter_Count( houses ) ) { + return -1; + } + + static szCity[ MAX_ZONE_NAME ]; + new ignoredHomes[ MAX_HOUSES ] = { -1, ... }; + + // first find homes to ignore + for ( new i = 0; i < MAX_HOUSES; i ++ ) + { + // Avoid Hills / Avoid V.I.P or Clan Homes + if ( ! Iter_Contains( houses, i ) || g_houseData[ i ] [ E_EZ ] > 300.0 || g_houseData[ i ] [ E_COST ] < 500000 ) { + ignoredHomes[ i ] = i; + continue; + } + + // check for house fire + if ( IsHouseOnFire( i ) ) { + ignoredHomes[ i ] = i; + continue; + } + + // San Fierro only + Get2DCity( szCity, g_houseData[ i ] [ E_EX ], g_houseData[ i ] [ E_EY ], g_houseData[ i ] [ E_EZ ] ); + if ( ! strmatch( szCity, "San Fierro" ) ) { + ignoredHomes[ i ] = i; + continue; + } + } + + new + random_home = randomExcept( ignoredHomes, sizeof( ignoredHomes ) ); + + // apparently 'safer' to return value from variable + return random_home; +} + stock IsHouseOnFire( houseid ) { if ( houseid < 0 || houseid > MAX_HOUSES ) @@ -182,45 +248,111 @@ stock IsHouseOnFire( houseid ) if ( ! Iter_Contains( houses, houseid ) ) return 0; - for( new i, Float: X, Float: Y, Float: Z; i < sizeof( g_fireData ); i++ ) + static + Float: X, Float: Y, Float: Z, Float: HX, Float: HY; + + foreach ( new fireid : fires ) { - if ( g_fireData[ i ] [ E_CREATED ] ) - { - GetDynamicObjectPos( g_fireData[ i ] [ E_OBJECT ], X, Y, Z ); // Z is unused due to the object. - if ( g_houseData[ houseid ] [ E_EX ] == X && g_houseData[ houseid ] [ E_EY ] == Y ) - { - return 1; - } + GetDynamicObjectPos( g_fireData[ fireid ] [ E_OBJECT ], X, Y, Z ); // Z is unused due to the object. + GetHousePos( houseid, HX, HY, Z ); + + if ( HX == X && HY == Y ) + { + return 1; } } return 0; } -function OnPlayerFireDistanceUpdate( playerid ) +stock UpdatePlayerFireTracker( playerid ) { - new - Float: X, Float: Y, Float: Z, Float: dis, - szFire1[ 128 ], szFire2[ 128 ] - ; - - for( new i; i < sizeof( g_fireData ); i++ ) - { - GetDynamicObjectPos( g_fireData[ i ] [ E_OBJECT ], X, Y, Z ); - dis = GetPlayerDistanceFromPoint( playerid, X, Y, Z ); - if ( i < floatround( sizeof( g_fireData ) / 2 ) ) - { - if ( g_fireData[ i ] [ E_CREATED ] == false ) format( szFire1, sizeof( szFire1 ), "%s~r~FIRE %d:%s ~g~Stopped~n~", szFire1, i,i==1?(" "):("") ); - else format( szFire1, sizeof( szFire1 ), "%s~r~FIRE %d:%s~w~ %0.0f m~n~", szFire1, i,i==1?("_"):(""), dis ); - } - else - { - if ( g_fireData[ i ] [ E_CREATED ] == false ) format( szFire2, sizeof( szFire2 ), "%s~r~FIRE %d:%s ~g~Stopped~n~", szFire2, i,i==1?(" "):("") ); - else format( szFire2, sizeof( szFire2 ), "%s~r~FIRE %d:%s~w~ %0.0f m~n~", szFire2, i,i==1?("_"):(""), dis ); - } + // add player to map icon list + foreach ( new fireid : fires ) { + Streamer_AppendArrayData( STREAMER_TYPE_MAP_ICON, g_fireData[ fireid ] [ E_MAP_ICON ], E_STREAMER_PLAYER_ID, playerid ); } - PlayerTextDrawSetString( playerid, p_FireDistance1[ playerid ], szFire1 ); - PlayerTextDrawSetString( playerid, p_FireDistance2[ playerid ], szFire2 ); - PlayerTextDrawShow( playerid, p_FireDistance1[ playerid ] ); - PlayerTextDrawShow( playerid, p_FireDistance2[ playerid ] ); return 1; } + +stock StopPlayerFireTracker( playerid ) +{ + // remove player from map icon list + foreach ( new fireid : fires ) if ( Streamer_IsInArrayData( STREAMER_TYPE_MAP_ICON, g_fireData[ fireid ] [ E_MAP_ICON ], E_STREAMER_PLAYER_ID, playerid ) ) { + Streamer_RemoveArrayData( STREAMER_TYPE_MAP_ICON, g_fireData[ fireid ] [ E_MAP_ICON ], E_STREAMER_PLAYER_ID, playerid ); + } + + // reset firetracker + p_FireTracker{ playerid } = false; + return 1; +} + +stock Float: GetPointAngleToPoint( Float: x2, Float: y2, Float: X, Float: Y ) +{ + new Float: DX, Float: DY; + new Float: angle; + + DX = floatabs( floatsub( x2, X ) ); + DY = floatabs( floatsub( y2, Y ) ); + + if ( DY == 0.0 || DX == 0.0 ) + { + if ( DY == 0 && DX > 0 ) angle = 0.0; + else if ( DY == 0 && DX < 0 ) angle = 180.0; + else if ( DY > 0 && DX == 0 ) angle = 90.0; + else if ( DY < 0 && DX == 0 ) angle = 270.0; + else if ( DY == 0 && DX == 0 ) angle = 0.0; + } + else + { + angle = atan( DX / DY ); + if ( X > x2 && Y <= y2 ) angle += 90.0; + else if ( X <= x2 && Y < y2 ) angle = floatsub( 90.0, angle ); + else if ( X < x2 && Y >= y2 ) angle -= 90.0; + else if ( X >= x2 && Y > y2 ) angle = floatsub( 270.0, angle ); + } + return floatadd( angle, 90.0 ); +} + +stock Float: DistanceCameraTargetToLocation(Float:CamX, Float:CamY, Float:CamZ, Float:ObjX, Float:ObjY, Float:ObjZ, Float:FrX, Float:FrY, Float:FrZ) { + + new Float: TGTDistance; + + TGTDistance = floatsqroot( ( CamX - ObjX) * ( CamX - ObjX ) + ( CamY - ObjY ) * ( CamY - ObjY ) + ( CamZ - ObjZ ) * ( CamZ - ObjZ ) ); + + new Float: tmpX, Float: tmpY, Float: tmpZ; + + tmpX = FrX * TGTDistance + CamX; + tmpY = FrY * TGTDistance + CamY; + tmpZ = FrZ * TGTDistance + CamZ; + + return floatsqroot( ( tmpX - ObjX ) * ( tmpX - ObjX ) + ( tmpY - ObjY ) * ( tmpY - ObjY ) + ( tmpZ - ObjZ ) * ( tmpZ - ObjZ ) ); +} + +stock IsPlayerAimingAt( playerid, Float: x, Float: y, Float: z, Float: radius ) // forgot who made this +{ + new Float: camera_x, Float: camera_y, Float: camera_z; + new Float: vector_x, Float: vector_y, Float: vector_z; + + GetPlayerCameraPos( playerid, camera_x, camera_y, camera_z ); + GetPlayerCameraFrontVector( playerid, vector_x, vector_y, vector_z ); + + new Float: vertical, Float: horizontal; + + switch ( GetPlayerWeapon( playerid ) ) + { + case 34, 35, 36: return DistanceCameraTargetToLocation( camera_x, camera_y, camera_z, x, y, z, vector_x, vector_y, vector_z ) < radius; + case 30, 31: vertical = 4.0, horizontal = -1.6; + case 33: vertical = 2.7, horizontal = -1.0; + default: vertical = 6.0, horizontal = -2.2; + } + + new Float: angle = GetPointAngleToPoint( 0, 0, floatsqroot( vector_x * vector_x + vector_y * vector_y ), vector_z ) - 270.0; + new Float: resize_x, Float: resize_y, Float: resize_z = floatsin( angle + vertical, degrees ); + + GetXYInFrontOfPoint( resize_x, resize_y, GetPointAngleToPoint( 0, 0, vector_x, vector_y ) + horizontal, floatcos( angle + vertical, degrees ) ); + return DistanceCameraTargetToLocation(camera_x, camera_y, camera_z, x, y, z, resize_x, resize_y, resize_z) < radius; +} + +stock GetXYInFrontOfPoint( &Float: x, &Float: y, Float: angle, Float: distance ) { + x += ( distance * floatsin( -angle, degrees ) ); + y += ( distance * floatcos( -angle, degrees ) ); +} diff --git a/gamemodes/irresistible/cnr/features/houses/house.pwn b/gamemodes/irresistible/cnr/features/houses/house.pwn index 2298c01..5b859bb 100644 --- a/gamemodes/irresistible/cnr/features/houses/house.pwn +++ b/gamemodes/irresistible/cnr/features/houses/house.pwn @@ -620,9 +620,6 @@ thread OnHouseLoad( ) SetHouseOwner( houseid, 1, "Lorenc" ); } } - - // The server crashes when the fires aren't correctly loaded. - CreateFire( ); return 1; } diff --git a/gamemodes/irresistible/cnr/textdraws.pwn b/gamemodes/irresistible/cnr/textdraws.pwn index 8f855e0..f8d9261 100644 --- a/gamemodes/irresistible/cnr/textdraws.pwn +++ b/gamemodes/irresistible/cnr/textdraws.pwn @@ -47,9 +47,7 @@ new PlayerText: p_TruckingTD [ MAX_PLAYERS ] = { PlayerText: INVALID_TEXT_DRAW, ... }, PlayerText: p_TrackPlayerTD [ MAX_PLAYERS ] = { PlayerText: INVALID_TEXT_DRAW, ... }, PlayerText: p_GPSInformation [ MAX_PLAYERS ] = { PlayerText: INVALID_TEXT_DRAW, ... }, - PlayerText: p_AchievementTD [ MAX_PLAYERS ] = { PlayerText: INVALID_TEXT_DRAW, ... }, - PlayerText: p_FireDistance1 [ MAX_PLAYERS ] = { PlayerText: INVALID_TEXT_DRAW, ... }, - PlayerText: p_FireDistance2 [ MAX_PLAYERS ] = { PlayerText: INVALID_TEXT_DRAW, ... } + PlayerText: p_AchievementTD [ MAX_PLAYERS ] = { PlayerText: INVALID_TEXT_DRAW, ... } ; /* ** Hooks ** */ @@ -525,22 +523,6 @@ hook OnPlayerConnect( playerid ) PlayerTextDrawSetOutline(playerid, p_RobberyAmountTD[ playerid ], 1); PlayerTextDrawSetProportional(playerid, p_RobberyAmountTD[ playerid ], 1); PlayerTextDrawSetSelectable(playerid, p_RobberyAmountTD[ playerid ], 0); - - p_FireDistance1[ playerid ] = CreatePlayerTextDraw(playerid, 26.000000, 182.000000, "_"); - PlayerTextDrawBackgroundColor(playerid, p_FireDistance1[ playerid ], 255); - PlayerTextDrawFont(playerid, p_FireDistance1[ playerid ], 2); - PlayerTextDrawLetterSize(playerid, p_FireDistance1[ playerid ], 0.210000, 1.200000); - PlayerTextDrawColor(playerid, p_FireDistance1[ playerid ], -1); - PlayerTextDrawSetOutline(playerid, p_FireDistance1[ playerid ], 1); - PlayerTextDrawSetProportional(playerid, p_FireDistance1[ playerid ], 1); - - p_FireDistance2[ playerid ] = CreatePlayerTextDraw(playerid, 26.000000, 236.000000, "_"); - PlayerTextDrawBackgroundColor(playerid, p_FireDistance2[ playerid ], 255); - PlayerTextDrawFont(playerid, p_FireDistance2[ playerid ], 2); - PlayerTextDrawLetterSize(playerid, p_FireDistance2[ playerid ], 0.209999, 1.200000); - PlayerTextDrawColor(playerid, p_FireDistance2[ playerid ], -1); - PlayerTextDrawSetOutline(playerid, p_FireDistance2[ playerid ], 1); - PlayerTextDrawSetProportional(playerid, p_FireDistance2[ playerid ], 1); return Y_HOOKS_CONTINUE_RETURN_1; } diff --git a/gamemodes/sf-cnr.pwn b/gamemodes/sf-cnr.pwn index 629f876..265eced 100644 --- a/gamemodes/sf-cnr.pwn +++ b/gamemodes/sf-cnr.pwn @@ -1450,7 +1450,6 @@ public ZoneTimer( ) g_WorldDayCount = ( g_WorldDayCount == 6 ? 0 : g_WorldDayCount + 1 ); TextDrawSetString( g_WorldDayTD, GetDayToString( g_WorldDayCount ) ); - CreateFire( ); RenewWeed( ); PlayerPlaceRandomHits( ); @@ -1740,8 +1739,6 @@ public OnPlayerRequestClass( playerid, classid ) TextDrawHideForPlayer( playerid, g_CurrentRankTD ); TextDrawHideForPlayer( playerid, g_currentXPTD ); TextDrawHideForPlayer( playerid, g_DoubleXPTD ); - PlayerTextDrawHide( playerid, p_FireDistance1[ playerid ] ); - PlayerTextDrawHide( playerid, p_FireDistance2[ playerid ] ); p_MoneyBag{ playerid } = false; RemovePlayerAttachedObject( playerid, 1 ); @@ -14191,44 +14188,6 @@ stock TimeConvert( seconds ) return szTime; } -stock GetRandomCreatedHouse( ) -{ - if ( ! Iter_Count( houses ) ) { - return -1; - } - - static szCity[ MAX_ZONE_NAME ]; - new ignoredHomes[ MAX_HOUSES ] = { -1, ... }; - - // first find homes to ignore - for ( new i = 0; i < MAX_HOUSES; i ++ ) - { - // Avoid Hills / Avoid V.I.P or Clan Homes - if ( ! Iter_Contains( houses, i ) || g_houseData[ i ] [ E_EZ ] > 300.0 || g_houseData[ i ] [ E_COST ] < 500000 ) { - ignoredHomes[ i ] = i; - continue; - } - - // check for house fire - if ( IsHouseOnFire( i ) ) { - ignoredHomes[ i ] = i; - continue; - } - - // San Fierro only - Get2DCity( szCity, g_houseData[ i ] [ E_EX ], g_houseData[ i ] [ E_EY ], g_houseData[ i ] [ E_EZ ] ); - if ( ! strmatch( szCity, "San Fierro" ) ) { - ignoredHomes[ i ] = i; - continue; - } - } - - new - random_home = randomExcept( ignoredHomes, sizeof( ignoredHomes ) ); - - return random_home; -} - stock SetPlayerFacePoint(playerid, Float: fX, Float: fY, Float: offset = 0.0) { static @@ -15004,84 +14963,6 @@ stock GetDayToString( day ) return string; } -Float:DistanceCameraTargetToLocation(Float:CamX, Float:CamY, Float:CamZ, Float:ObjX, Float:ObjY, Float:ObjZ, Float:FrX, Float:FrY, Float:FrZ) { - - new Float:TGTDistance; - - TGTDistance = floatsqroot((CamX - ObjX) * (CamX - ObjX) + (CamY - ObjY) * (CamY - ObjY) + (CamZ - ObjZ) * (CamZ - ObjZ)); - - new Float:tmpX, Float:tmpY, Float:tmpZ; - - tmpX = FrX * TGTDistance + CamX; - tmpY = FrY * TGTDistance + CamY; - tmpZ = FrZ * TGTDistance + CamZ; - - return floatsqroot((tmpX - ObjX) * (tmpX - ObjX) + (tmpY - ObjY) * (tmpY - ObjY) + (tmpZ - ObjZ) * (tmpZ - ObjZ)); -} - -stock Float:GetPointAngleToPoint(Float:x2, Float:y2, Float:X, Float:Y) { - - new Float:DX, Float:DY; - new Float:angle; - - DX = floatabs(floatsub(x2,X)); - DY = floatabs(floatsub(y2,Y)); - - if (DY == 0.0 || DX == 0.0) { - if (DY == 0 && DX > 0) angle = 0.0; - else if (DY == 0 && DX < 0) angle = 180.0; - else if (DY > 0 && DX == 0) angle = 90.0; - else if (DY < 0 && DX == 0) angle = 270.0; - else if (DY == 0 && DX == 0) angle = 0.0; - } - else { - angle = atan(DX/DY); - - if (X > x2 && Y <= y2) angle += 90.0; - else if (X <= x2 && Y < y2) angle = floatsub(90.0, angle); - else if (X < x2 && Y >= y2) angle -= 90.0; - else if (X >= x2 && Y > y2) angle = floatsub(270.0, angle); - } - - return floatadd(angle, 90.0); -} - -stock GetXYInFrontOfPoint(&Float:x, &Float:y, Float:angle, Float:distance) { - x += (distance * floatsin(-angle, degrees)); - y += (distance * floatcos(-angle, degrees)); -} - -stock IsPlayerAimingAt(playerid, Float:x, Float:y, Float:z, Float:radius) -{ - new Float:camera_x; - new Float:camera_y; - new Float:camera_z; - new Float:vector_x; - new Float:vector_y; - new Float:vector_z; - - GetPlayerCameraPos(playerid, camera_x, camera_y, camera_z); - GetPlayerCameraFrontVector(playerid, vector_x, vector_y, vector_z); - - new Float:vertical, Float:horizontal; - - switch (GetPlayerWeapon( playerid )) { - case 34,35,36: - { - if (DistanceCameraTargetToLocation(camera_x, camera_y, camera_z, x, y, z, vector_x, vector_y, vector_z) < radius) return true; - return false; - } - case 30,31: {vertical = 4.0; horizontal = -1.6;} - case 33: {vertical = 2.7; horizontal = -1.0;} - default: {vertical = 6.0; horizontal = -2.2;} - } - new Float:angle = GetPointAngleToPoint(0, 0, floatsqroot(vector_x*vector_x+vector_y*vector_y), vector_z) - 270.0; - new Float:resize_x, Float:resize_y, Float:resize_z = floatsin(angle+vertical, degrees); - GetXYInFrontOfPoint(resize_x, resize_y, GetPointAngleToPoint(0, 0, vector_x, vector_y)+horizontal, floatcos(angle+vertical, degrees)); - - if (DistanceCameraTargetToLocation(camera_x, camera_y, camera_z, x, y, z, resize_x, resize_y, resize_z) < radius) return true; - return false; -} stock ShowAchievement( playerid, achievement[ ], score = -1 ) { From 3ad50aec5e17bd3a2eb6c5a69dce83411cb4194a Mon Sep 17 00:00:00 2001 From: Lorenc Pekaj Date: Thu, 11 Oct 2018 20:24:21 +1100 Subject: [PATCH 3/9] move spike strip in car key to H/CAPSLOCK --- gamemodes/irresistible/cnr/features/spikestrips.pwn | 5 ++++- gamemodes/sf-cnr.pwn | 3 --- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/gamemodes/irresistible/cnr/features/spikestrips.pwn b/gamemodes/irresistible/cnr/features/spikestrips.pwn index 209ce44..ae17889 100644 --- a/gamemodes/irresistible/cnr/features/spikestrips.pwn +++ b/gamemodes/irresistible/cnr/features/spikestrips.pwn @@ -30,7 +30,7 @@ hook OnPlayerKeyStateChange( playerid, newkeys, oldkeys ) { new player_vehicle = GetPlayerVehicleID( playerid ); - if ( PRESSED( KEY_AIM ) && player_vehicle && GetPlayerClass( playerid ) == CLASS_POLICE && p_inFBI{ playerid } ) + if ( PRESSED( KEY_CROUCH ) && player_vehicle && GetPlayerClass( playerid ) == CLASS_POLICE && p_inFBI{ playerid } ) { new vehicle_model = GetVehicleModel( player_vehicle ); @@ -224,3 +224,6 @@ stock ClearPlayerSpikeStrips( playerid, bool: distance_check = true ) } return 1; } + +stock encode_tires( tires1, tires2, tires3, tires4 ) + return tires1 | (tires2 << 1) | (tires3 << 2) | (tires4 << 3); diff --git a/gamemodes/sf-cnr.pwn b/gamemodes/sf-cnr.pwn index 265eced..09722b5 100644 --- a/gamemodes/sf-cnr.pwn +++ b/gamemodes/sf-cnr.pwn @@ -14176,9 +14176,6 @@ stock SetObjectFacePoint(iObjectID, Float: fX, Float: fY, Float: fOffset, bool: } } -stock encode_tires( tires1, tires2, tires3, tires4 ) - return tires1 | (tires2 << 1) | (tires3 << 2) | (tires4 << 3); - stock TimeConvert( seconds ) { static From 97429cf955172701f16d8f04d16d64e3ac85c334 Mon Sep 17 00:00:00 2001 From: Lorenc Pekaj Date: Thu, 11 Oct 2018 23:22:55 +1100 Subject: [PATCH 4/9] explosive rounds n to activate --- gamemodes/sf-cnr.pwn | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gamemodes/sf-cnr.pwn b/gamemodes/sf-cnr.pwn index 09722b5..bae87c6 100644 --- a/gamemodes/sf-cnr.pwn +++ b/gamemodes/sf-cnr.pwn @@ -9799,7 +9799,7 @@ public OnPlayerKeyStateChange( playerid, newkeys, oldkeys ) } // Explosive Bullets - if ( p_ExplosiveBullets[ playerid ] > 0 && PRESSED( KEY_YES ) ) { + if ( p_ExplosiveBullets[ playerid ] > 0 && PRESSED( KEY_NO ) ) { if ( GetPVarInt( playerid, "explosive_rounds" ) == 1 ) { DeletePVar( playerid, "explosive_rounds" ); ShowPlayerHelpDialog( playerid, 2000, "Explosive rounds ~r~disabled." ); From f4a6e08428eead8e29e2111397eb211bfdf84da0 Mon Sep 17 00:00:00 2001 From: Lorenc Pekaj Date: Fri, 12 Oct 2018 00:03:57 +1100 Subject: [PATCH 5/9] fix issue with players losing their biz checkpoints when someone quits --- gamemodes/irresistible/cnr/features/business/business.pwn | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gamemodes/irresistible/cnr/features/business/business.pwn b/gamemodes/irresistible/cnr/features/business/business.pwn index 694452b..c426c5b 100644 --- a/gamemodes/irresistible/cnr/features/business/business.pwn +++ b/gamemodes/irresistible/cnr/features/business/business.pwn @@ -1159,7 +1159,7 @@ hook OnPlayerDisconnect( playerid, reason ) new members = 0; - GetOnlineBusinessAssociates( playerid, members, playerid ); + GetOnlineBusinessAssociates( businessid, members, playerid ); // printf ("%d online players for business %d, stopping mission?", members, businessid ); if ( members <= 0 ) { From fa0e42c0187e22524f34e1d62a174a4c2f2cb22d Mon Sep 17 00:00:00 2001 From: Lorenc Pekaj Date: Fri, 12 Oct 2018 16:43:16 +1100 Subject: [PATCH 6/9] explode at vehicle centre --- gamemodes/sf-cnr.pwn | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/gamemodes/sf-cnr.pwn b/gamemodes/sf-cnr.pwn index bae87c6..0a8f2b1 100644 --- a/gamemodes/sf-cnr.pwn +++ b/gamemodes/sf-cnr.pwn @@ -2704,12 +2704,12 @@ public OnPlayerWeaponShot( playerid, weaponid, hittype, hitid, Float: fX, Float: // Explosive Bullets if ( hittype != BULLET_HIT_TYPE_OBJECT ) { - CreateExplosiveBullet( playerid ); + CreateExplosiveBullet( playerid, hittype, hitid ); } return 1; } -stock CreateExplosiveBullet( playerid ) { +stock CreateExplosiveBullet( playerid, hittype = BULLET_HIT_TYPE_OBJECT, hitid = INVALID_OBJECT_ID ) { if ( IsPlayerInCasino( playerid ) || IsPlayerInPaintBall( playerid ) || IsPlayerInEvent( playerid ) || IsPlayerInMinigame( playerid ) ) return; @@ -2719,8 +2719,14 @@ stock CreateExplosiveBullet( playerid ) { static Float: fromX, Float: fromY, Float: fromZ; static Float: toX, Float: toY, Float: toZ; - // Cool effect - if ( GetPlayerLastShotVectors( playerid, fromX, fromY, fromZ, toX, toY, toZ ) ) { + if ( GetPlayerLastShotVectors( playerid, fromX, fromY, fromZ, toX, toY, toZ ) ) + { + // create explosion at the core of the vehicle + if ( hittype == BULLET_HIT_TYPE_VEHICLE ) { + GetVehiclePos( hitid, toX, toY, toZ ); + } + + // Cool effect new objectid = CreateDynamicObject( 19296, fromX, fromY, fromZ, 0.0, 0.0, 0.0 ); new milliseconds = MoveDynamicObject( objectid, toX, toY, toZ, 500.0 ); SetTimerEx( "Timer_DestroyObject", milliseconds + 200, false, "d", objectid ); From 1838bf5b50736d720bfede66378cea379cbe28f6 Mon Sep 17 00:00:00 2001 From: Lorenc Pekaj Date: Fri, 12 Oct 2018 19:34:02 +1100 Subject: [PATCH 7/9] move rank to experience.pwn --- gamemodes/irresistible/cnr/experience.pwn | 175 ++++++++++++++++++++-- gamemodes/irresistible/cnr/player.pwn | 1 - gamemodes/sf-cnr.pwn | 158 +------------------ 3 files changed, 172 insertions(+), 162 deletions(-) diff --git a/gamemodes/irresistible/cnr/experience.pwn b/gamemodes/irresistible/cnr/experience.pwn index 34ff582..f9a088f 100644 --- a/gamemodes/irresistible/cnr/experience.pwn +++ b/gamemodes/irresistible/cnr/experience.pwn @@ -37,6 +37,12 @@ enum E_LEVEL_DATA { Float: E_MAX_UNITS, Float: E_XP_DILATION }; +enum E_RANK_DATA +{ + Float: E_POINTS, E_NAME[ 32 ], E_MODEL, + E_COLOR, +}; + static const Float: EXP_MAX_PLAYER_LEVEL = 100.0; @@ -56,9 +62,28 @@ static const { "Drug Production", 10000.0, 6.0 }, // 10k exports drug related { "Mining", 1500.0, 3.0 } // 1,500 mining ores */ + }, + + g_aPlayerRanks[ ] [ E_RANK_DATA ] = + { + { 11871.5, "Elite V", 19780, COLOR_GOLD }, + { 6627.13, "Elite IV", 19782, COLOR_GOLD }, + { 3699.51, "Elite III", 19781, COLOR_GOLD }, + { 2065.21, "Elite II", 19784, COLOR_GOLD }, + { 1152.88, "Elite I", 19783, COLOR_GOLD }, + { 643.581, "Silver V", 19780, COLOR_GREY }, + { 359.271, "Silver IV", 19782, COLOR_GREY }, + { 200.563, "Silver III", 19781, COLOR_GREY }, + { 111.95, "Silver II", 19784, COLOR_GREY }, + { 62.5, "Silver I", 19783, COLOR_GREY }, + { 0.0, "unranked", 19300, COLOR_GREY } } ; +new + Float: p_seasonalXP [ MAX_PLAYERS ] +; + /* ** Variables ** */ static stock Float: g_playerExperience [ MAX_PLAYERS ] [ E_LEVELS ], @@ -134,18 +159,22 @@ hook OnPlayerConnect( playerid ) // general reward p_playerExpAwardTD[ playerid ] = CreatePlayerTextDraw( playerid,319.000000, 167.000000, "+20 XP" ); - PlayerTextDrawAlignment( playerid,p_playerExpAwardTD[ playerid ], 2 ); - PlayerTextDrawBackgroundColor( playerid,p_playerExpAwardTD[ playerid ], 255 ); - PlayerTextDrawFont( playerid,p_playerExpAwardTD[ playerid ], 3 ); - PlayerTextDrawLetterSize( playerid,p_playerExpAwardTD[ playerid ], 0.450000, 1.599999 ); - PlayerTextDrawColor( playerid,p_playerExpAwardTD[ playerid ], COLOR_GOLD ); - PlayerTextDrawSetOutline( playerid,p_playerExpAwardTD[ playerid ], 1 ); - PlayerTextDrawSetProportional( playerid,p_playerExpAwardTD[ playerid ], 1 ); - PlayerTextDrawSetSelectable( playerid,p_playerExpAwardTD[ playerid ], 0 ); + PlayerTextDrawAlignment( playerid, p_playerExpAwardTD[ playerid ], 2 ); + PlayerTextDrawBackgroundColor( playerid, p_playerExpAwardTD[ playerid ], 255 ); + PlayerTextDrawFont( playerid, p_playerExpAwardTD[ playerid ], 3 ); + PlayerTextDrawLetterSize( playerid, p_playerExpAwardTD[ playerid ], 0.450000, 1.599999 ); + PlayerTextDrawColor( playerid, p_playerExpAwardTD[ playerid ], COLOR_GOLD ); + PlayerTextDrawSetOutline( playerid, p_playerExpAwardTD[ playerid ], 1 ); + PlayerTextDrawSetProportional( playerid, p_playerExpAwardTD[ playerid ], 1 ); + PlayerTextDrawSetSelectable( playerid, p_playerExpAwardTD[ playerid ], 0 ); return 1; } -hook OnPlayerDisconnect( playerid, reason ) { +hook OnPlayerDisconnect( playerid, reason ) +{ + p_seasonalXP[ playerid ] = 0.0; + + // reset levels for ( new l = 0; l < sizeof ( g_levelData ); l ++ ) { g_playerExperience[ playerid ] [ E_LEVELS: l ] = 0; } @@ -186,6 +215,22 @@ CMD:level( playerid, params[ ] ) return ShowPlayerDialog( playerid, DIALOG_VIEW_LEVEL, DIALOG_STYLE_TABLIST_HEADERS, sprintf( "{FFFFFF}%s's Level - Total Level %d", ReturnPlayerName( watchingid ), player_total_lvl ), szLargeString, "Refresh", "Close" ); } +CMD:rank( playerid, params[ ] ) +{ + new + watchingid; + + if ( sscanf( params, "u", watchingid ) ) + watchingid = playerid; + + if ( !IsPlayerConnected( watchingid ) ) + watchingid = playerid; + + format( szBigString, 196, "SELECT uo.NAME, (SELECT COUNT(DISTINCT ui.`SCORE`) FROM `USERS` ui WHERE ui.`SCORE` >= uo.`SCORE`) AS `GLOBAL_RANK` FROM `USERS` uo WHERE `ID`=%d", p_AccountID[ watchingid ] ); + mysql_function_query( dbHandle, szBigString, true, "currentUserRank", "ii", playerid, watchingid ); + return 1; +} + /* ** SQL Threads ** */ thread Experience_OnLoad( playerid ) { @@ -208,6 +253,25 @@ thread Experience_OnLoad( playerid ) return 1; } +thread currentUserRank( playerid, watchingid ) +{ + new + rows; + + cache_get_data( rows, tmpVariable ); + + if ( rows ) + { + new + iGroupedRank = GetPlayerRank( watchingid ), + iGlobalRank = cache_get_field_content_int( 0, "GLOBAL_RANK", dbHandle ) + ; + SendServerMessage( playerid, "%s(%d) is grouped in {%06x}%s"COL_WHITE" and is globally "COL_GREY"#%d"COL_WHITE".", ReturnPlayerName( watchingid ), watchingid, g_aPlayerRanks[ iGroupedRank ] [ E_COLOR ] >>> 8, g_aPlayerRanks[ iGroupedRank ] [ E_NAME ], iGlobalRank ); + } + else SendError( playerid, "Couldn't find a rank for this user, try again later." ); + return 1; +} + /* ** Functions ** */ stock GivePlayerExperience( playerid, E_LEVELS: level, Float: default_xp = 1.0, bool: with_dilation = true ) { @@ -274,6 +338,99 @@ stock GetPlayerTotalLevel( playerid, &level = 0 ) { return level; } +stock GetRankFromXP( Float: xp ) { + new + iRank; + + for( iRank = 0; iRank < sizeof( g_aPlayerRanks ); iRank++ ) + if ( xp >= g_aPlayerRanks[ iRank ] [ E_POINTS ] ) + break; + + return iRank; +} + +stock GetPlayerRank( playerid ) { + return GetRankFromXP( p_seasonalXP[ playerid ] ); +} + +stock ShowPlayerIrresistibleRank( playerid ) +{ + new + iRank = GetPlayerRank( playerid ); + + PlayerTextDrawColor( playerid, p_PlayerRankTextTD[ playerid ], g_aPlayerRanks[ iRank ] [ E_COLOR ] ); + PlayerTextDrawSetString( playerid, p_PlayerRankTextTD[ playerid ], g_aPlayerRanks[ iRank ] [ E_NAME ] ); + + PlayerTextDrawColor( playerid, p_PlayerRankTD[ playerid ], g_aPlayerRanks[ iRank ] [ E_COLOR ] ); + PlayerTextDrawSetPreviewModel( playerid, p_PlayerRankTD[ playerid ], g_aPlayerRanks[ iRank ] [ E_MODEL ] ); + + PlayerTextDrawShow( playerid, p_PlayerRankTD[ playerid ] ); + PlayerTextDrawShow( playerid, p_PlayerRankTextTD[ playerid ] ); +} + +stock GivePlayerIrresistiblePoints( playerid, Float: points ) +{ + new + Float: fPreviousPoints = p_seasonalXP[ playerid ], + Float: fCurrentPoints = fPreviousPoints + points + ; + + if ( fCurrentPoints < 0.0 ) + fCurrentPoints = 0.0; + + new Float: upper_limit = g_aPlayerRanks[ 0 ] [ E_POINTS ] + 500.0; + + if ( fCurrentPoints > upper_limit ) + fCurrentPoints = upper_limit; + + for( new iRank = 0; iRank < sizeof( g_aPlayerRanks ); iRank++ ) + { + new + bGained = ( fPreviousPoints < g_aPlayerRanks[ iRank ] [ E_POINTS ] <= fCurrentPoints ), + bLost = ( fCurrentPoints < g_aPlayerRanks[ iRank ] [ E_POINTS ] <= fPreviousPoints ) + ; + + if ( bGained || bLost ) + { + if ( bGained ) + { + SendServerMessage( playerid, "Congratulations, your grouped ranking has been increased to {%06x}%s"COL_WHITE"!", g_aPlayerRanks[ iRank ] [ E_COLOR ] >>> 8, g_aPlayerRanks[ iRank ] [ E_NAME ] ); + + PlayerTextDrawColor( playerid, p_PlayerRankTextTD[ playerid ], g_aPlayerRanks[ iRank ] [ E_COLOR ] ); + PlayerTextDrawSetString( playerid, p_PlayerRankTextTD[ playerid ], g_aPlayerRanks[ iRank ] [ E_NAME ] ); + + PlayerTextDrawColor( playerid, p_PlayerRankTD[ playerid ], g_aPlayerRanks[ iRank ] [ E_COLOR ] ); + PlayerTextDrawSetPreviewModel( playerid, p_PlayerRankTD[ playerid ], g_aPlayerRanks[ iRank ] [ E_MODEL ] ); + } + + if ( bLost ) + { + SendServerMessage( playerid, "Sorry, your grouped ranking has decreased to {%06x}%s"COL_WHITE"!", g_aPlayerRanks[ iRank + 1 ] [ E_COLOR ] >>> 8, g_aPlayerRanks[ iRank + 1 ] [ E_NAME ] ); + + PlayerTextDrawColor( playerid, p_PlayerRankTextTD[ playerid ], g_aPlayerRanks[ iRank + 1 ] [ E_COLOR ] ); + PlayerTextDrawSetString( playerid, p_PlayerRankTextTD[ playerid ], g_aPlayerRanks[ iRank + 1 ] [ E_NAME ] ); + + PlayerTextDrawColor( playerid, p_PlayerRankTD[ playerid ], g_aPlayerRanks[ iRank + 1 ] [ E_COLOR ] ); + PlayerTextDrawSetPreviewModel( playerid, p_PlayerRankTD[ playerid ], g_aPlayerRanks[ iRank + 1 ] [ E_MODEL ] ); + } + + PlayerTextDrawShow( playerid, p_PlayerRankTD[ playerid ] ); + PlayerTextDrawShow( playerid, p_PlayerRankTextTD[ playerid ] ); + break; + } + } + //printf( "%s: %f points", ReturnPlayerName( playerid ), fCurrentPoints ); + p_seasonalXP[ playerid ] = fCurrentPoints; +} + +stock GetRankName( rankid ) { + return g_aPlayerRanks[ rankid ] [ E_NAME ]; +} + +stock GetRankColour( rankid ) { + return g_aPlayerRanks[ rankid ] [ E_COLOR ]; +} + /* ** Migrations ** */ /* CREATE TABLE IF NOT EXISTS USER_LEVELS ( diff --git a/gamemodes/irresistible/cnr/player.pwn b/gamemodes/irresistible/cnr/player.pwn index eb7ecaf..bc53500 100644 --- a/gamemodes/irresistible/cnr/player.pwn +++ b/gamemodes/irresistible/cnr/player.pwn @@ -210,7 +210,6 @@ new p_TrainMissions [ MAX_PLAYERS ], p_KidnapImmunity [ MAX_PLAYERS ], p_GangSplitProfits [ MAX_PLAYERS ], - Float: p_IrresistiblePoints [ MAX_PLAYERS ], p_SafeHelperTimer [ MAX_PLAYERS ] = { -1, ... }, p_HouseOfferer [ MAX_PLAYERS ], p_HouseOfferTicks [ MAX_PLAYERS ], diff --git a/gamemodes/sf-cnr.pwn b/gamemodes/sf-cnr.pwn index 0a8f2b1..fc8a746 100644 --- a/gamemodes/sf-cnr.pwn +++ b/gamemodes/sf-cnr.pwn @@ -342,28 +342,6 @@ new ; /* ** Rank System ** */ -enum E_RANK_DATA -{ - Float: E_POINTS, E_NAME[ 32 ], E_MODEL, - E_COLOR, -}; - -stock const - g_aPlayerRanks[ ] [ E_RANK_DATA ] = - { - { 11871.5, "Elite V", 19780, COLOR_GOLD }, - { 6627.13, "Elite IV", 19782, COLOR_GOLD }, - { 3699.51, "Elite III", 19781, COLOR_GOLD }, - { 2065.21, "Elite II", 19784, COLOR_GOLD }, - { 1152.88, "Elite I", 19783, COLOR_GOLD }, - { 643.581, "Silver V", 19780, COLOR_GREY }, - { 359.271, "Silver IV", 19782, COLOR_GREY }, - { 200.563, "Silver III", 19781, COLOR_GREY }, - { 111.95, "Silver II", 19784, COLOR_GREY }, - { 62.5, "Silver I", 19783, COLOR_GREY }, - { 0.0, "unranked", 19300, COLOR_GREY } - } -; /* ** Hitmarker ** */ enum E_HITMARKER_SOUND @@ -2263,7 +2241,6 @@ public OnPlayerDisconnect( playerid, reason ) p_GangSplitProfits[ playerid ] = 0; p_IrresistibleCoins[ playerid ] = 0.0; p_QuitToAvoidTimestamp[ playerid ] = 0; - p_IrresistiblePoints[ playerid ] = 0.0; p_AntiExportCarSpam[ playerid ] = 0; p_TruckedCargo[ playerid ] = 0; p_PilotMissions[ playerid ] = 0; @@ -4552,41 +4529,6 @@ CMD:highscores( playerid, params[ ] ) return 1; } -CMD:rank( playerid, params[ ] ) -{ - new - watchingid; - - if ( sscanf( params, "u", watchingid ) ) - watchingid = playerid; - - if ( !IsPlayerConnected( watchingid ) ) - watchingid = playerid; - - format( szBigString, 196, "SELECT uo.NAME, (SELECT COUNT(DISTINCT ui.`SCORE`) FROM `USERS` ui WHERE ui.`SCORE` >= uo.`SCORE`) AS `GLOBAL_RANK` FROM `USERS` uo WHERE `ID`=%d", p_AccountID[ watchingid ] ); - mysql_function_query( dbHandle, szBigString, true, "currentUserRank", "ii", playerid, watchingid ); - return 1; -} - -thread currentUserRank( playerid, watchingid ) -{ - new - rows; - - cache_get_data( rows, tmpVariable ); - - if ( rows ) - { - new - iGroupedRank = GetPlayerRank( watchingid ), - iGlobalRank = cache_get_field_content_int( 0, "GLOBAL_RANK", dbHandle ) - ; - SendServerMessage( playerid, "%s(%d) is grouped in {%06x}%s"COL_WHITE" and is globally "COL_GREY"#%d"COL_WHITE".", ReturnPlayerName( watchingid ), watchingid, g_aPlayerRanks[ iGroupedRank ] [ E_COLOR ] >>> 8, g_aPlayerRanks[ iGroupedRank ] [ E_NAME ], iGlobalRank ); - } - else SendError( playerid, "Couldn't find a rank for this user, try again later." ); - return 1; -} - CMD:request( playerid, params[ ] ) { /* ** Anti Spammy Commands ** */ @@ -10334,7 +10276,7 @@ thread OnAttemptPlayerLogin( playerid, password[ ] ) p_MethYielded[ playerid ] = cache_get_field_content_int( 0, "METH_YIELDED", dbHandle ); p_drillStrength[ playerid ] = cache_get_field_content_int( 0, "DRILL", dbHandle ); p_IrresistibleCoins[ playerid ] = cache_get_field_content_float( 0, "COINS", dbHandle ); - p_IrresistiblePoints[ playerid ]= cache_get_field_content_float( 0, "RANK", dbHandle ); + p_seasonalXP[ playerid ] = cache_get_field_content_float( 0, "RANK", dbHandle ); p_ExtraAssetSlots{ playerid } = cache_get_field_content_int( 0, "EXTRA_SLOTS", dbHandle ); p_forcedAnticheat[ playerid ] = cache_get_field_content_int( 0, "FORCE_AC", dbHandle ); @@ -11656,7 +11598,7 @@ public OnDialogResponse( playerid, dialogid, response, listitem, inputtext[ ] ) ""COL_GREY"Admin Level:{FFFFFF} %d\n"\ ""COL_GREY"Time Online:{FFFFFF} %s\n"\ ""COL_GREY"Irresistible Rank:{FFFFFF} %s\n"\ - ""COL_GREY"Irresistible Coins:{FFFFFF} %f\n", ReturnPlayerName( pID ), pID, p_AccountID[ pID ], p_AdminLevel[ pID ], secondstotime( p_Uptime[ pID ] ), g_aPlayerRanks[ GetPlayerRank( pID ) ] [ E_NAME ], p_IrresistibleCoins[ pID ] ); + ""COL_GREY"Irresistible Coins:{FFFFFF} %f\n", ReturnPlayerName( pID ), pID, p_AccountID[ pID ], p_AdminLevel[ pID ], secondstotime( p_Uptime[ pID ] ), GetRankName( GetPlayerRank( pID ) ), p_IrresistibleCoins[ pID ] ); format( szLargeString, 750, "%s"COL_GREY"V.I.P Level:{FFFFFF} %s\n"\ ""COL_GREY"V.I.P Expiry:{FFFFFF} %s\n"\ @@ -12985,16 +12927,10 @@ thread OnHighScoreCheck( playerid, highscore_item ) { case 0: { - new - Float: score_value = cache_get_field_content_float( row, "SCORE_VAL", dbHandle ), rank; + new Float: score_value = cache_get_field_content_float( row, "SCORE_VAL", dbHandle ); + new rank = GetRankFromXP( score_value ); - for( rank = 0; rank < sizeof( g_aPlayerRanks ); rank++ ) { - if ( score_value >= g_aPlayerRanks[ rank ] [ E_POINTS ] ) { - break; - } - } - - format( szLargeString, sizeof( szLargeString ), "%s%s%s\t{%06x}%s\n", szLargeString, strmatch( name, ReturnPlayerName( playerid ) ) ? COL_GREEN : COL_WHITE, name, g_aPlayerRanks[ rank ] [ E_COLOR ] >>> 8, g_aPlayerRanks[ rank ] [ E_NAME ] ); + format( szLargeString, sizeof( szLargeString ), "%s%s%s\t{%06x}%s\n", szLargeString, strmatch( name, ReturnPlayerName( playerid ) ) ? COL_GREEN : COL_WHITE, name, GetRankColour( rank ) >>> 8, GetRankName( rank ) ); } default: { @@ -13357,7 +13293,7 @@ stock SavePlayerData( playerid, bool: logout = false ) p_JailsBlown[ playerid ], p_BankBlown[ playerid ], p_CarsJacked[ playerid ], p_MethYielded[ playerid ], mysql_escape( ReturnPlayerIP( playerid ) ), p_VIPJob{ playerid }, p_TruckedCargo[ playerid ], p_IrresistibleCoins[ playerid ], - p_ExplosiveBullets[ playerid ], p_IrresistiblePoints[ playerid ], + p_ExplosiveBullets[ playerid ], p_seasonalXP[ playerid ], !logout, p_HitmarkerSound{ playerid }, p_ExtraAssetSlots{ playerid }, p_PilotMissions[ playerid ], p_TrainMissions[ playerid ], p_AccountID[ playerid ] ); @@ -16581,88 +16517,6 @@ stock SplitPlayerCashForGang( playerid, Float: cashRobbed ) return 1; } -stock GetPlayerRank( playerid ) -{ - new - iRank; - - for( iRank = 0; iRank < sizeof( g_aPlayerRanks ); iRank++ ) - if ( p_IrresistiblePoints[ playerid ] >= g_aPlayerRanks[ iRank ] [ E_POINTS ] ) - break; - - return iRank; -} - -stock ShowPlayerIrresistibleRank( playerid ) -{ - new - iRank = GetPlayerRank( playerid ); - - PlayerTextDrawColor( playerid, p_PlayerRankTextTD[ playerid ], g_aPlayerRanks[ iRank ] [ E_COLOR ] ); - PlayerTextDrawSetString( playerid, p_PlayerRankTextTD[ playerid ], g_aPlayerRanks[ iRank ] [ E_NAME ] ); - - PlayerTextDrawColor( playerid, p_PlayerRankTD[ playerid ], g_aPlayerRanks[ iRank ] [ E_COLOR ] ); - PlayerTextDrawSetPreviewModel( playerid, p_PlayerRankTD[ playerid ], g_aPlayerRanks[ iRank ] [ E_MODEL ] ); - - PlayerTextDrawShow( playerid, p_PlayerRankTD[ playerid ] ); - PlayerTextDrawShow( playerid, p_PlayerRankTextTD[ playerid ] ); -} - -stock GivePlayerIrresistiblePoints( playerid, Float: points ) -{ - new - Float: fPreviousPoints = p_IrresistiblePoints[ playerid ], - Float: fCurrentPoints = fPreviousPoints + points - ; - - if ( fCurrentPoints < 0.0 ) - fCurrentPoints = 0.0; - - new Float: upper_limit = g_aPlayerRanks[ 0 ] [ E_POINTS ] + 500.0; - - if ( fCurrentPoints > upper_limit ) - fCurrentPoints = upper_limit; - - for( new iRank = 0; iRank < sizeof( g_aPlayerRanks ); iRank++ ) - { - new - bGained = ( fPreviousPoints < g_aPlayerRanks[ iRank ] [ E_POINTS ] <= fCurrentPoints ), - bLost = ( fCurrentPoints < g_aPlayerRanks[ iRank ] [ E_POINTS ] <= fPreviousPoints ) - ; - - if ( bGained || bLost ) - { - if ( bGained ) - { - SendServerMessage( playerid, "Congratulations, your grouped ranking has been increased to {%06x}%s"COL_WHITE"!", g_aPlayerRanks[ iRank ] [ E_COLOR ] >>> 8, g_aPlayerRanks[ iRank ] [ E_NAME ] ); - - PlayerTextDrawColor( playerid, p_PlayerRankTextTD[ playerid ], g_aPlayerRanks[ iRank ] [ E_COLOR ] ); - PlayerTextDrawSetString( playerid, p_PlayerRankTextTD[ playerid ], g_aPlayerRanks[ iRank ] [ E_NAME ] ); - - PlayerTextDrawColor( playerid, p_PlayerRankTD[ playerid ], g_aPlayerRanks[ iRank ] [ E_COLOR ] ); - PlayerTextDrawSetPreviewModel( playerid, p_PlayerRankTD[ playerid ], g_aPlayerRanks[ iRank ] [ E_MODEL ] ); - } - - if ( bLost ) - { - SendServerMessage( playerid, "Sorry, your grouped ranking has decreased to {%06x}%s"COL_WHITE"!", g_aPlayerRanks[ iRank + 1 ] [ E_COLOR ] >>> 8, g_aPlayerRanks[ iRank + 1 ] [ E_NAME ] ); - - PlayerTextDrawColor( playerid, p_PlayerRankTextTD[ playerid ], g_aPlayerRanks[ iRank + 1 ] [ E_COLOR ] ); - PlayerTextDrawSetString( playerid, p_PlayerRankTextTD[ playerid ], g_aPlayerRanks[ iRank + 1 ] [ E_NAME ] ); - - PlayerTextDrawColor( playerid, p_PlayerRankTD[ playerid ], g_aPlayerRanks[ iRank + 1 ] [ E_COLOR ] ); - PlayerTextDrawSetPreviewModel( playerid, p_PlayerRankTD[ playerid ], g_aPlayerRanks[ iRank + 1 ] [ E_MODEL ] ); - } - - PlayerTextDrawShow( playerid, p_PlayerRankTD[ playerid ] ); - PlayerTextDrawShow( playerid, p_PlayerRankTextTD[ playerid ] ); - break; - } - } - //printf( "%s: %f points", ReturnPlayerName( playerid ), fCurrentPoints ); - p_IrresistiblePoints[ playerid ] = fCurrentPoints; -} - stock ShowPlayerTogglableTextdraws( playerid, bool: force = false ) { // Current Coins From ecf10abe5c33c05a1e263d8f483f57f24713b6f3 Mon Sep 17 00:00:00 2001 From: Lorenc Pekaj Date: Fri, 12 Oct 2018 20:01:32 +1100 Subject: [PATCH 8/9] new rank system is largely based off the new xp system --- .../cnr/commands/admin/admin_rcon.pwn | 6 +- gamemodes/irresistible/cnr/experience.pwn | 113 +++++++++--------- .../cnr/features/minijobs/meth.pwn | 2 +- gamemodes/sf-cnr.pwn | 34 +++--- 4 files changed, 80 insertions(+), 75 deletions(-) diff --git a/gamemodes/irresistible/cnr/commands/admin/admin_rcon.pwn b/gamemodes/irresistible/cnr/commands/admin/admin_rcon.pwn index a83c5f5..06eda97 100644 --- a/gamemodes/irresistible/cnr/commands/admin/admin_rcon.pwn +++ b/gamemodes/irresistible/cnr/commands/admin/admin_rcon.pwn @@ -438,18 +438,18 @@ CMD:givexp( playerid, params [ ] ) return 1; } -CMD:giveip( playerid, params [ ] ) +CMD:givesxp( playerid, params [ ] ) { new pID, ip ; if ( !IsPlayerAdmin( playerid ) || ! IsPlayerLeadMaintainer( playerid ) ) return 0; - else if ( sscanf( params, "ud", pID, ip ) ) SendUsage( playerid, "/giveip [PLAYER_ID] [IP_AMOUNT]" ); + else if ( sscanf( params, "ud", pID, ip ) ) SendUsage( playerid, "/givesxp [PLAYER_ID] [IP_AMOUNT]" ); else if ( !IsPlayerConnected( pID ) ) SendError( playerid, "Invalid Player ID." ); else { - GivePlayerIrresistiblePoints( pID, ip ); + GivePlayerSeasonalXP( pID, ip ); //AddAdminLogLineFormatted( "%s(%d) has given %s(%d) %d IP", ReturnPlayerName( playerid ), playerid, ReturnPlayerName( pID ), pID, ip ); //SendClientMessageFormatted( pID, -1, ""COL_PINK"[ADMIN]{FFFFFF} %s(%d) has given you %d IP.", ReturnPlayerName( playerid ), playerid, ip ); //SendClientMessageFormatted( playerid, -1, ""COL_PINK"[ADMIN]{FFFFFF} You've given %s(%d) %d IP.", ReturnPlayerName( pID ), pID, ip ); diff --git a/gamemodes/irresistible/cnr/experience.pwn b/gamemodes/irresistible/cnr/experience.pwn index f9a088f..8ea5c0d 100644 --- a/gamemodes/irresistible/cnr/experience.pwn +++ b/gamemodes/irresistible/cnr/experience.pwn @@ -64,35 +64,31 @@ static const */ }, - g_aPlayerRanks[ ] [ E_RANK_DATA ] = + g_seasonalRanks[ ] [ E_RANK_DATA ] = { - { 11871.5, "Elite V", 19780, COLOR_GOLD }, - { 6627.13, "Elite IV", 19782, COLOR_GOLD }, - { 3699.51, "Elite III", 19781, COLOR_GOLD }, - { 2065.21, "Elite II", 19784, COLOR_GOLD }, - { 1152.88, "Elite I", 19783, COLOR_GOLD }, - { 643.581, "Silver V", 19780, COLOR_GREY }, - { 359.271, "Silver IV", 19782, COLOR_GREY }, - { 200.563, "Silver III", 19781, COLOR_GREY }, - { 111.95, "Silver II", 19784, COLOR_GREY }, - { 62.5, "Silver I", 19783, COLOR_GREY }, + { 49860.3, "Elite V", 19780, COLOR_GOLD }, + { 27833.9, "Elite IV", 19782, COLOR_GOLD }, + { 15537.9, "Elite III", 19781, COLOR_GOLD }, + { 8673.88, "Elite II", 19784, COLOR_GOLD }, + { 4842.10, "Elite I", 19783, COLOR_GOLD }, + { 2703.04, "Silver V", 19780, COLOR_GREY }, + { 1508.94, "Silver IV", 19782, COLOR_GREY }, + { 842.365, "Silver III", 19781, COLOR_GREY }, + { 470.19, "Silver II", 19784, COLOR_GREY }, + { 262.5, "Silver I", 19783, COLOR_GREY }, { 0.0, "unranked", 19300, COLOR_GREY } } ; -new - Float: p_seasonalXP [ MAX_PLAYERS ] -; - /* ** Variables ** */ static stock Float: g_playerExperience [ MAX_PLAYERS ] [ E_LEVELS ], + Float: p_seasonalXP [ MAX_PLAYERS ], PlayerText: p_playerExpTitle [ MAX_PLAYERS ] = { PlayerText: INVALID_TEXT_DRAW, ... }, PlayerText: p_playerExpAwardTD [ MAX_PLAYERS ] = { PlayerText: INVALID_TEXT_DRAW, ... }, PlayerBar: p_playerExpProgress [ MAX_PLAYERS ], p_playerExpHideTimer [ MAX_PLAYERS ] = { -1, ... } - ; /* ** Important ** */ @@ -266,7 +262,7 @@ thread currentUserRank( playerid, watchingid ) iGroupedRank = GetPlayerRank( watchingid ), iGlobalRank = cache_get_field_content_int( 0, "GLOBAL_RANK", dbHandle ) ; - SendServerMessage( playerid, "%s(%d) is grouped in {%06x}%s"COL_WHITE" and is globally "COL_GREY"#%d"COL_WHITE".", ReturnPlayerName( watchingid ), watchingid, g_aPlayerRanks[ iGroupedRank ] [ E_COLOR ] >>> 8, g_aPlayerRanks[ iGroupedRank ] [ E_NAME ], iGlobalRank ); + SendServerMessage( playerid, "%s(%d) is grouped in {%06x}%s"COL_WHITE" and is globally "COL_GREY"#%d"COL_WHITE".", ReturnPlayerName( watchingid ), watchingid, g_seasonalRanks[ iGroupedRank ] [ E_COLOR ] >>> 8, g_seasonalRanks[ iGroupedRank ] [ E_NAME ], iGlobalRank ); } else SendError( playerid, "Couldn't find a rank for this user, try again later." ); return 1; @@ -303,6 +299,9 @@ stock GivePlayerExperience( playerid, E_LEVELS: level, Float: default_xp = 1.0, SetPlayerProgressBarValue( playerid, p_playerExpProgress[ playerid ], progress ); } + // seasonal + GivePlayerSeasonalXP( playerid, xp_earned ); + // alert user KillTimer( p_playerExpHideTimer[ playerid ] ); PlayerTextDrawColor( playerid, p_playerExpTitle[ playerid ], g_levelData[ _: level ] [ E_COLOUR ] ); @@ -342,8 +341,8 @@ stock GetRankFromXP( Float: xp ) { new iRank; - for( iRank = 0; iRank < sizeof( g_aPlayerRanks ); iRank++ ) - if ( xp >= g_aPlayerRanks[ iRank ] [ E_POINTS ] ) + for( iRank = 0; iRank < sizeof( g_seasonalRanks ); iRank++ ) + if ( xp >= g_seasonalRanks[ iRank ] [ E_POINTS ] ) break; return iRank; @@ -358,60 +357,58 @@ stock ShowPlayerIrresistibleRank( playerid ) new iRank = GetPlayerRank( playerid ); - PlayerTextDrawColor( playerid, p_PlayerRankTextTD[ playerid ], g_aPlayerRanks[ iRank ] [ E_COLOR ] ); - PlayerTextDrawSetString( playerid, p_PlayerRankTextTD[ playerid ], g_aPlayerRanks[ iRank ] [ E_NAME ] ); + PlayerTextDrawColor( playerid, p_PlayerRankTextTD[ playerid ], g_seasonalRanks[ iRank ] [ E_COLOR ] ); + PlayerTextDrawSetString( playerid, p_PlayerRankTextTD[ playerid ], g_seasonalRanks[ iRank ] [ E_NAME ] ); - PlayerTextDrawColor( playerid, p_PlayerRankTD[ playerid ], g_aPlayerRanks[ iRank ] [ E_COLOR ] ); - PlayerTextDrawSetPreviewModel( playerid, p_PlayerRankTD[ playerid ], g_aPlayerRanks[ iRank ] [ E_MODEL ] ); + PlayerTextDrawColor( playerid, p_PlayerRankTD[ playerid ], g_seasonalRanks[ iRank ] [ E_COLOR ] ); + PlayerTextDrawSetPreviewModel( playerid, p_PlayerRankTD[ playerid ], g_seasonalRanks[ iRank ] [ E_MODEL ] ); PlayerTextDrawShow( playerid, p_PlayerRankTD[ playerid ] ); PlayerTextDrawShow( playerid, p_PlayerRankTextTD[ playerid ] ); } -stock GivePlayerIrresistiblePoints( playerid, Float: points ) +stock GivePlayerSeasonalXP( playerid, Float: default_xp ) { - new - Float: fPreviousPoints = p_seasonalXP[ playerid ], - Float: fCurrentPoints = fPreviousPoints + points - ; + new Float: previous_season_xp = p_seasonalXP[ playerid ]; + new Float: current_season_xp = previous_season_xp + default_xp; - if ( fCurrentPoints < 0.0 ) - fCurrentPoints = 0.0; + // default 0 + if ( current_season_xp < 0.0 ) + current_season_xp = 0.0; - new Float: upper_limit = g_aPlayerRanks[ 0 ] [ E_POINTS ] + 500.0; + new Float: upper_limit = g_seasonalRanks[ 0 ] [ E_POINTS ] + 500.0; - if ( fCurrentPoints > upper_limit ) - fCurrentPoints = upper_limit; + // so that the player has a chance to be deranked + if ( current_season_xp > upper_limit ) + current_season_xp = upper_limit; - for( new iRank = 0; iRank < sizeof( g_aPlayerRanks ); iRank++ ) + for( new iRank = 0; iRank < sizeof( g_seasonalRanks ); iRank++ ) { - new - bGained = ( fPreviousPoints < g_aPlayerRanks[ iRank ] [ E_POINTS ] <= fCurrentPoints ), - bLost = ( fCurrentPoints < g_aPlayerRanks[ iRank ] [ E_POINTS ] <= fPreviousPoints ) - ; + new bGained = ( previous_season_xp < g_seasonalRanks[ iRank ] [ E_POINTS ] <= current_season_xp ); + new bLost = ( current_season_xp < g_seasonalRanks[ iRank ] [ E_POINTS ] <= previous_season_xp ); if ( bGained || bLost ) { if ( bGained ) { - SendServerMessage( playerid, "Congratulations, your grouped ranking has been increased to {%06x}%s"COL_WHITE"!", g_aPlayerRanks[ iRank ] [ E_COLOR ] >>> 8, g_aPlayerRanks[ iRank ] [ E_NAME ] ); + SendServerMessage( playerid, "Congratulations, your grouped ranking has been increased to {%06x}%s"COL_WHITE"!", g_seasonalRanks[ iRank ] [ E_COLOR ] >>> 8, g_seasonalRanks[ iRank ] [ E_NAME ] ); - PlayerTextDrawColor( playerid, p_PlayerRankTextTD[ playerid ], g_aPlayerRanks[ iRank ] [ E_COLOR ] ); - PlayerTextDrawSetString( playerid, p_PlayerRankTextTD[ playerid ], g_aPlayerRanks[ iRank ] [ E_NAME ] ); + PlayerTextDrawColor( playerid, p_PlayerRankTextTD[ playerid ], g_seasonalRanks[ iRank ] [ E_COLOR ] ); + PlayerTextDrawSetString( playerid, p_PlayerRankTextTD[ playerid ], g_seasonalRanks[ iRank ] [ E_NAME ] ); - PlayerTextDrawColor( playerid, p_PlayerRankTD[ playerid ], g_aPlayerRanks[ iRank ] [ E_COLOR ] ); - PlayerTextDrawSetPreviewModel( playerid, p_PlayerRankTD[ playerid ], g_aPlayerRanks[ iRank ] [ E_MODEL ] ); + PlayerTextDrawColor( playerid, p_PlayerRankTD[ playerid ], g_seasonalRanks[ iRank ] [ E_COLOR ] ); + PlayerTextDrawSetPreviewModel( playerid, p_PlayerRankTD[ playerid ], g_seasonalRanks[ iRank ] [ E_MODEL ] ); } if ( bLost ) { - SendServerMessage( playerid, "Sorry, your grouped ranking has decreased to {%06x}%s"COL_WHITE"!", g_aPlayerRanks[ iRank + 1 ] [ E_COLOR ] >>> 8, g_aPlayerRanks[ iRank + 1 ] [ E_NAME ] ); + SendServerMessage( playerid, "Sorry, your grouped ranking has decreased to {%06x}%s"COL_WHITE"!", g_seasonalRanks[ iRank + 1 ] [ E_COLOR ] >>> 8, g_seasonalRanks[ iRank + 1 ] [ E_NAME ] ); - PlayerTextDrawColor( playerid, p_PlayerRankTextTD[ playerid ], g_aPlayerRanks[ iRank + 1 ] [ E_COLOR ] ); - PlayerTextDrawSetString( playerid, p_PlayerRankTextTD[ playerid ], g_aPlayerRanks[ iRank + 1 ] [ E_NAME ] ); + PlayerTextDrawColor( playerid, p_PlayerRankTextTD[ playerid ], g_seasonalRanks[ iRank + 1 ] [ E_COLOR ] ); + PlayerTextDrawSetString( playerid, p_PlayerRankTextTD[ playerid ], g_seasonalRanks[ iRank + 1 ] [ E_NAME ] ); - PlayerTextDrawColor( playerid, p_PlayerRankTD[ playerid ], g_aPlayerRanks[ iRank + 1 ] [ E_COLOR ] ); - PlayerTextDrawSetPreviewModel( playerid, p_PlayerRankTD[ playerid ], g_aPlayerRanks[ iRank + 1 ] [ E_MODEL ] ); + PlayerTextDrawColor( playerid, p_PlayerRankTD[ playerid ], g_seasonalRanks[ iRank + 1 ] [ E_COLOR ] ); + PlayerTextDrawSetPreviewModel( playerid, p_PlayerRankTD[ playerid ], g_seasonalRanks[ iRank + 1 ] [ E_MODEL ] ); } PlayerTextDrawShow( playerid, p_PlayerRankTD[ playerid ] ); @@ -419,16 +416,24 @@ stock GivePlayerIrresistiblePoints( playerid, Float: points ) break; } } - //printf( "%s: %f points", ReturnPlayerName( playerid ), fCurrentPoints ); - p_seasonalXP[ playerid ] = fCurrentPoints; + + //printf( "%s: %f points", ReturnPlayerName( playerid ), current_season_xp ); + p_seasonalXP[ playerid ] = current_season_xp; + + // save to database + mysql_single_query( sprintf( "UPDATE `USERS` SET `RANK` = %f WHERE `ID` = %d", current_season_xp, GetPlayerAccountID( playerid ) ) ); } -stock GetRankName( rankid ) { - return g_aPlayerRanks[ rankid ] [ E_NAME ]; +stock GetSeasonalRankName( rankid ) { + return g_seasonalRanks[ rankid ] [ E_NAME ]; } -stock GetRankColour( rankid ) { - return g_aPlayerRanks[ rankid ] [ E_COLOR ]; +stock GetSeasonalRankColour( rankid ) { + return g_seasonalRanks[ rankid ] [ E_COLOR ]; +} + +stock SetPlayerSeasonalXP( playerid, Float: seasonal_xp ) { + p_seasonalXP[ playerid ] = seasonal_xp; } /* ** Migrations ** */ diff --git a/gamemodes/irresistible/cnr/features/minijobs/meth.pwn b/gamemodes/irresistible/cnr/features/minijobs/meth.pwn index 85dc360..10bb777 100644 --- a/gamemodes/irresistible/cnr/features/minijobs/meth.pwn +++ b/gamemodes/irresistible/cnr/features/minijobs/meth.pwn @@ -209,7 +209,7 @@ public OnMethamphetamineCooking( playerid, vehicleid, last_chemical ) ShowPlayerHelpDialog( playerid, 5000, "The process is done. Bag it up and do another round if you wish." ); SendServerMessage( playerid, "Process is done. Bag it up, and do another round if you wish. Export it for money." ); GivePlayerWantedLevel( playerid, 12 ); - GivePlayerScore( playerid, 3, .multiplier = 0.30 ); + GivePlayerScore( playerid, 3 ); ach_HandleMethYielded( playerid ); SetGVarInt( "meth_yield", CreateDynamicObject( 1579, 2083.684082, 1233.945922, 414.875244, 0.000000, 0.000000, 90.000000, GetPlayerVirtualWorld( playerid ) ), vehicleid ); PlayerPlaySound( playerid, 1057, 0.0, 0.0, 0.0 ); diff --git a/gamemodes/sf-cnr.pwn b/gamemodes/sf-cnr.pwn index fc8a746..e85618a 100644 --- a/gamemodes/sf-cnr.pwn +++ b/gamemodes/sf-cnr.pwn @@ -1564,7 +1564,7 @@ public ZoneTimer( ) if ( IsPlayerSpawned( d ) && ! IsPlayerAFK( d ) && p_Class[ d ] == CLASS_CIVILIAN && p_GangID[ d ] == attacker_gang && ! IsPlayerInPaintBall( d ) ) { if ( in_area ) { - GivePlayerScore( d, 2, .multiplier = 0.5 ); + GivePlayerScore( d, 2 ); GivePlayerWantedLevel( d, 6 ); } PlayerPlaySound( d, 36205, 0.0, 0.0, 0.0 ); @@ -3273,7 +3273,7 @@ public OnPlayerDeath( playerid, killerid, reason ) if ( p_Class[ killerid ] != CLASS_POLICE ) { GivePlayerWantedLevel( killerid, 12 ); - GivePlayerScore( killerid, 1, .multiplier = 0.2 ); + GivePlayerScore( killerid, 1 ); new Float: default_experience = 1.0; @@ -3301,7 +3301,7 @@ public OnPlayerDeath( playerid, killerid, reason ) SaveGangData( playerGangId ), g_gangData[ playerGangId ] [ E_DEATHS ]++; p_Deaths[ playerid ] ++; // Usually other events do nothing - GivePlayerIrresistiblePoints( playerid, -1 ); // Deduct points, it's meant to be hard!!! + GivePlayerSeasonalXP( playerid, -10.0 ); // Deduct points, it's meant to be hard!!! } ClearPlayerWantedLevel( playerid ); @@ -9154,7 +9154,7 @@ public OnPlayerEnterDynamicCP( playerid, checkpointid ) GameTextForPlayer( victimid, "~r~Busted!", 4000, 0 ); ClearAnimations( victimid ); JailPlayer( victimid, totalSeconds ); - GivePlayerIrresistiblePoints( victimid, -2 ); + GivePlayerSeasonalXP( victimid, -2 ); SendGlobalMessage( -1, ""COL_GOLD"[JAIL]{FFFFFF} %s(%d) has sent %s(%d) to jail for %d seconds!", ReturnPlayerName( playerid ), playerid, ReturnPlayerName( victimid ), victimid, totalSeconds ); } } @@ -9387,7 +9387,7 @@ public OnPlayerEnterDynamicRaceCP( playerid, checkpointid ) } items = GetGVarInt( szItems ); score = floatround( items / 2 ); - GivePlayerScore( playerid, score == 0 ? 1 : score, .multiplier = 0.4 ); + GivePlayerScore( playerid, score == 0 ? 1 : score ); //GivePlayerExperience( playerid, E_BURGLAR, float( items ) * 0.2 ); DestroyDynamicMapIcon( p_PawnStoreMapIcon[ playerid ] ); p_PawnStoreMapIcon[ playerid ] = 0xFFFF; @@ -10276,7 +10276,6 @@ thread OnAttemptPlayerLogin( playerid, password[ ] ) p_MethYielded[ playerid ] = cache_get_field_content_int( 0, "METH_YIELDED", dbHandle ); p_drillStrength[ playerid ] = cache_get_field_content_int( 0, "DRILL", dbHandle ); p_IrresistibleCoins[ playerid ] = cache_get_field_content_float( 0, "COINS", dbHandle ); - p_seasonalXP[ playerid ] = cache_get_field_content_float( 0, "RANK", dbHandle ); p_ExtraAssetSlots{ playerid } = cache_get_field_content_int( 0, "EXTRA_SLOTS", dbHandle ); p_forcedAnticheat[ playerid ] = cache_get_field_content_int( 0, "FORCE_AC", dbHandle ); @@ -10287,6 +10286,9 @@ thread OnAttemptPlayerLogin( playerid, password[ ] ) p_AddedEmail{ playerid } = !!cache_get_field_content_int( 0, "USED_EMAIL", dbHandle ); // p_TaxTime[ playerid ] = cache_get_field_content_int( 0, "TAX_TIME", dbHandle ); + // seasonal xp + SetPlayerSeasonalXP( playerid, cache_get_field_content_float( 0, "RANK", dbHandle ) ); + // spawn location new spawn_location[ 10 ]; @@ -11598,7 +11600,7 @@ public OnDialogResponse( playerid, dialogid, response, listitem, inputtext[ ] ) ""COL_GREY"Admin Level:{FFFFFF} %d\n"\ ""COL_GREY"Time Online:{FFFFFF} %s\n"\ ""COL_GREY"Irresistible Rank:{FFFFFF} %s\n"\ - ""COL_GREY"Irresistible Coins:{FFFFFF} %f\n", ReturnPlayerName( pID ), pID, p_AccountID[ pID ], p_AdminLevel[ pID ], secondstotime( p_Uptime[ pID ] ), GetRankName( GetPlayerRank( pID ) ), p_IrresistibleCoins[ pID ] ); + ""COL_GREY"Irresistible Coins:{FFFFFF} %f\n", ReturnPlayerName( pID ), pID, p_AccountID[ pID ], p_AdminLevel[ pID ], secondstotime( p_Uptime[ pID ] ), GetSeasonalRankName( GetPlayerRank( pID ) ), p_IrresistibleCoins[ pID ] ); format( szLargeString, 750, "%s"COL_GREY"V.I.P Level:{FFFFFF} %s\n"\ ""COL_GREY"V.I.P Expiry:{FFFFFF} %s\n"\ @@ -12930,7 +12932,7 @@ thread OnHighScoreCheck( playerid, highscore_item ) new Float: score_value = cache_get_field_content_float( row, "SCORE_VAL", dbHandle ); new rank = GetRankFromXP( score_value ); - format( szLargeString, sizeof( szLargeString ), "%s%s%s\t{%06x}%s\n", szLargeString, strmatch( name, ReturnPlayerName( playerid ) ) ? COL_GREEN : COL_WHITE, name, GetRankColour( rank ) >>> 8, GetRankName( rank ) ); + format( szLargeString, sizeof( szLargeString ), "%s%s%s\t{%06x}%s\n", szLargeString, strmatch( name, ReturnPlayerName( playerid ) ) ? COL_GREEN : COL_WHITE, name, GetSeasonalRankColour( rank ) >>> 8, GetSeasonalRankName( rank ) ); } default: { @@ -13288,12 +13290,12 @@ stock SavePlayerData( playerid, bool: logout = false ) p_ContractedAmount[ playerid ], p_WeedGrams[ playerid ], logout ? ( bQuitToAvoid ? 1 : 0 ) : 0, p_drillStrength[ playerid ] ); - format( Query, sizeof( Query ), "%s`BLEW_JAILS`=%d,`BLEW_VAULT`=%d,`VEHICLES_JACKED`=%d,`METH_YIELDED`=%d,`LAST_IP`='%s',`VIP_JOB`=%d,`TRUCKED`=%d,`COINS`=%f,`EXPLOSIVE_BULLETS`=%d,`RANK`=%f,`ONLINE`=%d,`HIT_SOUND`=%d,`EXTRA_SLOTS`=%d,`PILOT`=%d,`TRAIN`=%d WHERE `ID`=%d", + format( Query, sizeof( Query ), "%s`BLEW_JAILS`=%d,`BLEW_VAULT`=%d,`VEHICLES_JACKED`=%d,`METH_YIELDED`=%d,`LAST_IP`='%s',`VIP_JOB`=%d,`TRUCKED`=%d,`COINS`=%f,`EXPLOSIVE_BULLETS`=%d,`ONLINE`=%d,`HIT_SOUND`=%d,`EXTRA_SLOTS`=%d,`PILOT`=%d,`TRAIN`=%d WHERE `ID`=%d", Query, p_JailsBlown[ playerid ], p_BankBlown[ playerid ], p_CarsJacked[ playerid ], p_MethYielded[ playerid ], mysql_escape( ReturnPlayerIP( playerid ) ), p_VIPJob{ playerid }, p_TruckedCargo[ playerid ], p_IrresistibleCoins[ playerid ], - p_ExplosiveBullets[ playerid ], p_seasonalXP[ playerid ], + p_ExplosiveBullets[ playerid ], !logout, p_HitmarkerSound{ playerid }, p_ExtraAssetSlots{ playerid }, p_PilotMissions[ playerid ], p_TrainMissions[ playerid ], p_AccountID[ playerid ] ); @@ -13701,7 +13703,7 @@ stock IsWeaponBanned( weaponid ) { return 0 <= weaponid < MAX_WEAPONS && ( weaponid == 36 || weaponid == 37 || weaponid == 38 || weaponid == 39 || weaponid == 44 || weaponid == 45 ); } -stock GivePlayerScore( playerid, score, Float: multiplier = 0.75 ) +stock GivePlayerScore( playerid, score ) { if ( IsPlayerAdminOnDuty( playerid ) ) return 0; @@ -13709,11 +13711,9 @@ stock GivePlayerScore( playerid, score, Float: multiplier = 0.75 ) new gangid = p_GangID[ playerid ]; - if ( gangid != INVALID_GANG_ID ) + if ( gangid != INVALID_GANG_ID ) { SaveGangData( gangid ), g_gangData[ gangid ] [ E_SCORE ] += score; - - //GivePlayerXP_Legacy( playerid, score * 10 ); - GivePlayerIrresistiblePoints( playerid, score < 0 ? ( score * 1.0 ) : ( score * multiplier ) ); + } return SetPlayerScore( playerid, GetPlayerScore( playerid ) + score ); } @@ -17835,7 +17835,7 @@ stock ArrestPlayer( victimid, playerid ) if ( GetPlayerState( playerid ) == PLAYER_STATE_WASTED ) return SendError( playerid, "You cannot use this command since you are dead." ); new totalCash = ( p_WantedLevel[ victimid ] < MAX_WANTED_LVL ? p_WantedLevel[ victimid ] : MAX_WANTED_LVL ) * ( 300 ); new totalSeconds = p_WantedLevel[ victimid ] * ( JAIL_SECONDS_MULTIPLIER ); - GivePlayerScore( playerid, 2, .multiplier = 1.5 ); + GivePlayerScore( playerid, 2 ); GivePlayerExperience( playerid, E_POLICE ); GivePlayerCash( playerid, totalCash ); if ( totalCash > 20000 ) printf("[police arrest] %s -> %s - %s", ReturnPlayerName( playerid ), ReturnPlayerName( victimid ), cash_format( totalCash ) ); // 8hska7082bmahu @@ -17843,7 +17843,7 @@ stock ArrestPlayer( victimid, playerid ) GameTextForPlayer( victimid, "~r~Busted!", 4000, 0 ); CallLocalFunction( "OnPlayerArrested", "dddd", playerid, victimid, p_Arrests[ playerid ], 1 ); Untaze( victimid, 6 ); - GivePlayerIrresistiblePoints( victimid, -2 ); + GivePlayerSeasonalXP( victimid, -20.0 ); SendGlobalMessage( -1, ""COL_GOLD"[JAIL]{FFFFFF} %s(%d) has sent %s(%d) to jail for %d seconds!", ReturnPlayerName( playerid ), playerid, ReturnPlayerName( victimid ), victimid, totalSeconds ); JailPlayer( victimid, totalSeconds ); return 1; From f5e1a4565c46e9b23c78608e3cc93ddc68912b00 Mon Sep 17 00:00:00 2001 From: Lorenc Pekaj Date: Fri, 12 Oct 2018 20:26:35 +1100 Subject: [PATCH 9/9] moviemode xp tds moved to experience.pwn --- gamemodes/irresistible/cnr/experience.pwn | 22 +++++++++++++++++++++- gamemodes/sf-cnr.pwn | 9 --------- 2 files changed, 21 insertions(+), 10 deletions(-) diff --git a/gamemodes/irresistible/cnr/experience.pwn b/gamemodes/irresistible/cnr/experience.pwn index 8ea5c0d..fd3be78 100644 --- a/gamemodes/irresistible/cnr/experience.pwn +++ b/gamemodes/irresistible/cnr/experience.pwn @@ -177,6 +177,26 @@ hook OnPlayerDisconnect( playerid, reason ) return 1; } +hook OnPlayerMovieMode( playerid, bool: toggled ) +{ + if ( toggled ) + { + TextDrawShowForPlayer( playerid, g_CurrentRankTD ); + TextDrawShowForPlayer( playerid, g_currentXPTD ); + PlayerTextDrawShow( playerid, p_ExperienceTD[ playerid ] ); + ShowPlayerIrresistibleRank( playerid ); + } + else + { + TextDrawHideForPlayer( playerid, g_CurrentRankTD ); + TextDrawHideForPlayer( playerid, g_currentXPTD ); + PlayerTextDrawHide( playerid, p_ExperienceTD[ playerid ] ); + PlayerTextDrawHide( playerid, p_PlayerRankTD[ playerid ] ); + PlayerTextDrawHide( playerid, p_PlayerRankTextTD[ playerid ] ); + } + return 1; +} + /* ** Commands ** */ CMD:experience( playerid, params[ ] ) return cmd_level( playerid, params ); CMD:levels( playerid, params[ ] ) return cmd_level( playerid, params ); @@ -458,4 +478,4 @@ stock SetPlayerSeasonalXP( playerid, Float: seasonal_xp ) { INSERT INTO USER_LEVELS (USER_ID, LEVEL_ID, EXPERIENCE) (SELECT ID as USER_ID, 6 as LEVEL_ID, (BLEW_JAILS + BLEW_VAULT) * 6.0 AS EXPERIENCE FROM USERS); INSERT INTO USER_LEVELS (USER_ID, LEVEL_ID, EXPERIENCE) (SELECT ID as USER_ID, 7 as LEVEL_ID, VEHICLES_JACKED * 6.0 AS EXPERIENCE FROM USERS); INSERT INTO USER_LEVELS (USER_ID, LEVEL_ID, EXPERIENCE) (SELECT ID as USER_ID, 8 as LEVEL_ID, (METH_YIELDED + (TRUCKED*0.33)) * 6.0 AS EXPERIENCE FROM USERS); - */ +*/ diff --git a/gamemodes/sf-cnr.pwn b/gamemodes/sf-cnr.pwn index e85618a..242c9e2 100644 --- a/gamemodes/sf-cnr.pwn +++ b/gamemodes/sf-cnr.pwn @@ -6145,10 +6145,7 @@ CMD:moviemode( playerid, params[ ] ) case true: { ShowPlayerTogglableTextdraws( playerid ); - TextDrawShowForPlayer( playerid, g_CurrentRankTD ); - TextDrawShowForPlayer( playerid, g_currentXPTD ); PlayerTextDrawShow( playerid, p_LocationTD[ playerid ] ); - PlayerTextDrawShow( playerid, p_ExperienceTD[ playerid ] ); if ( IsDoubleXP( ) ) TextDrawShowForPlayer( playerid, g_DoubleXPTD ); TextDrawShowForPlayer( playerid, g_WebsiteTD ); if ( p_WantedLevel[ playerid ] ) PlayerTextDrawShow( playerid, p_WantedLevelTD[ playerid ] ); @@ -6157,7 +6154,6 @@ CMD:moviemode( playerid, params[ ] ) if ( p_FPSCounter{ playerid } ) TextDrawShowForPlayer( playerid, p_FPSCounterTD[ playerid ] ); if ( p_AdminOnDuty{ playerid } ) TextDrawShowForPlayer( playerid, g_AdminOnDutyTD ); TextDrawShowForPlayer( playerid, g_WorldDayTD ); - ShowPlayerIrresistibleRank( playerid ); PlayerTextDrawShow( playerid, g_ZoneOwnerTD[ playerid ] ); for( new i; i < sizeof( g_MovieModeTD ); i ++ ) TextDrawHideForPlayer( playerid, g_MovieModeTD[ i ] ); p_inMovieMode{ playerid } = false; @@ -6167,16 +6163,11 @@ CMD:moviemode( playerid, params[ ] ) { PlayerTextDrawHide( playerid, g_ZoneOwnerTD[ playerid ] ); HidePlayerTogglableTextdraws( playerid ); - TextDrawHideForPlayer( playerid, g_CurrentRankTD ); - TextDrawHideForPlayer( playerid, g_currentXPTD ); PlayerTextDrawHide( playerid, p_LocationTD[ playerid ] ); - PlayerTextDrawHide( playerid, p_ExperienceTD[ playerid ] ); PlayerTextDrawHide( playerid, p_WantedLevelTD[ playerid ] ); TextDrawHideForPlayer( playerid, g_WebsiteTD ); TextDrawHideForPlayer( playerid, g_AdminOnDutyTD ); TextDrawHideForPlayer( playerid, g_DoubleXPTD ); - PlayerTextDrawHide( playerid, p_PlayerRankTD[ playerid ] ); - PlayerTextDrawHide( playerid, p_PlayerRankTextTD[ playerid ] ); TextDrawHideForPlayer( playerid, g_MotdTD ); TextDrawHideForPlayer( playerid, g_NotManyPlayersTD ); TextDrawHideForPlayer( playerid, g_WorldDayTD );