add server rule setting in config.pwn

This commit is contained in:
Lorenc Pekaj 2018-12-23 10:13:49 +11:00
parent 49d646048b
commit 08e25e4a5b
6 changed files with 57 additions and 24 deletions

View File

@ -205,7 +205,7 @@ CMD:frules( playerid, params[ ] )
else if ( !IsPlayerSpawned( pID ) ) return SendError( playerid, "This player isn't spawned." ); else if ( !IsPlayerSpawned( pID ) ) return SendError( playerid, "This player isn't spawned." );
else else
{ {
cmd_rules( pID, "" ); ShowPlayerRules( pID );
SendClientMessageFormatted( playerid, -1, ""COL_PINK"[ADMIN]"COL_WHITE" You have shown %s(%d) the /rules", ReturnPlayerName( pID ), 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 ); 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; 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 ); AddAdminLogLineFormatted( "%s(%d) has jailed %s(%d) for %d seconds", ReturnPlayerName( playerid ), playerid, ReturnPlayerName( pID ), pID, Seconds );
JailPlayer( pID, Seconds, 1 ); 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 ); 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; return 1;

View File

@ -25,6 +25,7 @@
// other // other
#include "irresistible\cnr\features\passive_mode.pwn" #include "irresistible\cnr\features\passive_mode.pwn"
#include "irresistible\cnr\features\server_rules.pwn"
#include "irresistible\cnr\features\toys.pwn" #include "irresistible\cnr\features\toys.pwn"
#include "irresistible\cnr\features\fps.pwn" #include "irresistible\cnr\features\fps.pwn"
#include "irresistible\cnr\features\radio.pwn" #include "irresistible\cnr\features\radio.pwn"

View File

@ -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
}

View File

@ -24,7 +24,6 @@ new
szQuestionsLog [ 8 ][ 128 ], szQuestionsLog [ 8 ][ 128 ],
bool: g_CommandLogging = false, bool: g_CommandLogging = false,
bool: g_DialogLogging = false, bool: g_DialogLogging = false,
szRules [ 3300 ],
g_BannedDrivebyWeapons [ ] = g_BannedDrivebyWeapons [ ] =
{ {
24, 26, 27, 34, 33 24, 26, 27, 34, 33

View File

@ -19,6 +19,8 @@
#define SERVER_WEBSITE "www.sfcnr.com" #define SERVER_WEBSITE "www.sfcnr.com"
#define SERVER_IP "54.36.127.43:7777" #define SERVER_IP "54.36.127.43:7777"
//#define SERVER_RULES_URL "files.sfcnr.com/en_rules.txt" // comment to disable feature
/* ** Hooks ** */ /* ** Hooks ** */
hook OnScriptInit( ) hook OnScriptInit( )
{ {

View File

@ -87,7 +87,6 @@ public OnPlayerDriveVehicle( playerid, vehicleid );
public OnServerUpdateTimer( ); public OnServerUpdateTimer( );
public OnServerSecondTick( ); public OnServerSecondTick( );
public OnHelpHTTPResponse( index, response_code, data[ ] ); public OnHelpHTTPResponse( index, response_code, data[ ] );
public OnRulesHTTPResponse( index, response_code, data[ ] );
public OnTwitterHTTPResponse( index, response_code, data[ ] ); public OnTwitterHTTPResponse( index, response_code, data[ ] );
public OnPlayerAccessEntrance( playerid, entranceid, worldid, interiorid ); public OnPlayerAccessEntrance( playerid, entranceid, worldid, interiorid );
@ -212,8 +211,6 @@ public OnGameModeInit()
rl_ServerUpdate = SetTimer( "OnServerUpdateTimer", 960, true ); rl_ServerUpdate = SetTimer( "OnServerUpdateTimer", 960, true );
rl_ZoneUpdate = SetTimer( "OnServerSecondTick", 980, 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( ) ); printf( "[SF-CNR] SF-CnR has been successfully initialized. (Build: "#FILE_BUILD" | Time: %d | Tickcount: %d)", ( g_ServerUptime = gettime( ) ), GetTickCount( ) );
return 1; return 1;
} }
@ -553,16 +550,6 @@ public OnServerSecondTick( )
return 1; 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[ ] ) public OnTwitterHTTPResponse( index, response_code, data[ ] )
{ {
if ( response_code == 200 ) //Did the request succeed? if ( response_code == 200 ) //Did the request succeed?
@ -1787,7 +1774,7 @@ public OnPlayerDeath( playerid, killerid, reason )
GivePlayerCash( killerid, -10000 ); GivePlayerCash( killerid, -10000 );
GivePlayerScore( killerid, -2 ); GivePlayerScore( killerid, -2 );
JailPlayer( killerid, 200, 1 ); JailPlayer( killerid, 200, 1 );
cmd_rules( killerid, "" ); ShowPlayerRules( killerid );
WarnPlayerClass( killerid, p_inArmy{ 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 ); 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; return 1;
@ -1815,7 +1802,7 @@ public OnPlayerDeath( playerid, killerid, reason )
GivePlayerCash( killerid, -10000 ); GivePlayerCash( killerid, -10000 );
GivePlayerScore( killerid, -2 ); GivePlayerScore( killerid, -2 );
JailPlayer( killerid, 200, 1 ); JailPlayer( killerid, 200, 1 );
cmd_rules( killerid, "" ); ShowPlayerRules( killerid );
WarnPlayerClass( killerid, p_inArmy{ 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 ); 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[ ] ) CMD:viewguns( playerid, params[ ] )
{ {
/* ** COOL DOWN ** */ /* ** COOL DOWN ** */