From f9c62507646a00a71e6688f48b21c44da5c894fa Mon Sep 17 00:00:00 2001 From: Lorenc Pekaj Date: Sun, 23 Dec 2018 10:24:17 +1100 Subject: [PATCH] twitter command moved to /commands folder --- .../irresistible/cnr/commands/_commands.pwn | 3 +- .../irresistible/cnr/commands/cmd_twitter.pwn | 37 +++++++++++++++++++ gamemodes/irresistible/config/server.pwn | 3 ++ gamemodes/sf-cnr.pwn | 18 --------- 4 files changed, 42 insertions(+), 19 deletions(-) create mode 100644 gamemodes/irresistible/cnr/commands/cmd_twitter.pwn diff --git a/gamemodes/irresistible/cnr/commands/_commands.pwn b/gamemodes/irresistible/cnr/commands/_commands.pwn index 123e3dc..a23ab86 100644 --- a/gamemodes/irresistible/cnr/commands/_commands.pwn +++ b/gamemodes/irresistible/cnr/commands/_commands.pwn @@ -9,4 +9,5 @@ #include "irresistible\cnr\commands\admin\_admin.pwn" /* ** Files ** */ -#include "irresistible\cnr\commands\cmd_changes.pwn" \ No newline at end of file +#include "irresistible\cnr\commands\cmd_changes.pwn" +#include "irresistible\cnr\commands\cmd_twitter.pwn" \ No newline at end of file diff --git a/gamemodes/irresistible/cnr/commands/cmd_twitter.pwn b/gamemodes/irresistible/cnr/commands/cmd_twitter.pwn new file mode 100644 index 0000000..d94114a --- /dev/null +++ b/gamemodes/irresistible/cnr/commands/cmd_twitter.pwn @@ -0,0 +1,37 @@ +/* + * Irresistible Gaming (c) 2018 + * Developed by Lorenc + * Module: cnr\commands\cmd_twitter.pwn + * Purpose: twitter feed displayer (requires php script) + */ + +/* ** Includes ** */ +#include < YSI\y_hooks > + +/* ** Error Checking ** */ +#if !defined SERVER_TWITTER_FEED_URL + #endinput +#endif + +/* ** Forwards ** */ +forward OnTwitterHTTPResponse( index, response_code, data[ ] ); + +/* ** Commands ** */ +CMD:tweets( playerid, params[ ] ) return cmd_twitter( playerid, params ); +CMD:twitter( playerid, params[ ] ) +{ + SendServerMessage( playerid, "Reading latest tweets from {00CCFF}www.twitter.com/IrresistibleDev{FFFFFF}, please wait!" ); + HTTP( playerid, HTTP_GET, SERVER_TWITTER_FEED_URL, "", "OnTwitterHTTPResponse" ); + return 1; +} + +/* ** Callbacks ** */ +public OnTwitterHTTPResponse( index, response_code, data[ ] ) +{ + if ( response_code == 200 ) { + ShowPlayerDialog( index, DIALOG_NULL, DIALOG_STYLE_MSGBOX, "{00CCFF}@" # SERVER_TWITTER ""COL_WHITE" - Twitter", data, "Okay", "" ); + } else { + ShowPlayerDialog( index, DIALOG_NULL, DIALOG_STYLE_MSGBOX, "{00CCFF}@" # SERVER_TWITTER ""COL_WHITE" - Twitter", ""COL_WHITE"An error has occurred, try again later.", "Okay", "" ); + } + return 1; +} diff --git a/gamemodes/irresistible/config/server.pwn b/gamemodes/irresistible/config/server.pwn index b8df375..8f8bf54 100644 --- a/gamemodes/irresistible/config/server.pwn +++ b/gamemodes/irresistible/config/server.pwn @@ -19,8 +19,11 @@ #define SERVER_WEBSITE "www.sfcnr.com" #define SERVER_IP "54.36.127.43:7777" +#define SERVER_TWITTER "IrresistibleDev" + /* ** Comment line to disable feature ** */ #define SERVER_RULES_URL "files.sfcnr.com/en_rules.txt" +#define SERVER_TWITTER_FEED_URL "files.sfcnr.com/cnr_twitter.php" #define SERVER_CHANGES_FILE "updates.txt" /* ** Hooks ** */ diff --git a/gamemodes/sf-cnr.pwn b/gamemodes/sf-cnr.pwn index 149b50e..37909a3 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 OnTwitterHTTPResponse( index, response_code, data[ ] ); public OnPlayerAccessEntrance( playerid, entranceid, worldid, interiorid ); main() @@ -550,15 +549,6 @@ public OnServerSecondTick( ) return 1; } -public OnTwitterHTTPResponse( index, response_code, data[ ] ) -{ - if ( response_code == 200 ) //Did the request succeed? - ShowPlayerDialog( index, DIALOG_NULL, DIALOG_STYLE_MSGBOX, "{00CCFF}@IrresistibleDev"COL_WHITE" - Twitter", data, "Okay", "" ); - else - ShowPlayerDialog( index, DIALOG_NULL, DIALOG_STYLE_MSGBOX, "{00CCFF}@IrresistibleDev"COL_WHITE" - Twitter", ""COL_WHITE"An error has occurred, try again later.", "Okay", "" ); - return 1; -} - public OnPlayerRequestClass( playerid, classid ) { p_Spawned{ playerid } = false; @@ -2977,14 +2967,6 @@ CMD:vipjob( playerid, params[ ] ) return 1; } -CMD:tweets( playerid, params[ ] ) return cmd_twitter( playerid, params ); -CMD:twitter( playerid, params[ ] ) -{ - SendServerMessage( playerid, "Reading latest tweets from {00CCFF}www.twitter.com/IrresistibleDev{FFFFFF}, please wait!" ); - HTTP( playerid, HTTP_GET, "files.sfcnr.com/cnr_twitter.php", "", "OnTwitterHTTPResponse" ); - return 1; -} - CMD:mechanic( playerid, params[ ] ) return cmd_mech( playerid, params ); CMD:mech( playerid, params[ ] ) {