Raised This Month: $51 Target: $400
 12% 

[CS:GO] Web Shortcuts CS:GO version [Updated 11-May-2022]


Post New Thread Reply   
 
Thread Tools Display Modes
Rodya
Senior Member
Join Date: Mar 2017
Location: Russia
Old 04-26-2017 , 13:01   Re: [CS:GO] Web Shortcuts CS:GO version
Reply With Quote #471

Quote:
Originally Posted by Cripix View Post
In last update CS:GO 1.35.7.6:
my protocols:
Rodya is offline
SikoZ
Junior Member
Join Date: Apr 2017
Old 04-26-2017 , 22:51   Re: [CS:GO] Web Shortcuts CS:GO version
Reply With Quote #472

Not working - used latest plugin update on latest CSGO update on a working server (After the update).

once you do get it working, could you please make sure it is public for all players to use not just admin use only?

I appreciate the time you put into this .
__________________
SikoZ is offline
kiko.
AlliedModders Donor
Join Date: Dec 2015
Old 04-27-2017 , 18:10   Re: [CS:GO] Web Shortcuts CS:GO version
Reply With Quote #473

Quote:
Originally Posted by Franc1sco View Post
The previous version works well after the csgo update?

Previous version: https://github.com/Franc1sco/WebShor...e0afdf0839.zip

Not working. No reaction.
kiko. is offline
Byte
Senior Member
Join Date: Jun 2010
Location: 📦 CCSPlayer
Old 04-28-2017 , 03:35   Re: [CS:GO] Web Shortcuts CS:GO version
Reply With Quote #474

You can use the previous version here, it should work fine:
https://github.com/Franc1sco/WebShor...rtcuts_csgo.sp
__________________
STEAM: /id/invexbyte | Github: Mo Beigi | Discord: Byte#0017
Community: Invex Gaming | My Plugins: Click Me!

Byte is offline
Neuro Toxin
Veteran Member
Join Date: Oct 2013
Location: { closing the void; }
Old 04-28-2017 , 03:55   Re: [CS:GO] Web Shortcuts CS:GO version
Reply With Quote #475

The MOTD window not showing up has nothing to do with this plugin when the redirect page is working (previous versions).

Common issues.

1. The pages take to long to load
2. Javascript errors cause errors which stop the page loading
3. Flash completely breaks the MOTD window until you restart the game
__________________
Neuro Toxin is offline
Bad Cold Man
Senior Member
Join Date: Apr 2014
Old 04-28-2017 , 05:18   Re: [CS:GO] Web Shortcuts CS:GO version
Reply With Quote #476

I tried all versions I found and none of them works.
__________________
Bad Cold Man is offline
Byte
Senior Member
Join Date: Jun 2010
Location: 📦 CCSPlayer
Old 04-28-2017 , 05:22   Re: [CS:GO] Web Shortcuts CS:GO version
Reply With Quote #477

Since a few people have messaged me to ask for a working version.
Files also attached as a zip.

Then set:
Code:
sm_webshortcutscsgo_url "http://www.example.com/myscript.php"
Plugin:
PHP Code:
/*  Web Shortcuts CS:GO version
 *
 *  Copyright (C) 2017 Francisco 'Franc1sco' García
 * 
 * This program is free software: you can redistribute it and/or modify it
 * under the terms of the GNU General Public License as published by the Free
 * Software Foundation, either version 3 of the License, or (at your option) 
 * any later version.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT 
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 
 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License along with 
 * this program. If not, see http://www.gnu.org/licenses/.
 */

#include <sourcemod>

#pragma semicolon 1

#pragma newdecls required

#define PLUGIN_VERSION        "2.5"

public Plugin myinfo 
{
  
name "Web Shortcuts CS:GO version",
  
author "Franc1sco franug and James \"sslice\" Gray",
  
description "Provides chat-triggered web shortcuts",
  
version PLUGIN_VERSION,
  
url "http://steamcommunity.com/id/franug/"
};

Handle g_Shortcuts;
Handle g_Titles;
Handle g_Links;

char g_ServerIp [32];
char g_ServerPort [16];

ConVar gc_sURL;

