diff --git a/gamemodes/irresistible/cnr/commands/admin/admin_one.pwn b/gamemodes/irresistible/cnr/commands/admin/admin_one.pwn index 7db2593..cf216fa 100644 --- a/gamemodes/irresistible/cnr/commands/admin/admin_one.pwn +++ b/gamemodes/irresistible/cnr/commands/admin/admin_one.pwn @@ -205,7 +205,7 @@ CMD:frules( playerid, params[ ] ) else if ( !IsPlayerSpawned( pID ) ) return SendError( playerid, "This player isn't spawned." ); else { - cmd_rules( pID, "" ); + ShowPlayerRules( pID ); SendClientMessageFormatted( playerid, -1, ""COL_PINK"[ADMIN]"COL_WHITE" You have shown %s(%d) the /rules", ReturnPlayerName( pID ), pID ); AddAdminLogLineFormatted( "%s(%d) has shown the rules to %s(%d)", ReturnPlayerName( playerid ), playerid, ReturnPlayerName( pID ), pID ); } @@ -570,7 +570,7 @@ CMD:jail( playerid, params [ ] ) p_AdminCommandPause[ pID ] = g_iTime + ADMIN_COMMAND_TIME; AddAdminLogLineFormatted( "%s(%d) has jailed %s(%d) for %d seconds", ReturnPlayerName( playerid ), playerid, ReturnPlayerName( pID ), pID, Seconds ); JailPlayer( pID, Seconds, 1 ); - if ( Seconds > 60 ) cmd_rules( pID, "" ); // Force rules + if ( Seconds > 60 ) ShowPlayerRules( pID ); // force rules SendGlobalMessage( -1, ""COL_GOLD"[JAIL]{FFFFFF} %s(%d) has been sent to jail for %d seconds by %s "COL_GREEN"[REASON: %s]", ReturnPlayerName( pID ), pID, Seconds, ReturnPlayerName( playerid ), reason ); } return 1; diff --git a/gamemodes/irresistible/cnr/features/_features.pwn b/gamemodes/irresistible/cnr/features/_features.pwn index 9838685..1e629a7 100644 --- a/gamemodes/irresistible/cnr/features/_features.pwn +++ b/gamemodes/irresistible/cnr/features/_features.pwn @@ -25,6 +25,7 @@ // other #include "irresistible\cnr\features\passive_mode.pwn" +#include "irresistible\cnr\features\server_rules.pwn" #include "irresistible\cnr\features\toys.pwn" #include "irresistible\cnr\features\fps.pwn" #include "irresistible\cnr\features\radio.pwn" diff --git a/gamemodes/irresistible/cnr/features/server_rules.pwn b/gamemodes/irresistible/cnr/features/server_rules.pwn new file mode 100644 index 0000000..880e021 --- /dev/null +++ b/gamemodes/irresistible/cnr/features/server_rules.pwn @@ -0,0 +1,50 @@ +/* + * Irresistible Gaming (c) 2018 + * Developed by Lorenc + * Module: cnr\features\server_rules.pwn + * Purpose: server rules implementation (/rules) that scans URL + */ + +/* ** Includes ** */ +#include < YSI\y_hooks > + +#if defined SERVER_RULES_URL + + /* ** Variables ** */ + static stock szRules [ 3300 ]; + + /* ** Forwards ** */ + public OnRulesHTTPResponse( index, response_code, data[ ] ); + + /* ** Hooks ** */ + hook OnScriptInit( ) { + HTTP( 0, HTTP_GET, SERVER_RULES_URL, "", "OnRulesHTTPResponse" ); + return 1; + } + + /* ** Functions ** */ + public OnRulesHTTPResponse( index, response_code, data[ ] ) { + if ( response_code == 200 ) { + printf( "[RULES] Rules have been updated! Character Size: %d", strlen( data ) ); + strcpy( szRules, data ); + } + return 1; + } + + /* ** Commands ** */ + CMD:rules( playerid, params[ ] ) { + return ShowPlayerRules( playerid ); + } + +#endif + +/* ** Functions ** */ +stock ShowPlayerRules( playerid ) +{ + #if !defined SERVER_RULES_URL + #pragma unused playerid + return 1; + #else + return ShowPlayerDialog( playerid, DIALOG_NULL, DIALOG_STYLE_MSGBOX, "{FFFFFF}Rules", szRules, "Okay", "" ), 1; + #endif +} \ No newline at end of file diff --git a/gamemodes/irresistible/cnr/global.pwn b/gamemodes/irresistible/cnr/global.pwn index dc72616..239211f 100644 --- a/gamemodes/irresistible/cnr/global.pwn +++ b/gamemodes/irresistible/cnr/global.pwn @@ -24,7 +24,6 @@ new szQuestionsLog [ 8 ][ 128 ], bool: g_CommandLogging = false, bool: g_DialogLogging = false, - szRules [ 3300 ], g_BannedDrivebyWeapons [ ] = { 24, 26, 27, 34, 33 diff --git a/gamemodes/irresistible/config/server.pwn b/gamemodes/irresistible/config/server.pwn index bc88a85..4e29a53 100644 --- a/gamemodes/irresistible/config/server.pwn +++ b/gamemodes/irresistible/config/server.pwn @@ -19,6 +19,8 @@ #define SERVER_WEBSITE "www.sfcnr.com" #define SERVER_IP "54.36.127.43:7777" +//#define SERVER_RULES_URL "files.sfcnr.com/en_rules.txt" // comment to disable feature + /* ** Hooks ** */ hook OnScriptInit( ) { diff --git a/gamemodes/sf-cnr.pwn b/gamemodes/sf-cnr.pwn index 0699ea2..00a3695 100644 --- a/gamemodes/sf-cnr.pwn +++ b/gamemodes/sf-cnr.pwn @@ -87,7 +87,6 @@ public OnPlayerDriveVehicle( playerid, vehicleid ); public OnServerUpdateTimer( ); public OnServerSecondTick( ); public OnHelpHTTPResponse( index, response_code, data[ ] ); -public OnRulesHTTPResponse( index, response_code, data[ ] ); public OnTwitterHTTPResponse( index, response_code, data[ ] ); public OnPlayerAccessEntrance( playerid, entranceid, worldid, interiorid ); @@ -212,8 +211,6 @@ public OnGameModeInit() rl_ServerUpdate = SetTimer( "OnServerUpdateTimer", 960, true ); rl_ZoneUpdate = SetTimer( "OnServerSecondTick", 980, true ); - HTTP( 0, HTTP_GET, "files.sfcnr.com/en_rules.txt", "", "OnRulesHTTPResponse" ); - printf( "[SF-CNR] SF-CnR has been successfully initialized. (Build: "#FILE_BUILD" | Time: %d | Tickcount: %d)", ( g_ServerUptime = gettime( ) ), GetTickCount( ) ); return 1; } @@ -553,16 +550,6 @@ public OnServerSecondTick( ) return 1; } -public OnRulesHTTPResponse( index, response_code, data[ ] ) -{ - if ( response_code == 200 ) - { - printf( "[RULES] Rules have been updated! Character Size: %d", strlen( data ) ); - strcpy( szRules, data ); - } - return 1; -} - public OnTwitterHTTPResponse( index, response_code, data[ ] ) { if ( response_code == 200 ) //Did the request succeed? @@ -1787,7 +1774,7 @@ public OnPlayerDeath( playerid, killerid, reason ) GivePlayerCash( killerid, -10000 ); GivePlayerScore( killerid, -2 ); JailPlayer( killerid, 200, 1 ); - cmd_rules( killerid, "" ); + ShowPlayerRules( killerid ); WarnPlayerClass( killerid, p_inArmy{ killerid } ); SendGlobalMessage( -1, ""COL_GOLD"[JAIL]{FFFFFF} %s(%d) has been sent to jail for 200 seconds by the server "COL_GREEN"[REASON: Killing Teammate(s)]", ReturnPlayerName( killerid ), killerid ); return 1; @@ -1815,7 +1802,7 @@ public OnPlayerDeath( playerid, killerid, reason ) GivePlayerCash( killerid, -10000 ); GivePlayerScore( killerid, -2 ); JailPlayer( killerid, 200, 1 ); - cmd_rules( killerid, "" ); + ShowPlayerRules( killerid ); WarnPlayerClass( killerid, p_inArmy{ killerid } ); SendGlobalMessage( -1, ""COL_GOLD"[JAIL]{FFFFFF} %s(%d) has been sent to jail for 200 seconds by the server "COL_GREEN"[REASON: Killing Innocent(s)]", ReturnPlayerName( killerid ), killerid ); } @@ -3694,12 +3681,6 @@ CMD:hitlist( playerid, params[ ] ) } } -CMD:rules( playerid, params[ ] ) -{ - ShowPlayerDialog( playerid, DIALOG_NULL, DIALOG_STYLE_MSGBOX, "{FFFFFF}Rules", szRules, "Okay", "" ); - return 1; -} - CMD:viewguns( playerid, params[ ] ) { /* ** COOL DOWN ** */