move game day code into its own module
This commit is contained in:
parent
16b12b4610
commit
1427fc0196
@ -119,7 +119,7 @@ CMD:time( playerid, params[ ] )
|
|||||||
if ( sscanf( params, "d", timeid ) )
|
if ( sscanf( params, "d", timeid ) )
|
||||||
return SendUsage( playerid, "/time [SECONDS]" );
|
return SendUsage( playerid, "/time [SECONDS]" );
|
||||||
|
|
||||||
g_WorldClockSeconds = timeid;
|
SetWorldClock( timeid );
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -421,8 +421,7 @@ CMD:weather( playerid, params[ ] )
|
|||||||
if ( sscanf( params, "d", weatherid ) )
|
if ( sscanf( params, "d", weatherid ) )
|
||||||
return SendUsage( playerid, "/weather [WEATHER_ID]" );
|
return SendUsage( playerid, "/weather [WEATHER_ID]" );
|
||||||
|
|
||||||
g_WorldWeather = weatherid;
|
SetWorldWeather( weatherid );
|
||||||
|
|
||||||
SaveToAdminLogFormatted( playerid, 0, "weather %d", weatherid );
|
SaveToAdminLogFormatted( playerid, 0, "weather %d", weatherid );
|
||||||
AddAdminLogLineFormatted( "%s(%d) has changed the weather to %d", ReturnPlayerName( playerid ), playerid, weatherid );
|
AddAdminLogLineFormatted( "%s(%d) has changed the weather to %d", ReturnPlayerName( playerid ), playerid, weatherid );
|
||||||
SendGlobalMessage( -1, ""COL_PINK"[ADMIN]"COL_WHITE" %s(%d) has changed the weather to %d!", ReturnPlayerName( playerid ), playerid, weatherid );
|
SendGlobalMessage( -1, ""COL_PINK"[ADMIN]"COL_WHITE" %s(%d) has changed the weather to %d!", ReturnPlayerName( playerid ), playerid, weatherid );
|
||||||
|
@ -28,6 +28,7 @@
|
|||||||
|
|
||||||
// other
|
// other
|
||||||
#include "irresistible\cnr\features\ammunation.pwn"
|
#include "irresistible\cnr\features\ammunation.pwn"
|
||||||
|
#include "irresistible\cnr\features\game_day.pwn"
|
||||||
#include "irresistible\cnr\features\movie_mode.pwn"
|
#include "irresistible\cnr\features\movie_mode.pwn"
|
||||||
#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\server_rules.pwn"
|
||||||
|
99
gamemodes/irresistible/cnr/features/game_day.pwn
Normal file
99
gamemodes/irresistible/cnr/features/game_day.pwn
Normal file
@ -0,0 +1,99 @@
|
|||||||
|
/*
|
||||||
|
* Irresistible Gaming (c) 2018
|
||||||
|
* Developed by Lorenc
|
||||||
|
* Module: cnr\features\game_day.pwn
|
||||||
|
* Purpose: adds a game week day after 24:00 elapses
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* ** Includes ** */
|
||||||
|
#include < YSI\y_hooks >
|
||||||
|
|
||||||
|
/* ** Variables ** */
|
||||||
|
static stock
|
||||||
|
Text: g_WorldDayTD = Text: INVALID_TEXT_DRAW,
|
||||||
|
g_WorldClockSeconds = 0,
|
||||||
|
g_WorldDayCount = 0,
|
||||||
|
g_WorldWeather = 10
|
||||||
|
;
|
||||||
|
|
||||||
|
/* ** Hooks ** */
|
||||||
|
hook OnScriptInit( )
|
||||||
|
{
|
||||||
|
g_WorldDayTD = TextDrawCreate(501.000000, 6.000000, "Monday");
|
||||||
|
TextDrawBackgroundColor(g_WorldDayTD, 255);
|
||||||
|
TextDrawFont(g_WorldDayTD, 3);
|
||||||
|
TextDrawLetterSize(g_WorldDayTD, 0.519998, 1.499999);
|
||||||
|
TextDrawSetOutline(g_WorldDayTD, 2);
|
||||||
|
TextDrawSetProportional(g_WorldDayTD, 1);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
hook OnPlayerTickSecond( playerid )
|
||||||
|
{
|
||||||
|
SetPlayerWeather( playerid, ( GetPlayerInterior( playerid ) || GetPlayerVirtualWorld( playerid ) ) ? 1 : g_WorldWeather );
|
||||||
|
UpdatePlayerTime( playerid );
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
hook OnServerTickSecond( )
|
||||||
|
{
|
||||||
|
// set the world time at the query
|
||||||
|
SendRconCommand( sprintf( "worldtime %s, %s", GetDayToString( g_WorldDayCount ), TimeConvert( g_WorldClockSeconds++ ) ) );
|
||||||
|
|
||||||
|
if ( g_WorldClockSeconds >= 1440 )
|
||||||
|
{
|
||||||
|
// call a function when the server day ends
|
||||||
|
CallLocalFunction( "OnServerGameDayEnd", "" );
|
||||||
|
|
||||||
|
// set weather
|
||||||
|
g_WorldWeather = randarg( 10, 11, 12 );
|
||||||
|
g_WorldClockSeconds = 0;
|
||||||
|
g_WorldDayCount = ( g_WorldDayCount == 6 ? 0 : g_WorldDayCount + 1 );
|
||||||
|
TextDrawSetString( g_WorldDayTD, GetDayToString( g_WorldDayCount ) );
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
hook OnPlayerLoadTextdraws( playerid )
|
||||||
|
{
|
||||||
|
TextDrawShowForPlayer( playerid, g_WorldDayTD );
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
hook OnPlayerUnloadTextdraws( playerid )
|
||||||
|
{
|
||||||
|
TextDrawHideForPlayer( playerid, g_WorldDayTD );
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ** Functions ** */
|
||||||
|
stock GetDayToString( day )
|
||||||
|
{
|
||||||
|
static
|
||||||
|
string[ 10 ];
|
||||||
|
|
||||||
|
switch( day )
|
||||||
|
{
|
||||||
|
case 0: string = "Monday";
|
||||||
|
case 1: string = "Tuesday";
|
||||||
|
case 2: string = "Wednesday";
|
||||||
|
case 3: string = "Thursday";
|
||||||
|
case 4: string = "Friday";
|
||||||
|
case 5: string = "Saturday";
|
||||||
|
case 6: string = "Sunday";
|
||||||
|
default: string = "Bugged";
|
||||||
|
}
|
||||||
|
return string;
|
||||||
|
}
|
||||||
|
|
||||||
|
stock UpdatePlayerTime( playerid ) {
|
||||||
|
return SetPlayerTime( playerid, floatround( g_WorldClockSeconds / 60 ), g_WorldClockSeconds - floatround( ( g_WorldClockSeconds / 60 ) * 60 ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
stock SetWorldWeather( weatherid ) {
|
||||||
|
g_WorldWeather = weatherid;
|
||||||
|
}
|
||||||
|
|
||||||
|
stock SetWorldClock( seconds ) {
|
||||||
|
g_WorldClockSeconds = ! ( 0 <= seconds <= 1440 ) ? 0 : seconds;
|
||||||
|
}
|
@ -97,6 +97,17 @@ static stock
|
|||||||
forward Float: GetPlayerIrresistibleCoins( playerid );
|
forward Float: GetPlayerIrresistibleCoins( playerid );
|
||||||
|
|
||||||
/* ** Hooks ** */
|
/* ** Hooks ** */
|
||||||
|
#if defined SERVER_PLS_DONATE_MP3
|
||||||
|
hook OnServerGameDayEnd( )
|
||||||
|
{
|
||||||
|
foreach ( new p : Player ) if ( ! p_VIPLevel[ p ] && ! IsPlayerUsingRadio( p ) )
|
||||||
|
{
|
||||||
|
PlayAudioStreamForPlayer( p, SERVER_PLS_DONATE_MP3 );
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
hook OnPlayerUpdateEx( playerid )
|
hook OnPlayerUpdateEx( playerid )
|
||||||
{
|
{
|
||||||
CheckPlayerVipExpiry( playerid );
|
CheckPlayerVipExpiry( playerid );
|
||||||
|
@ -14,9 +14,6 @@ new
|
|||||||
rl_ZoneUpdate = 0xFF,
|
rl_ZoneUpdate = 0xFF,
|
||||||
rl_AutoVehicleRespawner = 0xFF,
|
rl_AutoVehicleRespawner = 0xFF,
|
||||||
bool: g_adminSpawnedCar [ MAX_VEHICLES char ],
|
bool: g_adminSpawnedCar [ MAX_VEHICLES char ],
|
||||||
g_WorldClockSeconds = 0,
|
|
||||||
g_WorldDayCount = 0,
|
|
||||||
g_WorldWeather = 10,
|
|
||||||
g_PingLimit = 1024,
|
g_PingLimit = 1024,
|
||||||
g_circleall_CD = false,
|
g_circleall_CD = false,
|
||||||
log__Text [ 6 ][ 90 ],
|
log__Text [ 6 ][ 90 ],
|
||||||
|
@ -13,7 +13,6 @@ new
|
|||||||
Text: g_ObjectLoadTD = Text: INVALID_TEXT_DRAW,
|
Text: g_ObjectLoadTD = Text: INVALID_TEXT_DRAW,
|
||||||
Text: g_WebsiteTD = Text: INVALID_TEXT_DRAW,
|
Text: g_WebsiteTD = Text: INVALID_TEXT_DRAW,
|
||||||
Text: g_MotdTD = Text: INVALID_TEXT_DRAW,
|
Text: g_MotdTD = Text: INVALID_TEXT_DRAW,
|
||||||
Text: g_WorldDayTD = Text: INVALID_TEXT_DRAW,
|
|
||||||
Text: g_AchievementTD [ 4 ] = { Text: INVALID_TEXT_DRAW, ... },
|
Text: g_AchievementTD [ 4 ] = { Text: INVALID_TEXT_DRAW, ... },
|
||||||
Text: g_AdminLogTD = Text: INVALID_TEXT_DRAW,
|
Text: g_AdminLogTD = Text: INVALID_TEXT_DRAW,
|
||||||
Text: g_AdminOnDutyTD = Text: INVALID_TEXT_DRAW,
|
Text: g_AdminOnDutyTD = Text: INVALID_TEXT_DRAW,
|
||||||
@ -139,13 +138,6 @@ hook OnScriptInit( )
|
|||||||
TextDrawSetProportional(g_AchievementTD[ 3 ], 1);
|
TextDrawSetProportional(g_AchievementTD[ 3 ], 1);
|
||||||
TextDrawSetShadow(g_AchievementTD[ 3 ], 1);
|
TextDrawSetShadow(g_AchievementTD[ 3 ], 1);
|
||||||
|
|
||||||
g_WorldDayTD = TextDrawCreate(501.000000, 6.000000, "Monday");
|
|
||||||
TextDrawBackgroundColor(g_WorldDayTD, 255);
|
|
||||||
TextDrawFont(g_WorldDayTD, 3);
|
|
||||||
TextDrawLetterSize(g_WorldDayTD, 0.519998, 1.499999);
|
|
||||||
TextDrawSetOutline(g_WorldDayTD, 2);
|
|
||||||
TextDrawSetProportional(g_WorldDayTD, 1);
|
|
||||||
|
|
||||||
g_MotdTD = TextDrawCreate(320.000000, 426.000000, "_");
|
g_MotdTD = TextDrawCreate(320.000000, 426.000000, "_");
|
||||||
TextDrawAlignment(g_MotdTD, 2);
|
TextDrawAlignment(g_MotdTD, 2);
|
||||||
TextDrawBackgroundColor(g_MotdTD, 117);
|
TextDrawBackgroundColor(g_MotdTD, 117);
|
||||||
|
@ -26,6 +26,7 @@
|
|||||||
#define SERVER_TWITTER_FEED_URL "files.sfcnr.com/cnr_twitter.php" // used for /twitter (cnr\commands\cmd_twitter.pwn)
|
#define SERVER_TWITTER_FEED_URL "files.sfcnr.com/cnr_twitter.php" // used for /twitter (cnr\commands\cmd_twitter.pwn)
|
||||||
#define SERVER_HELP_API_URL "sfcnr.com/api/player/help" // used for /help (cnr\commands\cmd_help.pwn)
|
#define SERVER_HELP_API_URL "sfcnr.com/api/player/help" // used for /help (cnr\commands\cmd_help.pwn)
|
||||||
#define SERVER_CHANGES_FILE "updates.txt" // used for /changes (cnr\commands\cmd_changes.pwn)
|
#define SERVER_CHANGES_FILE "updates.txt" // used for /changes (cnr\commands\cmd_changes.pwn)
|
||||||
|
#define SERVER_PLS_DONATE_MP3 "http://files.sfcnr.com/game_sounds/pls_donate.mp3" // used for advertising vip (cnr\vip\coin_market.pwn)
|
||||||
|
|
||||||
/* ** Hooks ** */
|
/* ** Hooks ** */
|
||||||
hook OnScriptInit( )
|
hook OnScriptInit( )
|
||||||
|
@ -55,8 +55,6 @@ native gpci ( playerid, serial[ ], len );
|
|||||||
#include "irresistible\_main.pwn"
|
#include "irresistible\_main.pwn"
|
||||||
|
|
||||||
/* ** Useful macros ** */
|
/* ** Useful macros ** */
|
||||||
#define UpdatePlayerTime(%0) SetPlayerTime(%0,floatround(g_WorldClockSeconds/60),g_WorldClockSeconds-floatround((g_WorldClockSeconds/60)*60))
|
|
||||||
|
|
||||||
#define Ach_Unlock(%0,%1) (%0 >= %1 ?("{6EF83C}"):("{FFFFFF}"))
|
#define Ach_Unlock(%0,%1) (%0 >= %1 ?("{6EF83C}"):("{FFFFFF}"))
|
||||||
#define Achievement:: ach_
|
#define Achievement:: ach_
|
||||||
|
|
||||||
@ -392,25 +390,6 @@ public OnServerUpdateTimer( )
|
|||||||
|
|
||||||
public OnServerSecondTick( )
|
public OnServerSecondTick( )
|
||||||
{
|
{
|
||||||
SendRconCommand( sprintf( "worldtime %s, %s", GetDayToString( g_WorldDayCount ), TimeConvert( g_WorldClockSeconds++ ) ) );
|
|
||||||
|
|
||||||
if ( g_WorldClockSeconds >= 1440 )
|
|
||||||
{
|
|
||||||
// call a function when the server day ends
|
|
||||||
CallLocalFunction( "OnServerGameDayEnd", "" );
|
|
||||||
|
|
||||||
g_WorldWeather = randarg( 10, 11, 12 );
|
|
||||||
g_WorldClockSeconds = 0;
|
|
||||||
g_WorldDayCount = ( g_WorldDayCount == 6 ? 0 : g_WorldDayCount + 1 );
|
|
||||||
TextDrawSetString( g_WorldDayTD, GetDayToString( g_WorldDayCount ) );
|
|
||||||
|
|
||||||
foreach(new p : Player) {
|
|
||||||
if ( !p_VIPLevel[ p ] && !IsPlayerUsingRadio( p ) ) {
|
|
||||||
PlayAudioStreamForPlayer( p, "http://files.sfcnr.com/game_sounds/pls_donate.mp3" );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// call local function
|
// call local function
|
||||||
CallLocalFunction( "OnServerTickSecond", "" );
|
CallLocalFunction( "OnServerTickSecond", "" );
|
||||||
|
|
||||||
@ -420,9 +399,6 @@ public OnServerSecondTick( )
|
|||||||
if ( ! p_PlayerLogged{ playerid } )
|
if ( ! p_PlayerLogged{ playerid } )
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
SetPlayerWeather( playerid, ( GetPlayerInterior( playerid ) || GetPlayerVirtualWorld( playerid ) ) ? 1 : g_WorldWeather );
|
|
||||||
UpdatePlayerTime( playerid );
|
|
||||||
|
|
||||||
// Callback
|
// Callback
|
||||||
CallLocalFunction( "OnPlayerTickSecond", "d", playerid );
|
CallLocalFunction( "OnPlayerTickSecond", "d", playerid );
|
||||||
|
|
||||||
@ -461,7 +437,6 @@ public OnPlayerRequestClass( playerid, classid )
|
|||||||
TextDrawHideForPlayer( playerid, g_MotdTD );
|
TextDrawHideForPlayer( playerid, g_MotdTD );
|
||||||
PlayerTextDrawHide( playerid, g_ZoneOwnerTD[ playerid ] );
|
PlayerTextDrawHide( playerid, g_ZoneOwnerTD[ playerid ] );
|
||||||
TextDrawHideForPlayer( playerid, g_AdminOnDutyTD );
|
TextDrawHideForPlayer( playerid, g_AdminOnDutyTD );
|
||||||
TextDrawHideForPlayer( playerid, g_WorldDayTD );
|
|
||||||
PlayerTextDrawHide( playerid, p_LocationTD[ playerid ] );
|
PlayerTextDrawHide( playerid, p_LocationTD[ playerid ] );
|
||||||
PlayerTextDrawHide( playerid, p_PlayerRankTD[ playerid ] );
|
PlayerTextDrawHide( playerid, p_PlayerRankTD[ playerid ] );
|
||||||
PlayerTextDrawHide( playerid, p_PlayerRankTextTD[ playerid ] );
|
PlayerTextDrawHide( playerid, p_PlayerRankTextTD[ playerid ] );
|
||||||
@ -732,7 +707,6 @@ public OnPlayerSpawn( playerid )
|
|||||||
TextDrawShowForPlayer( playerid, g_WebsiteTD );
|
TextDrawShowForPlayer( playerid, g_WebsiteTD );
|
||||||
TextDrawShowForPlayer( playerid, g_MotdTD );
|
TextDrawShowForPlayer( playerid, g_MotdTD );
|
||||||
PlayerTextDrawShow( playerid, g_ZoneOwnerTD[ playerid ] );
|
PlayerTextDrawShow( playerid, g_ZoneOwnerTD[ playerid ] );
|
||||||
TextDrawShowForPlayer( playerid, g_WorldDayTD );
|
|
||||||
if ( p_AdminOnDuty{ playerid } ) TextDrawShowForPlayer( playerid, g_AdminOnDutyTD );
|
if ( p_AdminOnDuty{ playerid } ) TextDrawShowForPlayer( playerid, g_AdminOnDutyTD );
|
||||||
if ( p_AdminLog{ playerid } ) TextDrawShowForPlayer( playerid, g_AdminLogTD );
|
if ( p_AdminLog{ playerid } ) TextDrawShowForPlayer( playerid, g_AdminLogTD );
|
||||||
if ( IsDoubleXP( ) ) TextDrawShowForPlayer( playerid, g_DoubleXPTD );
|
if ( IsDoubleXP( ) ) TextDrawShowForPlayer( playerid, g_DoubleXPTD );
|
||||||
@ -1308,7 +1282,6 @@ public OnPlayerDeath( playerid, killerid, reason )
|
|||||||
TextDrawHideForPlayer( playerid, g_MotdTD );
|
TextDrawHideForPlayer( playerid, g_MotdTD );
|
||||||
PlayerTextDrawHide( playerid, g_ZoneOwnerTD[ playerid ] );
|
PlayerTextDrawHide( playerid, g_ZoneOwnerTD[ playerid ] );
|
||||||
TextDrawHideForPlayer( playerid, g_AdminOnDutyTD );
|
TextDrawHideForPlayer( playerid, g_AdminOnDutyTD );
|
||||||
TextDrawHideForPlayer( playerid, g_WorldDayTD );
|
|
||||||
TextDrawHideForPlayer( playerid, g_AdminLogTD );
|
TextDrawHideForPlayer( playerid, g_AdminLogTD );
|
||||||
TextDrawHideForPlayer( playerid, g_DoubleXPTD );
|
TextDrawHideForPlayer( playerid, g_DoubleXPTD );
|
||||||
PlayerTextDrawHide( playerid, p_PlayerRankTD[ playerid ] );
|
PlayerTextDrawHide( playerid, p_PlayerRankTD[ playerid ] );
|
||||||
@ -2811,7 +2784,6 @@ public OnPlayerLoadTextdraws( playerid )
|
|||||||
if ( p_WantedLevel[ playerid ] ) PlayerTextDrawShow( playerid, p_WantedLevelTD[ playerid ] );
|
if ( p_WantedLevel[ playerid ] ) PlayerTextDrawShow( playerid, p_WantedLevelTD[ playerid ] );
|
||||||
TextDrawShowForPlayer( playerid, g_MotdTD );
|
TextDrawShowForPlayer( playerid, g_MotdTD );
|
||||||
if ( p_AdminOnDuty{ playerid } ) TextDrawShowForPlayer( playerid, g_AdminOnDutyTD );
|
if ( p_AdminOnDuty{ playerid } ) TextDrawShowForPlayer( playerid, g_AdminOnDutyTD );
|
||||||
TextDrawShowForPlayer( playerid, g_WorldDayTD );
|
|
||||||
PlayerTextDrawShow( playerid, g_ZoneOwnerTD[ playerid ] );
|
PlayerTextDrawShow( playerid, g_ZoneOwnerTD[ playerid ] );
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -2825,7 +2797,6 @@ public OnPlayerUnloadTextdraws( playerid )
|
|||||||
TextDrawHideForPlayer( playerid, g_AdminOnDutyTD );
|
TextDrawHideForPlayer( playerid, g_AdminOnDutyTD );
|
||||||
TextDrawHideForPlayer( playerid, g_DoubleXPTD );
|
TextDrawHideForPlayer( playerid, g_DoubleXPTD );
|
||||||
TextDrawHideForPlayer( playerid, g_MotdTD );
|
TextDrawHideForPlayer( playerid, g_MotdTD );
|
||||||
TextDrawHideForPlayer( playerid, g_WorldDayTD );
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -6304,25 +6275,6 @@ stock mysql_escape( string[ ] )
|
|||||||
return szEscaped;
|
return szEscaped;
|
||||||
}
|
}
|
||||||
|
|
||||||
stock GetDayToString( day )
|
|
||||||
{
|
|
||||||
static
|
|
||||||
string[ 10 ];
|
|
||||||
|
|
||||||
switch( day )
|
|
||||||
{
|
|
||||||
case 0: string = "Monday";
|
|
||||||
case 1: string = "Tuesday";
|
|
||||||
case 2: string = "Wednesday";
|
|
||||||
case 3: string = "Thursday";
|
|
||||||
case 4: string = "Friday";
|
|
||||||
case 5: string = "Saturday";
|
|
||||||
case 6: string = "Sunday";
|
|
||||||
default: string = "Bugged";
|
|
||||||
}
|
|
||||||
return string;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
stock ShowAchievement( playerid, achievement[ ], score = -1 )
|
stock ShowAchievement( playerid, achievement[ ], score = -1 )
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user