modulize streaks and weapon statistics

This commit is contained in:
Lorenc Pekaj 2018-10-10 16:05:23 +11:00
parent c652ac40e2
commit 889f8bf946
6 changed files with 265 additions and 192 deletions

View File

@ -7,7 +7,7 @@
/* ** Includes ** */ /* ** Includes ** */
// houses #include "irresistible\cnr\features\player\_player.pwn"
#include "irresistible\cnr\features\houses\_houses.pwn" #include "irresistible\cnr\features\houses\_houses.pwn"
#include "irresistible\cnr\features\vehicles\_vehicles.pwn" #include "irresistible\cnr\features\vehicles\_vehicles.pwn"
#include "irresistible\cnr\features\business\_business.pwn" #include "irresistible\cnr\features\business\_business.pwn"

View File

@ -0,0 +1,10 @@
/*
* Irresistible Gaming (c) 2018
* Developed by Lorenc Pekaj
* Module: cnr\features\player\_player.pwn
* Purpose: encloses all player modules & components (cnr)
*/
/* ** Includes ** */
#include "irresistible\cnr\features\player\streaks.pwn"
#include "irresistible\cnr\features\player\weapon_stats.pwn"

View File

@ -0,0 +1,142 @@
/*
* Irresistible Gaming (c) 2018
* Developed by Lorenc Pekaj
* Module: cnr\features\player\streaks.pwn
* Purpose: streak counting system for players
*/
/* ** Includes ** */
#include < YSI\y_hooks >
/* ** Definitions ** */
#define MAX_STREAKS ( 3 ) // Changing order will require change in UCP seasonal page.
/* ** Variables ** */
enum
{
STREAK_ROBBERY,
STREAK_ARREST,
STREAK_KILL
};
enum E_STREAK_DATA
{
E_STREAK, E_BEST_STREAK
};
static stock
g_streaksTypes [ MAX_STREAKS ] [ 8 ] = { "robbery", "arrest", "kill" },
p_streakData [ MAX_PLAYERS ] [ MAX_STREAKS ] [ E_STREAK_DATA ]
;
/* ** Hooks ** */
hook OnPlayerDisconnect( playerid, reason )
{
for ( new i = 0; i < MAX_STREAKS; i ++ ) {
p_streakData[ playerid ] [ i ] [ E_BEST_STREAK ] = 0;
p_streakData[ playerid ] [ i ] [ E_STREAK ] = 0;
}
return 1;
}
#if defined AC_INCLUDED
hook OnPlayerDeathEx( playerid, killerid, reason, Float: damage, bodypart )
#else
hook OnPlayerDeath( playerid, killerid, reason )
#endif
{
for ( new i = 0; i < MAX_STREAKS; i ++ ) {
p_streakData[ playerid ] [ i ] [ E_STREAK ] = 0;
}
return 1;
}
hook OnPlayerLogin( playerid )
{
format( szNormalString, sizeof( szNormalString ), "SELECT * FROM `STREAKS` WHERE `USER_ID`=%d", GetPlayerAccountID( playerid ) );
mysql_function_query( dbHandle, szNormalString, true, "OnStreaksLoad", "d", playerid );
return 1;
}
/* ** Commands ** */
CMD:streaks( playerid, params[ ] ) {
return Streak_ShowPlayer( playerid );
}
/* ** SQL Threads ** */
thread OnStreaksLoad( playerid )
{
if ( ! IsPlayerConnected( playerid ) )
return 0;
new
rows, fields, i = -1,
streakid, streak
;
cache_get_data( rows, fields );
if ( rows ) {
while( ++i < rows ) {
// Assign streak
streakid = cache_get_field_content_int( i, "STREAK_ID", dbHandle );
streak = cache_get_field_content_int( i, "STREAK", dbHandle );
// Check if streak is valid and then insert
if ( streakid < MAX_STREAKS )
p_streakData[ playerid ] [ streakid ] [ E_BEST_STREAK ] = streak;
}
}
return 1;
}
/* ** Functions ** */
stock Streak_ShowPlayer( playerid, dialogid = DIALOG_NULL, szSecondButton[ ] = "", forid = INVALID_PLAYER_ID ) {
szLargeString = ""COL_WHITE"Streak\t"COL_WHITE"Best Streak\t"COL_WHITE"Current Streak\n";
for( new streakid = 0, szStreak[ 8 ]; streakid < MAX_STREAKS; streakid++ ) {
szStreak = g_streaksTypes[ streakid ];
szStreak[ 0 ] = toupper( szStreak[ 0 ] );
format( szLargeString, 512, "%s%s\t%d\t%d\n", szLargeString, szStreak, p_streakData[ playerid ] [ streakid ] [ E_BEST_STREAK ], p_streakData[ playerid ] [ streakid ] [ E_STREAK ] );
}
if ( !IsPlayerConnected( forid ) )
forid = playerid;
return ShowPlayerDialog( forid, dialogid, DIALOG_STYLE_TABLIST_HEADERS, "{FFFFFF}Best Streaks", szLargeString, "Okay", szSecondButton );
}
stock Streak_IncrementPlayerStreak( playerid, streakid ) {
if ( ++p_streakData[ playerid ] [ streakid ] [ E_STREAK ] > p_streakData[ playerid ] [ streakid ] [ E_BEST_STREAK ] ) {
p_streakData[ playerid ] [ streakid ] [ E_BEST_STREAK ] = p_streakData[ playerid ] [ streakid ] [ E_STREAK ];
format( szBigString, 196, "INSERT INTO `STREAKS` (`USER_ID`,`STREAK_ID`,`STREAK`) VALUES(%d,%d,%d) ON DUPLICATE KEY UPDATE `STREAK`=%d;", p_AccountID[ playerid ], streakid, p_streakData[ playerid ] [ streakid ] [ E_BEST_STREAK ], p_streakData[ playerid ] [ streakid ] [ E_BEST_STREAK ] );
mysql_single_query( szBigString );
// Notify oneself
SendServerMessage( playerid, "You are currently on your best "COL_GOLD"%s streak"COL_WHITE" of %d!", g_streaksTypes[ streakid ], p_streakData[ playerid ] [ streakid ] [ E_BEST_STREAK ] );
// Beep
Beep( playerid );
}
// Notify whole chat
new
iModulus = 10;
if ( p_streakData[ playerid ] [ streakid ] [ E_STREAK ] > 50 )
iModulus = 1;
else if ( p_streakData[ playerid ] [ streakid ] [ E_STREAK ] > 20 )
iModulus = 5;
if ( p_streakData[ playerid ] [ streakid ] [ E_STREAK ] % iModulus == 0 ) {
if ( p_streakData[ playerid ] [ streakid ] [ E_STREAK ] == p_streakData[ playerid ] [ streakid ] [ E_BEST_STREAK ] ) {
SendGlobalMessage( -1, ""COL_GOLD"[STREAK]{FFFFFF} %s(%d) is currently on their best "COL_GOLD"%s streak"COL_WHITE" of %d!", ReturnPlayerName( playerid ), playerid, g_streaksTypes[ streakid ], p_streakData[ playerid ] [ streakid ] [ E_BEST_STREAK ] );
} else {
SendGlobalMessage( -1, ""COL_GOLD"[STREAK]{FFFFFF} %s(%d) is currently on a "COL_GOLD"%s streak"COL_WHITE" of %d!", ReturnPlayerName( playerid ), playerid, g_streaksTypes[ streakid ], p_streakData[ playerid ] [ streakid ] [ E_STREAK ] );
}
}
}