public 
void OnPluginStart()
{
  
CreateConVar("sm_webshortcutscsgo_version"PLUGIN_VERSION""FCVAR_NOTIFY|FCVAR_REPLICATED);
  
  
gc_sURL CreateConVar("sm_webshortcutscsgo_url""http://cola-team.com/franug""URL to your webspace with webshortcuts webpart");
  
  
RegConsoleCmd("say"OnSay);
  
RegConsoleCmd("say_team"OnSay);
  
  
RegAdminCmd("sm_web"Command_WebADMFLAG_GENERIC,"Open URL for target");
  
  
  
g_Shortcuts CreateArray(32);
  
g_Titles CreateArray(64);
  
g_Links CreateArray(512);
  
  
Handle cvar FindConVar("hostip");
  
int hostip GetConVarInt(cvar);
  
FormatEx(g_ServerIpsizeof(g_ServerIp), "%u.%u.%u.%u",
    (
hostip >> 24) & 0x000000FF, (hostip >> 16) & 0x000000FF, (hostip >> 8) & 0x000000FFhostip 0x000000FF);
  
  
cvar FindConVar("hostport");
  
GetConVarString(cvarg_ServerPortsizeof(g_ServerPort));
  
  
LoadWebshortcuts();
}
 
public 
void OnMapStart()
{
  
LoadWebshortcuts();
}
 
public 
Action OnSay(int clientint args)
{
  if(!
client) return Plugin_Continue;
  
  
char text [512], shortcut[512];
  
GetCmdArgString(textsizeof(text));
  
  
StripQuotes(text);
  
TrimString(text);
  
  
int size GetArraySize(g_Shortcuts);
  for (
int i!= size; ++i)
  {
    
GetArrayString(g_Shortcutsishortcutsizeof(shortcut));
    
    if (
StrEqual(textshortcutfalse))
    {
      
QueryClientConVar(client"cl_disablehtmlmotd"view_as<ConVarQueryFinished>(ClientConVar), client);
      
      
char title [256];
      
char steamId [64];
      
char userId [16];
      
char name [64];
      
char clientIp [32];
      
      
GetArrayString(g_Titlesititlesizeof(title));
      
GetArrayString(g_Linksitextsizeof(text));
      
      
//GetClientAuthString(client, steamId, sizeof(steamId));
      
GetClientAuthId(clientAuthId_Steam2,  steamIdsizeof(steamId));
      
FormatEx(userIdsizeof(userId), "%u"GetClientUserId(client));
      
GetClientName(clientnamesizeof(name));
      
GetClientIP(clientclientIpsizeof(clientIp));
      
/*       ReplaceString(title, sizeof(title), "{SERVER_IP}", g_ServerIp);
      ReplaceString(title, sizeof(title), "{SERVER_PORT}", g_ServerPort);
      ReplaceString(title, sizeof(title), "{STEAM_ID}", steamId);
      ReplaceString(title, sizeof(title), "{USER_ID}", userId);
      ReplaceString(title, sizeof(title), "{NAME}", name);
      ReplaceString(title, sizeof(title), "{IP}", clientIp); */
      
      
ReplaceString(textsizeof(text), "{SERVER_IP}"g_ServerIp);
      
ReplaceString(textsizeof(text), "{SERVER_PORT}"g_ServerPort);
      
ReplaceString(textsizeof(text), "{STEAM_ID}"steamId);
      
ReplaceString(textsizeof(text), "{USER_ID}"userId);
      
ReplaceString(textsizeof(text), "{NAME}"name);
      
ReplaceString(textsizeof(text), "{IP}"clientIp);
      
      
      if(
StrEqual(title"none"false))
      {
        
StreamPanel("Webshortcuts"textclient);
      }
      else if(
StrEqual(title"full"false))
      {
        
FixMotdCSGO_fullsize(text);
        
ShowMOTDPanel(client"Script by Franc1sco franug"textMOTDPANEL_TYPE_URL);
      }
      else
      {
        
FixMotdCSGO(texttitle);
        
ShowMOTDPanel(client"Script by Franc1sco franug"textMOTDPANEL_TYPE_URL);
      }
    }
  }
  
  return 
Plugin_Continue;  
}
 
