diff --git a/gamemodes/irresistible/cnr/commands/admin/admin_rcon.pwn b/gamemodes/irresistible/cnr/commands/admin/admin_rcon.pwn index 1f72ee5..0e64619 100644 --- a/gamemodes/irresistible/cnr/commands/admin/admin_rcon.pwn +++ b/gamemodes/irresistible/cnr/commands/admin/admin_rcon.pwn @@ -89,27 +89,6 @@ CMD:updatepool( playerid, params[ ] ) return 1; } -CMD:updatedonortd( playerid, params[ ] ) -{ - new - targetid, Float: amount, reset; - - if ( !IsPlayerAdmin( playerid ) ) return 0; - else if ( sscanf( params, "D(0)D(65535)F(0.0)", reset, targetid, amount ) ) return SendUsage( playerid, "/updatedonortd [RESET] [PLAYER_ID] [AMOUNT]" ); - else - { - // Reset the top donor - if ( reset ) { - TextDrawSetString( g_TopDonorTD, "Nobody Donated :(" ); - } - - // Update it incase - UpdateGlobalDonated( targetid, amount ); - SendServerMessage( playerid, "Updating latest donor now (player id %d, amount %f)", targetid, amount ); - } - return 1; -} - CMD:destroygang( playerid, params[ ] ) { new diff --git a/gamemodes/irresistible/cnr/global.pwn b/gamemodes/irresistible/cnr/global.pwn index e678e06..c6e19a0 100644 --- a/gamemodes/irresistible/cnr/global.pwn +++ b/gamemodes/irresistible/cnr/global.pwn @@ -7,7 +7,6 @@ /* ** Variables ** */ new - g_redeemVipWait = 0, g_TrolleyVehicles [ 5 ], engine, lights, doors, bonnet, boot, objective, alarm, panels, tires, g_RestoreRobberiesBribes = 0, @@ -39,7 +38,6 @@ new g_iTime = 0, g_VehicleLastAttacker [ MAX_VEHICLES ] = { INVALID_PLAYER_ID, ... }, g_VehicleLastAttacked [ MAX_VEHICLES ], - g_TopDonorWall = INVALID_OBJECT_ID, g_AlcatrazArea = -1 ; diff --git a/gamemodes/irresistible/cnr/textdraws.pwn b/gamemodes/irresistible/cnr/textdraws.pwn index 5120310..345d501 100644 --- a/gamemodes/irresistible/cnr/textdraws.pwn +++ b/gamemodes/irresistible/cnr/textdraws.pwn @@ -23,7 +23,6 @@ new Text: g_currentXPTD = Text: INVALID_TEXT_DRAW, Text: g_CurrentRankTD = Text: INVALID_TEXT_DRAW, Text: g_CurrentCoinsTD = Text: INVALID_TEXT_DRAW, - Text: g_TopDonorTD = Text: INVALID_TEXT_DRAW, Text: g_NotManyPlayersTD = Text: INVALID_TEXT_DRAW, // Player Textdraws @@ -56,15 +55,6 @@ hook OnScriptInit( ) TextDrawSetOutline(g_NotManyPlayersTD, 1); TextDrawSetProportional(g_NotManyPlayersTD, 1); - g_TopDonorTD = TextDrawCreate(320.000000, 2.000000, "Top Donor Lorenc - $0.00, ~w~~h~~h~Latest Donor Lorenc - $0.00"); - TextDrawAlignment(g_TopDonorTD, 2); - TextDrawBackgroundColor(g_TopDonorTD, 0); - TextDrawFont(g_TopDonorTD, 1); - TextDrawLetterSize(g_TopDonorTD, 0.139999, 0.799999); - TextDrawColor(g_TopDonorTD, -2347265); - TextDrawSetOutline(g_TopDonorTD, 1); - TextDrawSetProportional(g_TopDonorTD, 1); - g_currentXPTD = TextDrawCreate(529.000000, 405.000000, "Current XP"); TextDrawBackgroundColor(g_currentXPTD, 255); TextDrawFont(g_currentXPTD, 3); diff --git a/gamemodes/irresistible/cnr/vip/_vip.pwn b/gamemodes/irresistible/cnr/vip/_vip.pwn index 2d79b05..e108505 100644 --- a/gamemodes/irresistible/cnr/vip/_vip.pwn +++ b/gamemodes/irresistible/cnr/vip/_vip.pwn @@ -7,4 +7,5 @@ /* ** Includes ** */ #include "irresistible\cnr\vip\vip.pwn" +#include "irresistible\cnr\vip\redeem_code.pwn" #include "irresistible\cnr\vip\player_market.pwn" diff --git a/gamemodes/irresistible/cnr/vip/redeem_code.pwn b/gamemodes/irresistible/cnr/vip/redeem_code.pwn new file mode 100644 index 0000000..510f73f --- /dev/null +++ b/gamemodes/irresistible/cnr/vip/redeem_code.pwn @@ -0,0 +1,315 @@ +/* + * Irresistible Gaming (c) 2018 + * Developed by Lorenc + * Module: cnr\vip\redeem_code.pwn + * Purpose: code redemption system for newly donating donors + */ + +/* ** Includes ** */ +#include < YSI\y_hooks > + +/* ** Definitions ** */ +#define szRedemptionSalt "7resta#ecacakumedeM=yespawr!d@et" + +/* ** Variables ** */ +enum E_DONATION_DATA +{ + E_TRANSACTION_ID[ 17 ], + E_NAME[ 24 ], + E_AMOUNT[ 11 ], + E_PURPOSE[ 64 ], + E_DATE +}; + +static stock g_redeemVipWait = 0; +static stock g_TopDonorWall = INVALID_OBJECT_ID; +stock Text: g_TopDonorTD = Text: INVALID_TEXT_DRAW; + +/* ** Forwards ** */ +forward OnDonationRedemptionResponse( index, response_code, data[ ] ); + +/* ** Hooks ** */ +hook OnScriptInit( ) +{ + // Wall of Donors + SetDynamicObjectMaterialText( CreateDynamicObject( 3074, -1574.3559, 885.1296, 28.4690, 0.0000, 0.0000, -0.0156 ), 0, "Thx Monthly Donors", 130, "Times New Roman", 64, 1, -65536, 0, 1 ); + SetDynamicObjectMaterialText( ( g_TopDonorWall = CreateDynamicObject( 3074, -1574.3559, 885.1296, 14.0153, 0.0000, 0.0000, -0.0156 ) ), 0, "Nobody donated :(", 130, "Arial", 48, 0, -65536, 0, 1 ); + + // Latest Donor TD + g_TopDonorTD = TextDrawCreate(320.000000, 2.000000, "Top Donor Lorenc - $0.00, ~w~~h~~h~Latest Donor Lorenc - $0.00"); + TextDrawAlignment(g_TopDonorTD, 2); + TextDrawBackgroundColor(g_TopDonorTD, 0); + TextDrawFont(g_TopDonorTD, 1); + TextDrawLetterSize(g_TopDonorTD, 0.139999, 0.799999); + TextDrawColor(g_TopDonorTD, -2347265); + TextDrawSetOutline(g_TopDonorTD, 1); + TextDrawSetProportional(g_TopDonorTD, 1); + + /* ** Update Donation TD ** */ + UpdateGlobalDonated( ); + return 1; +} + +hook OnDialogResponse( playerid, dialogid, response, listitem, inputtext[ ] ) +{ + if ( dialogid == DIALOG_VIP && response ) + { + if ( strlen( inputtext ) != 16 ) + { + cmd_donated( playerid, "" ); + return SendError( playerid, "The transaction ID you entered is invalid." ); + } + + if ( g_redeemVipWait > g_iTime ) + { + cmd_donated( playerid, "" ); + return SendServerMessage( playerid, "Our anti-exploit system requires you to wait another %d seconds before redeeming.", g_redeemVipWait - g_iTime ); + } + + HTTP( playerid, HTTP_GET, sprintf( "donate.sfcnr.com/validate_code/%s", inputtext ), "", "OnDonationRedemptionResponse" ); + SendServerMessage( playerid, "We're now looking up this transaction. Please wait." ); + return 1; + } + else if ( dialogid == DIALOG_DONATED ) + { + szLargeString[ 0 ] = '\0'; + strcat( szLargeString, ""COL_WHITE"Thank you a lot for donating! :D In return for your dignity, you have received Irresistible Coins.\n\n"\ + ""COL_GREY" * What do I do with Irresistible Coins?"COL_WHITE" You can claim the V.I.P of your choice via "COL_GREY"/irresistiblecoins market"COL_WHITE".\n" ); + strcat( szLargeString, ""COL_GREY" * How many do I have?"COL_WHITE" You can see how many Irresistible Coins you have via "COL_GREY"/irresistiblecoins"COL_WHITE".\n" \ + ""COL_GREY" * I'm unsure, help?"COL_WHITE" If you have any questions, please /ask otherwise enquire Lorenc via the forums!\n\nThank you once again for your contribution to our community! :P" ); + return ShowPlayerDialog( playerid, DIALOG_FINISHED_DONATING, DIALOG_STYLE_MSGBOX, ""COL_GOLD"SF-CNR Donation", szLargeString, "Got it!", "" ); + } + else if ( dialogid == DIALOG_FINISHED_DONATING ) + { + return ShowPlayerDialog( playerid, DIALOG_LATEST_DONOR, DIALOG_STYLE_MSGBOX, ""COL_GOLD"SF-CNR Donation", ""COL_WHITE"Would you like to be shown as the latest donor?", "Yes", "No" ); + } + else if ( dialogid == DIALOG_LATEST_DONOR ) + { + if ( GetPVarType( playerid, "just_donated" ) != PLAYER_VARTYPE_FLOAT ) + return SendError( playerid, "Seems to be an issue where we couldn't find how much you donated. Report to Lorenc." ); + + new + Float: fAmount = GetPVarFloat( playerid, "just_donated" ); + + DeletePVar( playerid, "just_donated" ); + return UpdateGlobalDonated( playerid, fAmount, !response ); + } + return 1; +} + +/* ** Callbacks ** */ +public OnDonationRedemptionResponse( index, response_code, data[ ] ) +{ + if ( response_code == 200 ) + { + if ( strmatch( data, "{FFFFFF}Unable to identify transaction." ) ) ShowPlayerDialog( index, DIALOG_NULL, DIALOG_STYLE_MSGBOX, ""COL_GOLD"SF-CNR Donation", data, "Okay", "" ); + else + { + static aDonation[ E_DONATION_DATA ]; + sscanf( data, "p<|>e", aDonation ); + + // printf("donation {id:%s, name:%s, amount:%s, purpose:%s, date:%d}", aDonation[ E_TRANSACTION_ID ],aDonation[ E_NAME ],aDonation[ E_AMOUNT ],aDonation[ E_PURPOSE ],aDonation[ E_DATE ]); + if ( strfind( aDonation[ E_PURPOSE ], "San Fierro: Cops And Robbers" ) == -1 ) { + ShowPlayerDialog( index, DIALOG_NULL, DIALOG_STYLE_MSGBOX, ""COL_GOLD"SF-CNR Donation", ""COL_WHITE"This donation is not specifically for this server thus you are unable to retrieve anything.", "Okay", "" ); + return 0; + } + + // SELECT * FROM `REDEEMED` WHERE `ID` = MD5('%s7resta#ecacakumedeM=yespawr!d@et') LIMIT 0,1 + mysql_format( dbHandle, szNormalString, sizeof( szNormalString ), "SELECT * FROM `REDEEMED` WHERE `ID` = MD5('%e%s') LIMIT 0,1", aDonation[ E_TRANSACTION_ID ], szRedemptionSalt ); + mysql_tquery( dbHandle, szNormalString, "OnCheckForRedeemedVIP", "is", index, data ); + } + } + else + { + return ShowPlayerDialog( index, DIALOG_NULL, DIALOG_STYLE_MSGBOX, ""COL_GOLD"SF-CNR Donation", ""COL_WHITE"Unable to connect to the donation database. Please try again later.", "Okay", "" ); + } + return 1; +} + +/* ** SQL Threads ** */ +thread OnCheckForRedeemedVIP( playerid, data[ ] ) +{ + static + aDonation[ E_DONATION_DATA ], + rows, fields + ; + cache_get_data( rows, fields ); + + if ( rows ) + { + static + szName[ MAX_PLAYER_NAME ]; + + cache_get_field_content( 0, "REDEEMER", szName ); + ShowPlayerDialog( playerid, DIALOG_NULL, DIALOG_STYLE_MSGBOX, ""COL_GOLD"SF-CNR Donation", sprintf( ""COL_WHITE"Sorry this transaction ID has already been redeemed by %s.", szName ), "Okay", "" ); + } + else + { + g_redeemVipWait = g_iTime + 10; + + sscanf( data, "p<|>e", aDonation ); + + mysql_format( dbHandle, szNormalString, sizeof( szNormalString ), "INSERT INTO `REDEEMED`(`ID`, `REDEEMER`) VALUES (MD5('%e%s'), '%e')", aDonation[ E_TRANSACTION_ID ], szRedemptionSalt, ReturnPlayerName( playerid ) ); + mysql_single_query( szNormalString ); + + //printf( "%s\n%s | %s | %f | %s | %d", data, aDonation[ E_TRANSACTION_ID ], aDonation[ E_EMAIL ], floatstr( aDonation[ E_AMOUNT ] ), aDonation[ E_PURPOSE ], aDonation[ E_DATE ]); + + new + Float: fAmount = floatstr( aDonation[ E_AMOUNT ] ), + Float: iCoins = fAmount * ( 1 + GetGVarFloat( "vip_bonus" ) ) * 100.0 + ; + + if ( p_Uptime[ playerid ] > 604800 ) + { + if ( fAmount < 1.99999 ) + return SendError( playerid, "Thanks for donating! As this donation was under $2.00 USD, no coin has been issued." ); + } + else + { + if ( fAmount < 4.99999 ) + return SendError( playerid, "Thanks for donating! As this donation was under $5.00 USD, no coins have been issued." ); + } + + p_IrresistibleCoins[ playerid ] += iCoins; + SetPVarFloat( playerid, "just_donated", fAmount ); + + SendClientMessageFormatted( playerid, -1, ""COL_GOLD"[VIP PACKAGE]"COL_WHITE" You have received %0.0f Irresistible Coins! Thanks for donating %s!!! :D", iCoins, ReturnPlayerName( playerid ) ); + + format( szBigString, 256, ""COL_GREY"Transaction ID:\t"COL_WHITE"%s\n"COL_GREY"Donor Name:\t"COL_WHITE"%s\n"COL_GREY"Amount:\t"COL_WHITE"$%0.2f\n"COL_GREY"Total Coins:\t"COL_WHITE"%0.0f\n"COL_GREY"Time Ago:\t"COL_WHITE"%s", + aDonation[ E_TRANSACTION_ID ], aDonation[ E_NAME ], floatstr( aDonation[ E_AMOUNT ] ), iCoins, secondstotime( g_iTime - aDonation[ E_DATE ] ) ); + + ShowPlayerDialog( playerid, DIALOG_DONATED, DIALOG_STYLE_MSGBOX, ""COL_GOLD"SF-CNR Donation", szBigString, "Continue", "" ); + } + return 1; +} + +thread OnGrabLatestDonor( hidden ) +{ + new + rows; + + cache_get_data( rows, tmpVariable ); + + if ( rows ) + { + static + szName[ MAX_PLAYER_NAME ], + Float: fAmount; + + + cache_get_field_content( 0, "NAME", szName ); + fAmount = cache_get_field_content_float( 0, "LAST_AMOUNT", dbHandle ); + + // Play song! + GameTextForAll( sprintf( "~y~~h~~h~New Donor!~n~~w~%s", szName ), 6000, 3 ); + + // Play sound + foreach(new p : Player) if ( !IsPlayerUsingRadio( p ) ) { + PlayAudioStreamForPlayer( p, "http://files.sfcnr.com/game_sounds/donated.mp3" ); + } + + TextDrawSetString( g_TopDonorTD, sprintf( "Le Latest Donor %s - $%0.2f", szName, fAmount ) ); + } + else + { + TextDrawSetString( g_TopDonorTD, "Nobody Donated :(" ); + } + return 1; +} + +thread OnUpdateWallOfDonors( ) +{ + new + rows; + + cache_get_data( rows, tmpVariable ); + + if( rows ) + { + new + szString[ 600 ], + iLine = 1, + iPosition = 0; + + for( new row = 0; row < rows; row++ ) + { + new + szName[ MAX_PLAYER_NAME ]; + + cache_get_field_content( row, "NAME", szName ); + + new + iOldLength = strlen( szString ) + 4; // 4 is an offset + + if( iOldLength - iPosition > 24 ) { + iPosition = iOldLength; + strcat( szString, "\n" ), iLine ++; + } + + // The wall of donors + format( szString, sizeof( szString ), "%s%s, ", szString, szName ); + } + + // The wall of donors formatting + new + iLength = strlen( szString ); + + strdel( szString, iLength - 2, iLength ); + + // Develop a size and format + SetDynamicObjectMaterialText( g_TopDonorWall, 0, szString, 130, "Arial", floatround( 48.0 * floatpower( 0.925, iLine - 1 ), floatround_ceil ), 0, -65536, 0, 1 ); + } + else + { + SetDynamicObjectMaterialText( g_TopDonorWall, 0, "Nobody Donated :(", 130, "Arial", 48, 0, -65536, 0, 1 ); + } + return 1; +} + +/* ** Commands ** */ +CMD:redeemvip( playerid, params[ ] ) return cmd_donated( playerid, params ); +CMD:donated( playerid, params[ ] ) +{ + ShowPlayerDialog( playerid, DIALOG_VIP, DIALOG_STYLE_INPUT, ""COL_GOLD"SF-CNR Donation", ""COL_WHITE"Enter the transaction ID of your donation below.\n\n"COL_GREY"See http://forum.sfcnr.com/showthread.php?10125 for details.", "Redeem", "Close" ); + return 1; +} + +/* ** RCON Commands ** */ +CMD:updatedonortd( playerid, params[ ] ) +{ + new + targetid, Float: amount, reset; + + if ( ! IsPlayerAdmin( playerid ) ) return 0; + else if ( sscanf( params, "D(0)D(65535)F(0.0)", reset, targetid, amount ) ) return SendUsage( playerid, "/updatedonortd [RESET] [PLAYER_ID] [AMOUNT]" ); + else + { + // Reset the top donor + if ( reset ) { + TextDrawSetString( g_TopDonorTD, "Nobody Donated :(" ); + } + + // Update it incase + UpdateGlobalDonated( targetid, amount ); + SendServerMessage( playerid, "Updating latest donor now (player id %d, amount %f)", targetid, amount ); + } + return 1; +} + +/* ** Functions ** */ +static stock UpdateGlobalDonated( playerid = INVALID_PLAYER_ID, Float: amount = 0.0, hidden = 0 ) +{ + if ( playerid != INVALID_PLAYER_ID && amount > 0.0 ) { + format( szBigString, sizeof( szBigString ), "INSERT INTO `TOP_DONOR` (`USER_ID`,`AMOUNT`,`LAST_AMOUNT`,`TIME`,`HIDE`) VALUES(%d,%f,%f,%d,%d) ON DUPLICATE KEY UPDATE `AMOUNT`=`AMOUNT`+%f,`LAST_AMOUNT`=%f,`TIME`=%d,`HIDE`=%d;", p_AccountID[ playerid ], amount, amount, g_iTime, hidden, amount, amount, g_iTime, hidden ); + mysql_single_query( szBigString ); + } + + // top donor + if ( ! hidden ) { + mysql_tquery( dbHandle, "SELECT `NAME`,`LAST_AMOUNT` FROM `TOP_DONOR` INNER JOIN `USERS` ON `TOP_DONOR`.`USER_ID`=`USERS`.`ID` WHERE `LAST_AMOUNT` > 0 AND `HIDE` < 1 ORDER BY `TIME` DESC LIMIT 1", "OnGrabLatestDonor", "" ); + } + + // wall of donors + mysql_tquery( dbHandle, "SELECT `USERS`.`NAME` FROM `TOP_DONOR` INNER JOIN `USERS` ON `TOP_DONOR`.`USER_ID`=`USERS`.`ID` WHERE `HIDE` < 1 ORDER BY `AMOUNT` DESC, `TIME` DESC", "OnUpdateWallOfDonors", "" ); + return 1; +} diff --git a/gamemodes/sf-cnr.pwn b/gamemodes/sf-cnr.pwn index 4cb7ec1..46081ea 100644 --- a/gamemodes/sf-cnr.pwn +++ b/gamemodes/sf-cnr.pwn @@ -83,17 +83,6 @@ new bool: False = false; #define VW_SHAMAL 220 -/* ** Donation System ** */ -#define szRedemptionSalt "7resta#ecacakumedeM=yespawr!d@et" -enum E_DONATION_DATA -{ - E_TRANSACTION_ID[ 17 ], - E_NAME[ 24 ], - E_AMOUNT[ 11 ], - E_PURPOSE[ 64 ], - E_DATE -} - /* ** Discord ** */ //#include #define ENABLE_DISCORD false @@ -232,7 +221,6 @@ public OnServerSecondTick( ); public OnHelpHTTPResponse( index, response_code, data[ ] ); public OnRulesHTTPResponse( index, response_code, data[ ] ); public OnTwitterHTTPResponse( index, response_code, data[ ] ); -public OnDonationRedemptionResponse( index, response_code, data[ ] ); public OnPlayerArrested( playerid, victimid, totalarrests, totalpeople ); public OnPlayerUnjailed( playerid, reasonid ); public OnPlayerAccessEntrance( playerid, entranceid, worldid, interiorid ); @@ -309,12 +297,6 @@ public OnGameModeInit() g_bankvaultData[ VAULT_BOAT ] [ E_OBJECT ] = CreateDynamicObject( 19435, -2371.416992, 1552.027709, 1.907187, 0.000000, 0.000000, 28.0000, g_bankvaultData[ VAULT_BOAT ] [ E_WORLD ] ); SetDynamicObjectMaterial( g_bankvaultData[ VAULT_BOAT ] [ E_OBJECT ], 0, 18268, "mtbtrackcs_t", "mp_carter_cage", -1 ); - // Wall of Donors - SetDynamicObjectMaterialText( CreateDynamicObject( 3074, -1574.3559, 885.1296, 28.4690, 0.0000, 0.0000, -0.0156 ), 0, "Thx Monthly Donors", 130, "Times New Roman", 64, 1, -65536, 0, 1 ); - - g_TopDonorWall = CreateDynamicObject( 3074, -1574.3559, 885.1296, 14.0153, 0.0000, 0.0000, -0.0156 ); - SetDynamicObjectMaterialText( g_TopDonorWall, 0, "Nobody donated :(", 130, "Arial", 48, 0, -65536, 0, 1 ); - // Alcatraz g_AlcatrazArea = CreateDynamicRectangle( -1921.6816, 1661.7448, -2172.4653, 1876.0469 ); @@ -325,9 +307,6 @@ public OnGameModeInit() /* ** Set everyone offline ** */ mysql_single_query( "UPDATE `USERS` SET `ONLINE` = 0" ); - /* ** Update Donation TD ** */ - UpdateGlobalDonated( ); - /* ** Auto Inactive Deletion ** */ #if !defined DEBUG_MODE @@ -393,88 +372,6 @@ public OnGameModeInit() return 1; } -public OnDonationRedemptionResponse( index, response_code, data[ ] ) -{ - if ( response_code == 200 ) - { - if ( strmatch( data, "{FFFFFF}Unable to identify transaction." ) ) ShowPlayerDialog( index, DIALOG_NULL, DIALOG_STYLE_MSGBOX, ""COL_GOLD"SF-CNR Donation", data, "Okay", "" ); - else - { - static aDonation[ E_DONATION_DATA ]; - sscanf( data, "p<|>e", aDonation ); - - // printf("donation {id:%s, name:%s, amount:%s, purpose:%s, date:%d}", aDonation[ E_TRANSACTION_ID ],aDonation[ E_NAME ],aDonation[ E_AMOUNT ],aDonation[ E_PURPOSE ],aDonation[ E_DATE ]); - if ( strfind( aDonation[ E_PURPOSE ], "San Fierro: Cops And Robbers" ) == -1 ) - { - ShowPlayerDialog( index, DIALOG_NULL, DIALOG_STYLE_MSGBOX, ""COL_GOLD"SF-CNR Donation", ""COL_WHITE"This donation is not specifically for this server thus you are unable to retrieve anything.", "Okay", "" ); - return 0; - } - - // SELECT * FROM `REDEEMED` WHERE `ID` = MD5('%s7resta#ecacakumedeM=yespawr!d@et') LIMIT 0,1 - format( szNormalString, sizeof( szNormalString ), "SELECT * FROM `REDEEMED` WHERE `ID` = MD5('%s%s') LIMIT 0,1", mysql_escape( aDonation[ E_TRANSACTION_ID ] ), szRedemptionSalt ); - mysql_function_query( dbHandle, szNormalString, true, "OnCheckForRedeemedVIP", "is", index, data ); - } - } - else ShowPlayerDialog( index, DIALOG_NULL, DIALOG_STYLE_MSGBOX, ""COL_GOLD"SF-CNR Donation", ""COL_WHITE"Unable to connect to the donation database. Please try again later.", "Okay", "" ); - return 1; -} - -thread OnCheckForRedeemedVIP( playerid, data[ ] ) -{ - static - aDonation[ E_DONATION_DATA ], - rows, fields - ; - cache_get_data( rows, fields ); - - if ( rows ) - { - static - szName[ MAX_PLAYER_NAME ]; - - cache_get_field_content( 0, "REDEEMER", szName ); - ShowPlayerDialog( playerid, DIALOG_NULL, DIALOG_STYLE_MSGBOX, ""COL_GOLD"SF-CNR Donation", sprintf( ""COL_WHITE"Sorry this transaction ID has already been redeemed by %s.", szName ), "Okay", "" ); - } - else - { - g_redeemVipWait = g_iTime + 10; - - sscanf( data, "p<|>e", aDonation ); - - format( szNormalString, sizeof( szNormalString ), "INSERT INTO `REDEEMED`(`ID`, `REDEEMER`) VALUES (MD5('%s%s'), '%s')", mysql_escape( aDonation[ E_TRANSACTION_ID ] ), szRedemptionSalt, ReturnPlayerName( playerid ) ); - mysql_single_query( szNormalString ); - - //printf( "%s\n%s | %s | %f | %s | %d", data, aDonation[ E_TRANSACTION_ID ], aDonation[ E_EMAIL ], floatstr( aDonation[ E_AMOUNT ] ), aDonation[ E_PURPOSE ], aDonation[ E_DATE ]); - - new - Float: fAmount = floatstr( aDonation[ E_AMOUNT ] ), - Float: iCoins = fAmount * ( 1 + GetGVarFloat( "vip_bonus" ) ) * 100.0 - ; - - if ( p_Uptime[ playerid ] > 604800 ) - { - if ( fAmount < 1.99999 ) - return SendError( playerid, "Thanks for donating! As this donation was under $2.00 USD, no coin has been issued." ); - } - else - { - if ( fAmount < 4.99999 ) - return SendError( playerid, "Thanks for donating! As this donation was under $5.00 USD, no coins have been issued." ); - } - - p_IrresistibleCoins[ playerid ] += iCoins; - SetPVarFloat( playerid, "just_donated", fAmount ); - - SendClientMessageFormatted( playerid, -1, ""COL_GOLD"[VIP PACKAGE]"COL_WHITE" You have received %0.0f Irresistible Coins! Thanks for donating %s!!! :D", iCoins, ReturnPlayerName( playerid ) ); - - format( szBigString, 256, ""COL_GREY"Transaction ID:\t"COL_WHITE"%s\n"COL_GREY"Donor Name:\t"COL_WHITE"%s\n"COL_GREY"Amount:\t"COL_WHITE"$%0.2f\n"COL_GREY"Total Coins:\t"COL_WHITE"%0.0f\n"COL_GREY"Time Ago:\t"COL_WHITE"%s", - aDonation[ E_TRANSACTION_ID ], aDonation[ E_NAME ], floatstr( aDonation[ E_AMOUNT ] ), iCoins, secondstotime( g_iTime - aDonation[ E_DATE ] ) ); - - ShowPlayerDialog( playerid, DIALOG_DONATED, DIALOG_STYLE_MSGBOX, ""COL_GOLD"SF-CNR Donation", szBigString, "Continue", "" ); - } - return 1; -} - thread onRemoveInactiveRows( type ) { new @@ -3086,13 +2983,6 @@ CMD:idletime( playerid, params[ ] ) return 1; } -CMD:redeemvip( playerid, params[ ] ) return cmd_donated( playerid, params ); -CMD:donated( playerid, params[ ] ) -{ - ShowPlayerDialog( playerid, DIALOG_VIP, DIALOG_STYLE_INPUT, ""COL_GOLD"SF-CNR Donation", ""COL_WHITE"Enter the transaction ID of your donation below.\n\n"COL_GREY"See http://forum.sfcnr.com/showthread.php?10125 for details.", "Redeem", "Close" ); - return 1; -} - CMD:robitems( playerid, params[ ] ) { /* ** ANTI ROB SPAM ** */ @@ -8750,45 +8640,6 @@ public OnDialogResponse( playerid, dialogid, response, listitem, inputtext[ ] ) } if ( ( dialogid == DIALOG_HELP_BACK ) && !response ) return cmd_help( playerid, "" ); - if ( ( dialogid == DIALOG_VIP ) && response ) - { - if ( strlen( inputtext ) != 16 ) - { - cmd_donated( playerid, "" ); - return SendError( playerid, "The transaction ID you entered is invalid." ); - } - - if ( g_redeemVipWait > g_iTime ) - { - cmd_donated( playerid, "" ); - return SendServerMessage( playerid, "Our anti-exploit system requires you to wait another %d seconds before redeeming.", g_redeemVipWait - g_iTime ); - } - - HTTP( playerid, HTTP_GET, sprintf( "donate.sfcnr.com/validate_code/%s", inputtext ), "", "OnDonationRedemptionResponse" ); - SendServerMessage( playerid, "We're now looking up this transaction. Please wait." ); - } - if ( dialogid == DIALOG_DONATED ) - { - szLargeString[ 0 ] = '\0'; - strcat( szLargeString, ""COL_WHITE"Thank you a lot for donating! :D In return for your dignity, you have received Irresistible Coins.\n\n"\ - ""COL_GREY" * What do I do with Irresistible Coins?"COL_WHITE" You can claim the V.I.P of your choice via "COL_GREY"/irresistiblecoins market"COL_WHITE".\n" ); - strcat( szLargeString, ""COL_GREY" * How many do I have?"COL_WHITE" You can see how many Irresistible Coins you have via "COL_GREY"/irresistiblecoins"COL_WHITE".\n" \ - ""COL_GREY" * I'm unsure, help?"COL_WHITE" If you have any questions, please /ask otherwise enquire Lorenc via the forums!\n\nThank you once again for your contribution to our community! :P" ); - return ShowPlayerDialog( playerid, DIALOG_FINISHED_DONATING, DIALOG_STYLE_MSGBOX, ""COL_GOLD"SF-CNR Donation", szLargeString, "Got it!", "" ); - } - if ( dialogid == DIALOG_FINISHED_DONATING ) { - return ShowPlayerDialog( playerid, DIALOG_LATEST_DONOR, DIALOG_STYLE_MSGBOX, ""COL_GOLD"SF-CNR Donation", ""COL_WHITE"Would you like to be shown as the latest donor?", "Yes", "No" ); - } - if ( dialogid == DIALOG_LATEST_DONOR ) { - if ( GetPVarType( playerid, "just_donated" ) != PLAYER_VARTYPE_FLOAT ) - return SendError( playerid, "Seems to be an issue where we couldn't find how much you donated. Report to Lorenc." ); - - new - Float: fAmount = GetPVarFloat( playerid, "just_donated" ); - - DeletePVar( playerid, "just_donated" ); - return UpdateGlobalDonated( playerid, fAmount, !response ); - } if ( ( dialogid == DIALOG_UNBAN_CLASS ) && response ) { cmd_unbanme( playerid, "" ); @@ -11753,106 +11604,6 @@ stock GivePlayerLeoWeapons( playerid ) { } } -stock UpdateGlobalDonated( playerid = INVALID_PLAYER_ID, Float: amount = 0.0, hidden = 0 ) -{ - if ( playerid != INVALID_PLAYER_ID && amount > 0.0 ) { - format( szBigString, sizeof( szBigString ), "INSERT INTO `TOP_DONOR` (`USER_ID`,`AMOUNT`,`LAST_AMOUNT`,`TIME`,`HIDE`) VALUES(%d,%f,%f,%d,%d) ON DUPLICATE KEY UPDATE `AMOUNT`=`AMOUNT`+%f,`LAST_AMOUNT`=%f,`TIME`=%d,`HIDE`=%d;", p_AccountID[ playerid ], amount, amount, g_iTime, hidden, amount, amount, g_iTime, hidden ); - mysql_single_query( szBigString ); - } - - // top donor - if ( ! hidden ) { - mysql_function_query( dbHandle, "SELECT `NAME`,`LAST_AMOUNT` FROM `TOP_DONOR` INNER JOIN `USERS` ON `TOP_DONOR`.`USER_ID`=`USERS`.`ID` WHERE `LAST_AMOUNT` > 0 AND `HIDE` < 1 ORDER BY `TIME` DESC LIMIT 1", true, "OnGrabLatestDonor", "" ); - } - - // wall of donors - mysql_function_query( dbHandle, "SELECT `USERS`.`NAME` FROM `TOP_DONOR` INNER JOIN `USERS` ON `TOP_DONOR`.`USER_ID`=`USERS`.`ID` WHERE `HIDE` < 1 ORDER BY `AMOUNT` DESC, `TIME` DESC", true, "OnUpdateWallOfDonors", "" ); - return 1; -} - -thread OnGrabLatestDonor( hidden ) -{ - new - rows; - - cache_get_data( rows, tmpVariable ); - - if ( rows ) - { - static - szName[ MAX_PLAYER_NAME ], - Float: fAmount; - - - cache_get_field_content( 0, "NAME", szName ); - fAmount = cache_get_field_content_float( 0, "LAST_AMOUNT", dbHandle ); - - // Play song! - GameTextForAll( sprintf( "~y~~h~~h~New Donor!~n~~w~%s", szName ), 6000, 3 ); - - // Play sound - foreach(new p : Player) if ( !IsPlayerUsingRadio( p ) ) { - PlayAudioStreamForPlayer( p, "http://files.sfcnr.com/game_sounds/donated.mp3" ); - } - - TextDrawSetString( g_TopDonorTD, sprintf( "Le Latest Donor %s - $%0.2f", szName, fAmount ) ); - } - else - { - TextDrawSetString( g_TopDonorTD, "Nobody Donated :(" ); - } - return 1; -} - -thread OnUpdateWallOfDonors( ) -{ - new - rows; - - cache_get_data( rows, tmpVariable ); - - if( rows ) - { - new - szString[ 600 ], - iLine = 1, - iPosition = 0; - - for( new row = 0; row < rows; row++ ) - { - new - szName[ MAX_PLAYER_NAME ]; - - cache_get_field_content( row, "NAME", szName ); - - new - iOldLength = strlen( szString ) + 4; // 4 is an offset - - if( iOldLength - iPosition > 24 ) { - iPosition = iOldLength; - strcat( szString, "\n" ), iLine ++; - } - - // The wall of donors - format( szString, sizeof( szString ), "%s%s, ", szString, szName ); - } - - // The wall of donors formatting - new - iLength = strlen( szString ); - - strdel( szString, iLength - 2, iLength ); - - // Develop a size and format - SetDynamicObjectMaterialText( g_TopDonorWall, 0, szString, 130, "Arial", floatround( 48.0 * floatpower( 0.925, iLine - 1 ), floatround_ceil ), 0, -65536, 0, 1 ); - } - else - { - SetDynamicObjectMaterialText( g_TopDonorWall, 0, "Nobody Donated :(", 130, "Arial", 48, 0, -65536, 0, 1 ); - } - return 1; -} - stock IsSafeGameText(string[]) { new count;