View File

@ -0,0 +1,106 @@
/*
* Irresistible Gaming (c) 2018
* Developed by Lorenc Pekaj
* Module: cnr\features\player\weapon_stats.pwn
* Purpose: kill counting system for player weapon kills
*/
/* ** Includes ** */
#include < YSI\y_hooks >
/* ** Variables ** */
static stock
p_WeaponKills [ MAX_PLAYERS ] [ MAX_WEAPONS ];
/* ** Commands ** */
CMD:weaponstats( playerid, params[ ] ) {
return WeaponStats_ShowPlayer( playerid );
}
/* ** Hooks ** */
hook OnPlayerDisconnect( playerid, reason )
{
for ( new i = 0; i < MAX_WEAPONS; i ++ ) {
p_WeaponKills[ playerid ] [ i ] = 0;
}
return 1;
}
hook OnPlayerLogin( playerid )
{
format( szNormalString, sizeof( szNormalString ), "SELECT * FROM `WEAPON_STATS` WHERE `USER_ID`=%d", GetPlayerAccountID( playerid ) );
mysql_function_query( dbHandle, szNormalString, true, "OnWeaponStatsLoad", "d", playerid );
return 1;
}
/* ** SQL Threads ** */
thread OnWeaponStatsLoad( playerid )
{
if ( ! IsPlayerConnected( playerid ) )
return 0;
new
rows, fields, i = -1, weaponid;
cache_get_data( rows, fields );
if ( rows ) {
while( ++i < rows ) {
// Assign streak
weaponid = cache_get_field_content_int( i, "WEAPON_ID", dbHandle );
// Check if streak is valid and then insert
if ( weaponid < sizeof( p_WeaponKills[ ] ) )
p_WeaponKills[ playerid ] [ weaponid ] = cache_get_field_content_int( i, "KILLS", dbHandle );
}
}
return 1;
}
thread OnShowWeaponStats( playerid, dialogid, back_option, forid )
{
new
rows;
cache_get_data( rows, tmpVariable );
if ( rows )
{
szLargeString = ""COL_WHITE"Weapon\t"COL_WHITE"Kills\n";
for( new i = 0; i < rows; i++ )
{
new
weaponid = cache_get_field_content_int( i, "WEAPON_ID" ),
streak = cache_get_field_content_int( i, "KILLS" );
format( szLargeString, sizeof( szLargeString ), "%s%s\t%d\n", szLargeString, ReturnWeaponName( weaponid ), streak );
}
return ShowPlayerDialog( forid, DIALOG_NULL, DIALOG_STYLE_TABLIST_HEADERS, "{FFFFFF}Weapon Statistics", szLargeString, "Okay", back_option ? ( "Back" ) : ( "" ) );
}
else
{
return SendError( forid, "Kill someone with anything to display a statistic!" );
}
}
/* ** Functions ** */
stock WeaponStats_IncrementKill( playerid, weaponid, increment = 1 )
{
if ( 0 <= weaponid < MAX_WEAPONS )
{
p_WeaponKills[ playerid ] [ weaponid ] += increment;
format( szBigString, 196, "INSERT INTO `WEAPON_STATS` (`USER_ID`,`WEAPON_ID`,`KILLS`) VALUES(%d,%d,%d) ON DUPLICATE KEY UPDATE `KILLS`=%d;", p_AccountID[ playerid ], weaponid, p_WeaponKills[ playerid ] [ weaponid ], p_WeaponKills[ playerid ] [ weaponid ] );
mysql_single_query( szBigString );
}
}
stock WeaponStats_ShowPlayer( playerid, dialogid = DIALOG_NULL, bool: back_option = false, forid = INVALID_PLAYER_ID )
{
if ( ! IsPlayerConnected( forid ) ) {
forid = playerid;
}
format( szNormalString, sizeof( szNormalString ), "SELECT * FROM `WEAPON_STATS` WHERE `USER_ID`=%d ORDER BY `KILLS` DESC", p_AccountID[ playerid ] );
return mysql_function_query( dbHandle, szNormalString, true, "OnShowWeaponStats", "dddd", playerid, dialogid, back_option, forid );
}

View File

@ -222,7 +222,6 @@ new
p_TimeTiedAt [ MAX_PLAYERS ], p_TimeTiedAt [ MAX_PLAYERS ],
p_CopRefillTimestamp [ MAX_PLAYERS ], p_CopRefillTimestamp [ MAX_PLAYERS ],
p_AdminCommandPause [ MAX_PLAYERS ], p_AdminCommandPause [ MAX_PLAYERS ],
p_WeaponKills [ MAX_PLAYERS ] [ MAX_WEAPONS ],
p_forcedAnticheat [ MAX_PLAYERS ], p_forcedAnticheat [ MAX_PLAYERS ],
p_TiedAtTimestamp [ MAX_PLAYERS ], p_TiedAtTimestamp [ MAX_PLAYERS ],
bool: p_AutoSpin [ MAX_PLAYERS char ], bool: p_AutoSpin [ MAX_PLAYERS char ],

View File

@ -412,23 +412,6 @@ new
p_HitmarkerSound [ MAX_PLAYERS char ] p_HitmarkerSound [ MAX_PLAYERS char ]
; ;
/* ** Streak System ** */
#define MAX_STREAKS ( 3 ) // Changing order will require change in UCP seasonal page.
#define STREAK_ROBBERY 0
#define STREAK_ARREST 1
#define STREAK_KILL 2
enum E_STREAK_DATA
{
E_STREAK, E_BEST_STREAK
};
new
g_streaksTypes[ MAX_STREAKS ] [ 8 ] = { "robbery", "arrest", "kill" },
p_streakData[ MAX_PLAYERS ] [ MAX_STREAKS ] [ E_STREAK_DATA ]
;
/* ** Race System ** */ /* ** Race System ** */
#define MAX_RACES ( 32 ) #define MAX_RACES ( 32 )
@ -2292,7 +2275,6 @@ public OnPlayerDisconnect( playerid, reason )
dischargeVehicles( playerid ); dischargeVehicles( playerid );
CutSpectation( playerid ); CutSpectation( playerid );
LeavePlayerPaintball( playerid ); LeavePlayerPaintball( playerid );
resetPlayerStreaks( playerid );
RemovePlayerFromRace( playerid ); RemovePlayerFromRace( playerid );
ResetPlayerPassiveMode( playerid ); ResetPlayerPassiveMode( playerid );
//p_Detained { playerid } = false; //p_Detained { playerid } = false;
@ -2468,9 +2450,7 @@ public OnPlayerDisconnect( playerid, reason )
} }
if ( i < MAX_GANGS ) p_gangInvited[ playerid ] [ i ] = false; if ( i < MAX_GANGS ) p_gangInvited[ playerid ] [ i ] = false;
if ( i < MAX_WEAPONS ) p_WeaponKills[ playerid ] [ i ] = 0;
if ( i < MAX_RACES ) p_raceInvited[ playerid ] [ i ] = false; if ( i < MAX_RACES ) p_raceInvited[ playerid ] [ i ] = false;
if ( i < MAX_STREAKS ) p_streakData[ playerid ] [ i ] [ E_BEST_STREAK ] = 0, p_streakData[ playerid ] [ i ] [ E_STREAK ] = 0;
p_BlockedPM[ playerid ] [ i ] = false; p_BlockedPM[ playerid ] [ i ] = false;
} }
@ -3314,7 +3294,6 @@ public OnPlayerDeath( playerid, killerid, reason )
TextDrawHideForPlayer( playerid, g_CurrentRankTD ); TextDrawHideForPlayer( playerid, g_CurrentRankTD );
TextDrawHideForPlayer( playerid, g_currentXPTD ); TextDrawHideForPlayer( playerid, g_currentXPTD );
HidePlayerTogglableTextdraws( playerid ); HidePlayerTogglableTextdraws( playerid );
resetPlayerStreaks( playerid );
/* ** Tax And Medical Fees ** */ /* ** Tax And Medical Fees ** */
if ( GetPlayerTotalCash( playerid ) > 0 && ! ( IsPlayerInPaintBall( playerid ) || IsPlayerDueling( playerid ) || IsPlayerInEvent( playerid ) ) ) { if ( GetPlayerTotalCash( playerid ) > 0 && ! ( IsPlayerInPaintBall( playerid ) || IsPlayerDueling( playerid ) || IsPlayerInEvent( playerid ) ) ) {
@ -3365,8 +3344,8 @@ public OnPlayerDeath( playerid, killerid, reason )
case 1000: ShowAchievement( killerid, "Master Killer - 1000 Kills!", 25 ); case 1000: ShowAchievement( killerid, "Master Killer - 1000 Kills!", 25 );
} }
incrementPlayerWeaponKills( killerid, reason ); WeaponStats_IncrementKill( killerid, reason );
incrementPlayerStreak( killerid, STREAK_KILL ); Streak_IncrementPlayerStreak( killerid, STREAK_KILL );
if ( p_VIPLevel[ killerid ] && !isnull( p_DeathMessage[ killerid ] ) ) { if ( p_VIPLevel[ killerid ] && !isnull( p_DeathMessage[ killerid ] ) ) {
GameTextForPlayer( playerid, p_DeathMessage[ killerid ], 4000, 6 ); GameTextForPlayer( playerid, p_DeathMessage[ killerid ], 4000, 6 );
@ -4694,13 +4673,6 @@ CMD:feedback( playerid, params[ ] )
return ShowPlayerDialog( playerid, DIALOG_FEEDBACK, DIALOG_STYLE_INPUT, ""COL_GOLD"Server Feedback", ""COL_WHITE"Let us know how you think we can make the server better to play! Impactful feedback is rewarded.\n\n Be as serious and straight forward as you wish. You can rant if you need to. Be impactful.", "Submit", "Close" ); return ShowPlayerDialog( playerid, DIALOG_FEEDBACK, DIALOG_STYLE_INPUT, ""COL_GOLD"Server Feedback", ""COL_WHITE"Let us know how you think we can make the server better to play! Impactful feedback is rewarded.\n\n Be as serious and straight forward as you wish. You can rant if you need to. Be impactful.", "Submit", "Close" );
} }
CMD:weaponstats( playerid, params[ ] ) {
return displayWeaponStats( playerid );
}
CMD:streaks( playerid, params[ ] ) {
return displayStreaks( playerid );
}
CMD:notes( playerid, params[ ] ) return cmd_mynotes( playerid, params ); CMD:notes( playerid, params[ ] ) return cmd_mynotes( playerid, params );
CMD:myvipnotes( playerid, params[ ] ) return cmd_mynotes( playerid, params ); CMD:myvipnotes( playerid, params[ ] ) return cmd_mynotes( playerid, params );
@ -10093,7 +10065,7 @@ public OnPlayerArrested( playerid, victimid, totalarrests, totalpeople )
iAfter = ( p_Arrests[ playerid ] += totalpeople ) iAfter = ( p_Arrests[ playerid ] += totalpeople )
; ;
incrementPlayerStreak( playerid, STREAK_ARREST ); Streak_IncrementPlayerStreak( playerid, STREAK_ARREST );
if ( iBefore < 1000 && iAfter >= 1000 ) ShowAchievement( playerid, "Arrested ~r~1000~w~~h~~h~ criminals!", 25 ); if ( iBefore < 1000 && iAfter >= 1000 ) ShowAchievement( playerid, "Arrested ~r~1000~w~~h~~h~ criminals!", 25 );
else if ( iBefore < 500 && iAfter >= 500 ) ShowAchievement( playerid, "Arrested ~r~500~w~~h~~h~ criminals!", 18 ); else if ( iBefore < 500 && iAfter >= 500 ) ShowAchievement( playerid, "Arrested ~r~500~w~~h~~h~ criminals!", 18 );
@ -10764,12 +10736,6 @@ thread OnAttemptPlayerLogin( playerid, password[ ] )
format( szNormalString, sizeof( szNormalString ), "SELECT * FROM `VEHICLES` WHERE `OWNER`=%d", p_AccountID[ playerid ] ); format( szNormalString, sizeof( szNormalString ), "SELECT * FROM `VEHICLES` WHERE `OWNER`=%d", p_AccountID[ playerid ] );
mysql_function_query( dbHandle, szNormalString, true, "OnVehicleLoad", "d", playerid ); mysql_function_query( dbHandle, szNormalString, true, "OnVehicleLoad", "d", playerid );
format( szNormalString, sizeof( szNormalString ), "SELECT * FROM `STREAKS` WHERE `USER_ID`=%d", p_AccountID[ playerid ] );
mysql_function_query( dbHandle, szNormalString, true, "OnStreaksLoad", "d", playerid );
format( szNormalString, sizeof( szNormalString ), "SELECT * FROM `WEAPON_STATS` WHERE `USER_ID`=%d", p_AccountID[ playerid ] );
mysql_function_query( dbHandle, szNormalString, true, "OnWeaponStatsLoad", "d", playerid );
if ( p_VIPLevel[ playerid ] ) { if ( p_VIPLevel[ playerid ] ) {
format( szBigString, 192, "SELECT `ID` FROM `NOTES` WHERE (`NOTE` LIKE '{FFDC2E}%%' OR `NOTE` LIKE '{CD7F32}%%') AND `USER_ID`=%d AND `DELETED` IS NULL", p_AccountID[ playerid ] ); format( szBigString, 192, "SELECT `ID` FROM `NOTES` WHERE (`NOTE` LIKE '{FFDC2E}%%' OR `NOTE` LIKE '{CD7F32}%%') AND `USER_ID`=%d AND `DELETED` IS NULL", p_AccountID[ playerid ] );
mysql_function_query( dbHandle, szBigString, true, "checkforvipnotes", "d", playerid ); mysql_function_query( dbHandle, szBigString, true, "checkforvipnotes", "d", playerid );
@ -12111,8 +12077,8 @@ public OnDialogResponse( playerid, dialogid, response, listitem, inputtext[ ] )
format( szLargeString, 700, "%s"COL_GREY"Fireworks:{FFFFFF} %d\n"COL_GREY"Explosive Bullets:{FFFFFF} %d\n", szLargeString, p_Fireworks[ pID ], p_ExplosiveBullets[ pID ] ); format( szLargeString, 700, "%s"COL_GREY"Fireworks:{FFFFFF} %d\n"COL_GREY"Explosive Bullets:{FFFFFF} %d\n", szLargeString, p_Fireworks[ pID ], p_ExplosiveBullets[ pID ] );
ShowPlayerDialog( playerid, DIALOG_STATS_REDIRECT, DIALOG_STYLE_MSGBOX, "{FFFFFF}Item Statistics", szLargeString, "Okay", "Back" ); ShowPlayerDialog( playerid, DIALOG_STATS_REDIRECT, DIALOG_STYLE_MSGBOX, "{FFFFFF}Item Statistics", szLargeString, "Okay", "Back" );
} }
case 3: displayStreaks( pID, DIALOG_STATS_REDIRECT, "Back", playerid ); case 3: Streak_ShowPlayer( pID, DIALOG_STATS_REDIRECT, "Back", playerid );
case 4: displayWeaponStats( pID, DIALOG_STATS_REDIRECT, true, playerid ); case 4: WeaponStats_ShowPlayer( pID, DIALOG_STATS_REDIRECT, true, playerid );
case 5: displayAchievements( pID, DIALOG_STATS_REDIRECT, "Back", playerid ); case 5: displayAchievements( pID, DIALOG_STATS_REDIRECT, "Back", playerid );
} }
} }
@ -16719,7 +16685,7 @@ stock Achievement::HandleMethYielded( playerid )
stock Achievement::HandlePlayerRobbery( playerid ) stock Achievement::HandlePlayerRobbery( playerid )
{ {
incrementPlayerStreak( playerid, STREAK_ROBBERY ); Streak_IncrementPlayerStreak( playerid, STREAK_ROBBERY );
switch( ++p_Robberies[ playerid ] ) switch( ++p_Robberies[ playerid ] )
{ {
@ -16950,57 +16916,6 @@ stock IsPlayerInBank( playerid )
return false; return false;
} }
stock displayStreaks( playerid, dialogid = DIALOG_NULL, szSecondButton[ ] = "", forid = INVALID_PLAYER_ID ) {
szLargeString = ""COL_WHITE"Streak\t"COL_WHITE"Best Streak\t"COL_WHITE"Current Streak\n";
for( new streakid = 0, szStreak[ 8 ]; streakid < MAX_STREAKS; streakid++ ) {
szStreak = g_streaksTypes[ streakid ];
szStreak[ 0 ] = toupper( szStreak[ 0 ] );
format( szLargeString, 512, "%s%s\t%d\t%d\n", szLargeString, szStreak, p_streakData[ playerid ] [ streakid ] [ E_BEST_STREAK ], p_streakData[ playerid ] [ streakid ] [ E_STREAK ] );
}
if ( !IsPlayerConnected( forid ) )
forid = playerid;
return ShowPlayerDialog( forid, dialogid, DIALOG_STYLE_TABLIST_HEADERS, "{FFFFFF}Best Streaks", szLargeString, "Okay", szSecondButton );
}
stock displayWeaponStats( playerid, dialogid = DIALOG_NULL, bool: back_option = false, forid = INVALID_PLAYER_ID )
{
if ( !IsPlayerConnected( forid ) ) forid = playerid;
format( szNormalString, sizeof( szNormalString ), "SELECT * FROM `WEAPON_STATS` WHERE `USER_ID`=%d ORDER BY `KILLS` DESC", p_AccountID[ playerid ] );
return mysql_function_query( dbHandle, szNormalString, true, "OnShowWeaponStats", "dddd", playerid, dialogid, back_option, forid );
}
thread OnShowWeaponStats( playerid, dialogid, back_option, forid )
{
new
rows;
cache_get_data( rows, tmpVariable );
if ( rows )
{
szLargeString = ""COL_WHITE"Weapon\t"COL_WHITE"Kills\n";
for( new i = 0; i < rows; i++ )
{
new
weaponid = cache_get_field_content_int( i, "WEAPON_ID" ),
streak = cache_get_field_content_int( i, "KILLS" );
format( szLargeString, sizeof( szLargeString ), "%s%s\t%d\n", szLargeString, ReturnWeaponName( weaponid ), streak );
}
return ShowPlayerDialog( forid, DIALOG_NULL, DIALOG_STYLE_TABLIST_HEADERS, "{FFFFFF}Weapon Statistics", szLargeString, "Okay", back_option ? ( "Back" ) : ( "" ) );
}
else
{
return SendError( forid, "Kill someone with anything to display a statistic!" );
}
}
stock displayAchievements( playerid, dialogid = DIALOG_NULL, szSecondButton[ ] = "", forid = INVALID_PLAYER_ID ) stock displayAchievements( playerid, dialogid = DIALOG_NULL, szSecondButton[ ] = "", forid = INVALID_PLAYER_ID )
{ {
static static
@ -17603,105 +17518,6 @@ stock GivePlayerLeoWeapons( playerid ) {
} }
} }
stock incrementPlayerStreak( playerid, streakid ) {
if ( ++p_streakData[ playerid ] [ streakid ] [ E_STREAK ] > p_streakData[ playerid ] [ streakid ] [ E_BEST_STREAK ] ) {
p_streakData[ playerid ] [ streakid ] [ E_BEST_STREAK ] = p_streakData[ playerid ] [ streakid ] [ E_STREAK ];
format( szBigString, 196, "INSERT INTO `STREAKS` (`USER_ID`,`STREAK_ID`,`STREAK`) VALUES(%d,%d,%d) ON DUPLICATE KEY UPDATE `STREAK`=%d;", p_AccountID[ playerid ], streakid, p_streakData[ playerid ] [ streakid ] [ E_BEST_STREAK ], p_streakData[ playerid ] [ streakid ] [ E_BEST_STREAK ] );
mysql_single_query( szBigString );
// Notify oneself
SendServerMessage( playerid, "You are currently on your best "COL_GOLD"%s streak"COL_WHITE" of %d!", g_streaksTypes[ streakid ], p_streakData[ playerid ] [ streakid ] [ E_BEST_STREAK ] );
// Beep
Beep( playerid );
}
// Notify whole chat
new
iModulus = 10;
if ( p_streakData[ playerid ] [ streakid ] [ E_STREAK ] > 50 )
iModulus = 1;
else if ( p_streakData[ playerid ] [ streakid ] [ E_STREAK ] > 20 )
iModulus = 5;
if ( p_streakData[ playerid ] [ streakid ] [ E_STREAK ] % iModulus == 0 ) {
if ( p_streakData[ playerid ] [ streakid ] [ E_STREAK ] == p_streakData[ playerid ] [ streakid ] [ E_BEST_STREAK ] ) {
SendGlobalMessage( -1, ""COL_GOLD"[STREAK]{FFFFFF} %s(%d) is currently on their best "COL_GOLD"%s streak"COL_WHITE" of %d!", ReturnPlayerName( playerid ), playerid, g_streaksTypes[ streakid ], p_streakData[ playerid ] [ streakid ] [ E_BEST_STREAK ] );
} else {
SendGlobalMessage( -1, ""COL_GOLD"[STREAK]{FFFFFF} %s(%d) is currently on a "COL_GOLD"%s streak"COL_WHITE" of %d!", ReturnPlayerName( playerid ), playerid, g_streaksTypes[ streakid ], p_streakData[ playerid ] [ streakid ] [ E_STREAK ] );
}
}
}
stock resetPlayerStreaks( playerid ) {
for( new streakid = 0; streakid < MAX_STREAKS; streakid++ )
p_streakData[ playerid ] [ streakid ] [ E_STREAK ] = 0;
}
thread OnStreaksLoad( playerid )
{
if ( !IsPlayerConnected( playerid ) )
return 0;
new
rows, fields, i = -1,
streakid, streak
;
cache_get_data( rows, fields );
if ( rows ) {
while( ++i < rows ) {
// Assign streak
streakid = cache_get_field_content_int( i, "STREAK_ID", dbHandle );
streak = cache_get_field_content_int( i, "STREAK", dbHandle );
// Check if streak is valid and then insert
if ( streakid < MAX_STREAKS )
p_streakData[ playerid ] [ streakid ] [ E_BEST_STREAK ] = streak;
}
}
return 1;
}
stock incrementPlayerWeaponKills( playerid, weaponid, increment = 1 )
{
if ( 0 <= weaponid < MAX_WEAPONS )
{
p_WeaponKills[ playerid ] [ weaponid ] += increment;
format( szBigString, 196, "INSERT INTO `WEAPON_STATS` (`USER_ID`,`WEAPON_ID`,`KILLS`) VALUES(%d,%d,%d) ON DUPLICATE KEY UPDATE `KILLS`=%d;", p_AccountID[ playerid ], weaponid, p_WeaponKills[ playerid ] [ weaponid ], p_WeaponKills[ playerid ] [ weaponid ] );
mysql_single_query( szBigString );
}
}
thread OnWeaponStatsLoad( playerid )
{
if ( !IsPlayerConnected( playerid ) )
return 0;
new
rows, fields, i = -1, weaponid;
cache_get_data( rows, fields );
if ( rows ) {
while( ++i < rows ) {
// Assign streak
weaponid = cache_get_field_content_int( i, "WEAPON_ID", dbHandle );
// Check if streak is valid and then insert
if ( weaponid < sizeof( p_WeaponKills[ ] ) )
p_WeaponKills[ playerid ] [ weaponid ] = cache_get_field_content_int( i, "KILLS", dbHandle );
}
}
return 1;
}
stock UpdateGlobalDonated( playerid = INVALID_PLAYER_ID, Float: amount = 0.0, hidden = 0 ) stock UpdateGlobalDonated( playerid = INVALID_PLAYER_ID, Float: amount = 0.0, hidden = 0 )
{ {
if ( playerid != INVALID_PLAYER_ID && amount > 0.0 ) { if ( playerid != INVALID_PLAYER_ID && amount > 0.0 ) {