void LoadWebshortcuts()
{
  
char buffer [1024];
  
BuildPath(Path_SMbuffersizeof(buffer), "configs/webshortcuts.txt");
  
  if (!
FileExists(buffer))
  {
    return;
  }
  
  
Handle f OpenFile(buffer"r");
  if (
== INVALID_HANDLE)
  {
    
LogError("[SM] Could not open file: %s"buffer);
    return;
  }
  
  
ClearArray(g_Shortcuts);
  
ClearArray(g_Titles);
  
ClearArray(g_Links);
  
  
char shortcut [32];
  
char title [256];
  
char link [512];
  while (!
IsEndOfFile(f) && ReadFileLine(fbuffersizeof(buffer)))
  {
    
TrimString(buffer);
    if (
buffer[0] == '\0' || buffer[0] == ';' || (buffer[0] == '/' && buffer[1] == '/'))
    {
      continue;
    }
    
    
int pos BreakString(buffershortcutsizeof(shortcut));
    if (
pos == -1)
    {
      continue;
    }
    
    
int linkPos BreakString(buffer[pos], titlesizeof(title));
    if (
linkPos == -1)
    {
      continue;
    }
    
    
strcopy(linksizeof(link), buffer[linkPos+pos]);
    
TrimString(link);
    
    
PushArrayString(g_Shortcutsshortcut);
    
PushArrayString(g_Titlestitle);
    
PushArrayString(g_Linkslink);
  }
  
  
CloseHandle(f);
}

public 
Action Command_Web(int clientint args)
{
  if (
args 2)
  {
    
ReplyToCommand(client"[SM] Usage: sm_web <target> <url>");
    return 
Plugin_Handled;
  }
  
char pattern[96], buffer[64], url[512];
  
GetCmdArg(1patternsizeof(pattern));
  
GetCmdArg(2urlsizeof(url));
  
int targets[129];
  
bool ml false;

  
int count ProcessTargetString(patternclienttargetssizeof(targets), 0buffersizeof(buffer), ml);

  if(
StrContains(url"http://"false) != 0Format(urlsizeof(url), "http://%s"url);
  
FixMotdCSGO(url,"height=720,width=1280");
  
  if (
count <= 0ReplyToCommand(client"Bad target");
  else for (
int i 0counti++)
  {
    
ShowMOTDPanel(targets[i], "Web Shortcuts"urlMOTDPANEL_TYPE_URL);
  }
  return 
Plugin_Handled;
}

public 
void StreamPanel(char [] titlechar [] urlint client)
{
  
Handle Radio CreateKeyValues("data");
  
KvSetString(Radio"title"title);
  
KvSetString(Radio"type""2");
  
KvSetString(Radio"msg"url);
  
ShowVGUIPanel(client"info"Radiofalse);
  
CloseHandle(Radio);
}

stock void FixMotdCSGO(char [] webchar [] title)
{
  
char url[64];
  
gc_sURL.GetString(urlsizeof(url));
  
Format(web512"%s?web=%s&%s"urlwebtitle);
}

stock void FixMotdCSGO_fullsize(char [] web)
{
  
char url[64];
  
gc_sURL.GetString(urlsizeof(url));
  
Format(web512"%s?web=%s&fullsize=1"urlweb);
}

public 
void ClientConVar(QueryCookie cookieint clientConVarQueryResult resultchar [] cvarNamechar [] cvarValue)
{
  if (
StringToInt(cvarValue) > 0)
  {
    
PrintToChat(client"---------------------------------------------------------------");
    
PrintToChat(client"You have cl_disablehtmlmotd to 1 and for that reason webshortcuts plugin dont work for you");
    
PrintToChat(client"Please, put this in your console: cl_disablehtmlmotd 0");
    
PrintToChat(client"---------------------------------------------------------------");
  }

PHP Website Script:
PHP Code:
<html>
    <head>
        <title>CSGO Webshortcuts</title>
    </head>
    <body>
        <script type="text/javascript" >
            var str = "<?php echo htmlspecialchars($_GET["web"]); ?>";
            var full = "<?php echo htmlspecialchars($_GET["fullsize"]); ?>";
            var height = "<?php echo htmlspecialchars($_GET["height"]); ?>"; 
            var width = "<?php echo htmlspecialchars($_GET["width"]); ?>"; 
            
            if (full == 1) {
                window.open(str, "_blank", "toolbar=yes, fullscreen=yes, scrollbars=yes, width=" + screen.width + ", height=" + (screen.height - 72));
            }
            else {
                //Set the default width and height for if it's not defined
                if (height === undefined || height === null || height == "")
                {
                    height = 720;
                }
                if (width === undefined || width === null || width == "")
                {
                    width = 960;
                }
                window.open(str, "_blank", "toolbar=yes, scrollbars=yes, resizable=yes, fullscreen=no, width=" + width + ", height=" + height);
            }
        </script>
    </body>
</html>
Attached Files
File Type: zip webshortcuts.zip (9.0 KB, 152 views)
__________________
STEAM: /id/invexbyte | Github: Mo Beigi | Discord: Byte#0017
Community: Invex Gaming | My Plugins: Click Me!


Last edited by Byte; 04-28-2017 at 05:24.
Byte is offline
kiko.
AlliedModders Donor
Join Date: Dec 2015
Old 04-28-2017 , 05:37   Re: [CS:GO] Web Shortcuts CS:GO version
Reply With Quote #478

Thank you Byte!

Its working with your attached files!

-kiko
kiko. is offline
Rodya
Senior Member
Join Date: Mar 2017
Location: Russia
Old 04-28-2017 , 06:47   Re: [CS:GO] Web Shortcuts CS:GO version
Reply With Quote #479

Quote:
Originally Posted by Byte View Post
Since a few people have messaged me to ask for a working version.
Files also attached as a zip.

Then set:
Code:
sm_webshortcutscsgo_url "http://www.example.com/myscript.php"
Plugin:
PHP Code:
/*  Web Shortcuts CS:GO version
 *
 *  Copyright (C) 2017 Francisco 'Franc1sco' García
 * 
 * This program is free software: you can redistribute it and/or modify it
 * under the terms of the GNU General Public License as published by the Free
 * Software Foundation, either version 3 of the License, or (at your option) 
 * any later version.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT 
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 
 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License along with 
 * this program. If not, see http://www.gnu.org/licenses/.
 */

#include <sourcemod>

#pragma semicolon 1

#pragma newdecls required

#define PLUGIN_VERSION        "2.5"

public Plugin myinfo 
{
  
name "Web Shortcuts CS:GO version",
  
author "Franc1sco franug and James \"sslice\" Gray",
  
description "Provides chat-triggered web shortcuts",
  
version PLUGIN_VERSION,
  
url "http://steamcommunity.com/id/franug/"
};

Handle g_Shortcuts;
Handle g_Titles;
Handle g_Links;

char g_ServerIp [32];
char g_ServerPort [16];

ConVar gc_sURL;

public 
void OnPluginStart()
{
  
CreateConVar("sm_webshortcutscsgo_version"PLUGIN_VERSION""FCVAR_NOTIFY|FCVAR_REPLICATED);
  
  
gc_sURL CreateConVar("sm_webshortcutscsgo_url""http://cola-team.com/franug""URL to your webspace with webshortcuts webpart");
  
  
RegConsoleCmd("say"OnSay);
  
RegConsoleCmd("say_team"OnSay);
  
  
RegAdminCmd("sm_web"Command_WebADMFLAG_GENERIC,"Open URL for target");
  
  
  
g_Shortcuts CreateArray(32);
  
g_Titles CreateArray(64);
  
g_Links CreateArray(512);
  
  
Handle cvar FindConVar("hostip");
  
int hostip GetConVarInt(cvar);
  
FormatEx(g_ServerIpsizeof(g_ServerIp), "%u.%u.%u.%u",
    (
hostip >> 24) & 0x000000FF, (hostip >> 16) & 0x000000FF, (hostip >> 8) & 0x000000FFhostip 0x000000FF);
  
  
cvar FindConVar("hostport");
  
GetConVarString(cvarg_ServerPortsizeof(g_ServerPort));
  
  
LoadWebshortcuts();
}
 
public 
void OnMapStart()
{
  
LoadWebshortcuts();
}
 
public 
Action OnSay(int clientint args)
{
  if(!
client) return Plugin_Continue;
  
  
char text [512], shortcut[512];
  
GetCmdArgString(textsizeof(text));
  
  
StripQuotes(text);
  
TrimString(text);
  
  
int size GetArraySize(g_Shortcuts);
  for (
int i!= size; ++i)
  {
    
GetArrayString(g_Shortcutsishortcutsizeof(shortcut));
    
    if (
StrEqual(textshortcutfalse))
    {
      
QueryClientConVar(client"cl_disablehtmlmotd"view_as<ConVarQueryFinished>(ClientConVar), client);
      
      
char title [256];
      
char steamId [64];
      
char userId [16];
      
char name [64];
      
char clientIp [32];
      
      
GetArrayString(g_Titlesititlesizeof(title));
      
GetArrayString(g_Linksitextsizeof(text));
      
      
//GetClientAuthString(client, steamId, sizeof(steamId));
      
GetClientAuthId(clientAuthId_Steam2,  steamIdsizeof(steamId));
      
FormatEx(userIdsizeof(userId), "%u"GetClientUserId(client));
      
GetClientName(clientnamesizeof(name));
      
GetClientIP(clientclientIpsizeof(clientIp));
      
/*       ReplaceString(title, sizeof(title), "{SERVER_IP}", g_ServerIp);
      ReplaceString(title, sizeof(title), "{SERVER_PORT}", g_ServerPort);
      ReplaceString(title, sizeof(title), "{STEAM_ID}", steamId);
      ReplaceString(title, sizeof(title), "{USER_ID}", userId);
      ReplaceString(title, sizeof(title), "{NAME}", name);
      ReplaceString(title, sizeof(title), "{IP}", clientIp); */
      
      
ReplaceString(textsizeof(text), "{SERVER_IP}"g_ServerIp);
      
ReplaceString(textsizeof(text), "{SERVER_PORT}"g_ServerPort);
      
ReplaceString(textsizeof(text), "{STEAM_ID}"steamId);
      
ReplaceString(textsizeof(text), "{USER_ID}"userId);
      
ReplaceString(textsizeof(text), "{NAME}"name);
      
ReplaceString(textsizeof(text), "{IP}"clientIp);
      
      
      if(
StrEqual(title"none"false))
      {
        
StreamPanel("Webshortcuts"textclient);
      }
      else if(
StrEqual(title"full"false))
      {
        
FixMotdCSGO_fullsize(text);
        
ShowMOTDPanel(client"Script by Franc1sco franug"textMOTDPANEL_TYPE_URL);
      }
      else
      {
        
FixMotdCSGO(texttitle);
        
ShowMOTDPanel(client"Script by Franc1sco franug"textMOTDPANEL_TYPE_URL);
      }
    }
  }
  
  return 
Plugin_Continue;  
}
 
void LoadWebshortcuts()
{
  
char buffer [1024];
  
BuildPath(Path_SMbuffersizeof(buffer), "configs/webshortcuts.txt");
  
  if (!
FileExists(buffer))
  {
    return;
  }
  
  
Handle f OpenFile(buffer"r");
  if (
== INVALID_HANDLE)
  {
    
LogError("[SM] Could not open file: %s"buffer);
    return;
  }
  
  
ClearArray(g_Shortcuts);
  
ClearArray(g_Titles);
  
ClearArray(g_Links);
  
  
char shortcut [32];
  
char title [256];
  
char link [512];
  while (!
IsEndOfFile(f) && ReadFileLine(fbuffersizeof(buffer)))
  {
    
TrimString(buffer);
    if (
buffer[0] == '\0' || buffer[0] == ';' || (buffer[0] == '/' && buffer[1] == '/'))
    {
      continue;
    }
    
    
int pos BreakString(buffershortcutsizeof(shortcut));
    if (
pos == -1)
    {
      continue;
    }
    
    
int linkPos BreakString(buffer[pos], titlesizeof(title));
    if (
linkPos == -1)
    {
      continue;
    }
    
    
strcopy(linksizeof(link), buffer[linkPos+pos]);
    
TrimString(link);
    
    
PushArrayString(g_Shortcutsshortcut);
    
PushArrayString(g_Titlestitle);
    
PushArrayString(g_Linkslink);
  }
  
  
CloseHandle(f);
}

public 
Action Command_Web(int clientint args)
{
  if (
args 2)
  {
    
ReplyToCommand(client"[SM] Usage: sm_web <target> <url>");
    return 
Plugin_Handled;
  }
  
char pattern[96], buffer[64], url[512];
  
GetCmdArg(1patternsizeof(pattern));
  
GetCmdArg(2urlsizeof(url));
  
int targets[129];
  
bool ml false;

  
int count ProcessTargetString(patternclienttargetssizeof(targets), 0buffersizeof(buffer), ml);

  if(
StrContains(url"http://"false) != 0Format(urlsizeof(url), "http://%s"url);
  
FixMotdCSGO(url,"height=720,width=1280");
  
  if (
count <= 0ReplyToCommand(client"Bad target");
  else for (
int i 0counti++)
  {
    
ShowMOTDPanel(targets[i], "Web Shortcuts"urlMOTDPANEL_TYPE_URL);
  }
  return 
Plugin_Handled;
}

public 
void StreamPanel(char [] titlechar [] urlint client)
{
  
Handle Radio CreateKeyValues("data");
  
KvSetString(Radio"title"title);
  
KvSetString(Radio"type""2");
  
KvSetString(Radio"msg"url);
  
ShowVGUIPanel(client"info"Radiofalse);
  
CloseHandle(Radio);
}

stock void FixMotdCSGO(char [] webchar [] title)
{
  
char url[64];
  
gc_sURL.GetString(urlsizeof(url));
  
Format(web512"%s?web=%s&%s"urlwebtitle);
}

stock void FixMotdCSGO_fullsize(char [] web)
{
  
char url[64];
  
gc_sURL.GetString(urlsizeof(url));
  
Format(web512"%s?web=%s&fullsize=1"urlweb);
}

public 
void ClientConVar(QueryCookie cookieint clientConVarQueryResult resultchar [] cvarNamechar [] cvarValue)
{
  if (
StringToInt(cvarValue) > 0)
  {
    
PrintToChat(client"---------------------------------------------------------------");
    
PrintToChat(client"You have cl_disablehtmlmotd to 1 and for that reason webshortcuts plugin dont work for you");
    
PrintToChat(client"Please, put this in your console: cl_disablehtmlmotd 0");
    
PrintToChat(client"---------------------------------------------------------------");
  }

PHP Website Script:
PHP Code:
<html>
    <head>
        <title>CSGO Webshortcuts</title>
    </head>
    <body>
        <script type="text/javascript" >
            var str = "<?php echo htmlspecialchars($_GET["web"]); ?>";
            var full = "<?php echo htmlspecialchars($_GET["fullsize"]); ?>";
            var height = "<?php echo htmlspecialchars($_GET["height"]); ?>"; 
            var width = "<?php echo htmlspecialchars($_GET["width"]); ?>"; 
            
            if (full == 1) {
                window.open(str, "_blank", "toolbar=yes, fullscreen=yes, scrollbars=yes, width=" + screen.width + ", height=" + (screen.height - 72));
            }
            else {
                //Set the default width and height for if it's not defined
                if (height === undefined || height === null || height == "")
                {
                    height = 720;
                }
                if (width === undefined || width === null || width == "")
                {
                    width = 960;
                }
                window.open(str, "_blank", "toolbar=yes, scrollbars=yes, resizable=yes, fullscreen=no, width=" + width + ", height=" + height);
            }
        </script>
    </body>
</html>
THANKS!!!
Rodya is offline
szogun
Senior Member
Join Date: Apr 2016
Old 04-28-2017 , 07:22   Re: [CS:GO] Web Shortcuts CS:GO version
Reply With Quote #480

Quote:
Originally Posted by Byte View Post
Since a few people have messaged me to ask for a working version.
Files also attached as a zip.

Then set:
Code:
sm_webshortcutscsgo_url "http://www.example.com/myscript.php"
Plugin:
PHP Code:
/*  Web Shortcuts CS:GO version
 *
 *  Copyright (C) 2017 Francisco 'Franc1sco' García
 * 
 * This program is free software: you can redistribute it and/or modify it
 * under the terms of the GNU General Public License as published by the Free
 * Software Foundation, either version 3 of the License, or (at your option) 
 * any later version.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT 
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 
 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License along with 
 * this program. If not, see http://www.gnu.org/licenses/.
 */

#include <sourcemod>

#pragma semicolon 1

#pragma newdecls required

#define PLUGIN_VERSION        "2.5"

public Plugin myinfo 
{
  
name "Web Shortcuts CS:GO version",
  
author "Franc1sco franug and James \"sslice\" Gray",
  
description "Provides chat-triggered web shortcuts",
  
version PLUGIN_VERSION,
  
url "http://steamcommunity.com/id/franug/"
};

Handle g_Shortcuts;
Handle g_Titles;
Handle g_Links;

char g_ServerIp [32];
char g_ServerPort [16];

ConVar gc_sURL;

public 
void OnPluginStart()
{
  
CreateConVar("sm_webshortcutscsgo_version"PLUGIN_VERSION""FCVAR_NOTIFY|FCVAR_REPLICATED);
  
  
gc_sURL CreateConVar("sm_webshortcutscsgo_url""http://cola-team.com/franug""URL to your webspace with webshortcuts webpart");
  
  
RegConsoleCmd("say"OnSay);
  
RegConsoleCmd("say_team"OnSay);
  
  
RegAdminCmd("sm_web"Command_WebADMFLAG_GENERIC,"Open URL for target");
  
  
  
g_Shortcuts CreateArray(32);
  
g_Titles CreateArray(64);
  
g_Links CreateArray(512);
  
  
Handle cvar FindConVar("hostip");
  
int hostip GetConVarInt(cvar);
  
FormatEx(g_ServerIpsizeof(g_ServerIp), "%u.%u.%u.%u",
    (
hostip >> 24) & 0x000000FF, (hostip >> 16) & 0x000000FF, (hostip >> 8) & 0x000000FFhostip 0x000000FF);
  
  
cvar FindConVar("hostport");
  
GetConVarString(cvarg_ServerPortsizeof(g_ServerPort));
  
  
LoadWebshortcuts();
}
 
public 
void OnMapStart()
{
  
LoadWebshortcuts();
}
 
public 
Action OnSay(int clientint args)
{
  if(!
client) return Plugin_Continue;
  
  
char text [512], shortcut[512];
  
GetCmdArgString(textsizeof(text));
  
  
StripQuotes(text);
  
TrimString(text);
  
  
int size GetArraySize(g_Shortcuts);
  for (
int i!= size; ++i)
  {
    
GetArrayString(g_Shortcutsishortcutsizeof(shortcut));
    
    if (
StrEqual(textshortcutfalse))
    {
      
QueryClientConVar(client"cl_disablehtmlmotd"view_as<ConVarQueryFinished>(ClientConVar), client);
      
      
char title [256];
      
char steamId [64];
      
char userId [16];
      
char name [64];
      
char clientIp [32];
      
      
GetArrayString(g_Titlesititlesizeof(title));
      
GetArrayString(g_Linksitextsizeof(text));
      
      
//GetClientAuthString(client, steamId, sizeof(steamId));
      
GetClientAuthId(clientAuthId_Steam2,  steamIdsizeof(steamId));
      
FormatEx(userIdsizeof(userId), "%u"GetClientUserId(client));
      
GetClientName(clientnamesizeof(name));
      
GetClientIP(clientclientIpsizeof(clientIp));
      
/*       ReplaceString(title, sizeof(title), "{SERVER_IP}", g_ServerIp);
      ReplaceString(title, sizeof(title), "{SERVER_PORT}", g_ServerPort);
      ReplaceString(title, sizeof(title), "{STEAM_ID}", steamId);
      ReplaceString(title, sizeof(title), "{USER_ID}", userId);
      ReplaceString(title, sizeof(title), "{NAME}", name);
      ReplaceString(title, sizeof(title), "{IP}", clientIp); */
      
      
ReplaceString(textsizeof(text), "{SERVER_IP}"g_ServerIp);
      
ReplaceString(textsizeof(text), "{SERVER_PORT}"g_ServerPort);
      
ReplaceString(textsizeof(text), "{STEAM_ID}"steamId);
      
ReplaceString(textsizeof(text), "{USER_ID}"userId);
      
ReplaceString(textsizeof(text), "{NAME}"name);
      
ReplaceString(textsizeof(text), "{IP}"clientIp);
      
      
      if(
StrEqual(title"none"false))
      {
        
StreamPanel("Webshortcuts"textclient);
      }
      else if(
StrEqual(title"full"false))
      {
        
FixMotdCSGO_fullsize(text);
        
ShowMOTDPanel(client"Script by Franc1sco franug"textMOTDPANEL_TYPE_URL);
      }
      else
      {
        
FixMotdCSGO(texttitle);
        
ShowMOTDPanel(client"Script by Franc1sco franug"textMOTDPANEL_TYPE_URL);
      }
    }
  }
  
  return 
Plugin_Continue;  
}
 
void LoadWebshortcuts()
{
  
char buffer [1024];
  
BuildPath(Path_SMbuffersizeof(buffer), "configs/webshortcuts.txt");
  
  if (!
FileExists(buffer))
  {
    return;
  }
  
  
Handle f OpenFile(buffer"r");
  if (
== INVALID_HANDLE)
  {
    
LogError("[SM] Could not open file: %s"buffer);
    return;
  }
  
  
ClearArray(g_Shortcuts);
  
ClearArray(g_Titles);
  
ClearArray(g_Links);
  
  
char shortcut [32];
  
char title [256];
  
char link [512];
  while (!
IsEndOfFile(f) && ReadFileLine(fbuffersizeof(buffer)))
  {
    
TrimString(buffer);
    if (
buffer[0] == '\0' || buffer[0] == ';' || (buffer[0] == '/' && buffer[1] == '/'))
    {
      continue;
    }
    
    
int pos BreakString(buffershortcutsizeof(shortcut));
    if (
pos == -1)
    {
      continue;
    }
    
    
int linkPos BreakString(buffer[pos], titlesizeof(title));
    if (
linkPos == -1)
    {
      continue;
    }
    
    
strcopy(linksizeof(link), buffer[linkPos+pos]);
    
TrimString(link);
    
    
PushArrayString(g_Shortcutsshortcut);
    
PushArrayString(g_Titlestitle);
    
PushArrayString(g_Linkslink);
  }
  
  
CloseHandle(f);
}

public 
Action Command_Web(int clientint args)
{
  if (
args 2)
  {
    
ReplyToCommand(client"[SM] Usage: sm_web <target> <url>");
    return 
Plugin_Handled;
  }
  
char pattern[96], buffer[64], url[512];
  
GetCmdArg(1patternsizeof(pattern));
  
GetCmdArg(2urlsizeof(url));
  
int targets[129];
  
bool ml false;

  
int count ProcessTargetString(patternclienttargetssizeof(targets), 0buffersizeof(buffer), ml);

  if(
StrContains(url"http://"false) != 0Format(urlsizeof(url), "http://%s"url);
  
FixMotdCSGO(url,"height=720,width=1280");
  
  if (
count <= 0ReplyToCommand(client"Bad target");
  else for (
int i 0counti++)
  {
    
ShowMOTDPanel(targets[i], "Web Shortcuts"urlMOTDPANEL_TYPE_URL);
  }
  return 
Plugin_Handled;
}

public 
void StreamPanel(char [] titlechar [] urlint client)
{
  
Handle Radio CreateKeyValues("data");
  
KvSetString(Radio"title"title);
  
KvSetString(Radio"type""2");
  
KvSetString(Radio"msg"url);
  
ShowVGUIPanel(client"info"Radiofalse);
  
CloseHandle(Radio);
}

stock void FixMotdCSGO(char [] webchar [] title)
{
  
char url[64];
  
gc_sURL.GetString(urlsizeof(url));
  
Format(web512"%s?web=%s&%s"urlwebtitle);
}

stock void FixMotdCSGO_fullsize(char [] web)
{
  
char url[64];
  
gc_sURL.GetString(urlsizeof(url));
  
Format(web512"%s?web=%s&fullsize=1"urlweb);
}

public 
void ClientConVar(QueryCookie cookieint clientConVarQueryResult resultchar [] cvarNamechar [] cvarValue)
{
  if (
StringToInt(cvarValue) > 0)
  {
    
PrintToChat(client"---------------------------------------------------------------");
    
PrintToChat(client"You have cl_disablehtmlmotd to 1 and for that reason webshortcuts plugin dont work for you");
    
PrintToChat(client"Please, put this in your console: cl_disablehtmlmotd 0");
    
PrintToChat(client"---------------------------------------------------------------");
  }

PHP Website Script:
PHP Code:
<html>
    <head>
        <title>CSGO Webshortcuts</title>
    </head>
    <body>
        <script type="text/javascript" >
            var str = "<?php echo htmlspecialchars($_GET["web"]); ?>";
            var full = "<?php echo htmlspecialchars($_GET["fullsize"]); ?>";
            var height = "<?php echo htmlspecialchars($_GET["height"]); ?>"; 
            var width = "<?php echo htmlspecialchars($_GET["width"]); ?>"; 
            
            if (full == 1) {
                window.open(str, "_blank", "toolbar=yes, fullscreen=yes, scrollbars=yes, width=" + screen.width + ", height=" + (screen.height - 72));
            }
            else {
                //Set the default width and height for if it's not defined
                if (height === undefined || height === null || height == "")
                {
                    height = 720;
                }
                if (width === undefined || width === null || width == "")
                {
                    width = 960;
                }
                window.open(str, "_blank", "toolbar=yes, scrollbars=yes, resizable=yes, fullscreen=no, width=" + width + ", height=" + height);
            }
        </script>
    </body>
</html>
I do not want to work with me

Quote:
// tags: {NAME} {STEAM_ID} {USER_ID} {IP} {SERVER_IP} {SERVER_PORT}
//
// Use "full" instead of the windows size for adjust the windows size to the client resolution
//

"!steam" "height=480,width=1024" http://steamcommunity.com/groups/project-games
"/steam" "height=480,width=1024" http://steamcommunity.com/groups/project-games

Last edited by szogun; 04-28-2017 at 07:24.
szogun is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 03:07.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode