Raised This Month: $ Target: $400
 0% 

Add {TEXT} to Web ShortCuts


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
maciasbarlinek
Senior Member
Join Date: May 2015
Old 10-31-2015 , 14:23   Add {TEXT} to Web ShortCuts
Reply With Quote #1

Hello,

I use this plugin: https://forums.alliedmods.net/showthread.php?t=244075
I want to add {TEXT} to this plugin.

I was trying and i added this:

Code:
        GetArrayString(g_Shortcuts, i, text, sizeof(text));
        if(strcmp(shortcut, text, false) == 0)
        {
            QueryClientConVar(client, "cl_disablehtmlmotd", ConVarQueryFinished:ClientConVar, client);
            decl String:title[256];
            decl String:steamId[64];
            decl String:userId[16];
            decl String:name[64];
            decl String:clientIp[32];
            decl String:textclient[32];
            GetCmdArg(1, textclient, sizeof(textclient));
            GetArrayString(g_Titles, i, title, sizeof(title));
            GetArrayString(g_Links, i, text, sizeof(text));
            GetClientAuthId(client, AuthId_Steam2, steamId, sizeof(steamId));
            FormatEx(userId, sizeof(userId), "%u", GetClientUserId(client));
            GetClientName(client, name, sizeof(name));
            GetClientIP(client, clientIp, sizeof(clientIp));
            ReplaceString(text, sizeof(text), "{SERVER_IP}", g_ServerIp);
            ReplaceString(text, sizeof(text), "{SERVER_PORT}", g_ServerPort);
            ReplaceString(text, sizeof(text), "{STEAM_ID}", steamId);
            ReplaceString(text, sizeof(text), "{USER_ID}", userId);
            ReplaceString(text, sizeof(text), "{NAME}", name);
            ReplaceString(text, sizeof(text), "{IP}", clientIp);
            ReplaceString(text, sizeof(text), "{TEXT}", textclient);
            if(StrEqual(title, "none", false))
            {
                StreamPanel("Webshortcuts", text, client);
            }
            else if(StrEqual(title, "full", false))
            {
                FixMotdCSGO_fullsize(text);
                ShowMOTDPanel(client, "Script by Franc1sco franug", text, MOTDPANEL_TYPE_URL);
            }
            else
            {
                FixMotdCSGO(text, title);
                ShowMOTDPanel(client, "Script by Franc1sco franug", text, MOTDPANEL_TYPE_URL);
            }
        }
My config/webshortcuts.txt have:
"!google" "full" https://www.google.pl/search?q={TEXT}

And if i use code made by me:
After typed in server command: !google allied

URL changed from https://www.google.pl/search?q={TEXT} to https://www.google.pl/search?q=!google allied

Here, {TEXT} should be replaced by allied (not !google allied - without !google).
Where is mistake in my code?
Thanks a lot.
__________________
cam0 & lingzhidiyu - The best users

Last edited by maciasbarlinek; 11-01-2015 at 05:41. Reason: https://forums.alliedmods.net/showpost.php?p=2358741&postcount=3
maciasbarlinek is offline
Miu
Veteran Member
Join Date: Nov 2013
Old 10-31-2015 , 18:19   Re: Add {TEXT} to Web ShortCuts
Reply With Quote #2

waaaat
Miu is offline
maciasbarlinek
Senior Member
Join Date: May 2015
Old 11-01-2015 , 05:39   Re: Add {TEXT} to Web ShortCuts
Reply With Quote #3

[EDITED 1st post]

Ok, it's probably incomprehensible
I want to explain it better:

My config/webshortcuts.txt have:
"!google" "full" https://www.google.pl/search?q={TEXT}

And if i use code made by me:
After typed in server command: !google allied

URL changed from https://www.google.pl/search?q={TEXT} to https://www.google.pl/search?q=!google allied

Here, {TEXT} should be replaced by allied (not !google allied - without !google).
Where is mistake in my code?
__________________
cam0 & lingzhidiyu - The best users

Last edited by maciasbarlinek; 11-01-2015 at 05:42.
maciasbarlinek is offline
Miu
Veteran Member
Join Date: Nov 2013
Old 11-01-2015 , 07:12   Re: Add {TEXT} to Web ShortCuts
Reply With Quote #4

Oh okay, try this:

PHP Code:
public Action:OnSay(clientargs)
{
    if (!
client)return Plugin_Continue;
    
    
    
decl String:text[512];
    
GetCmdArgString(textsizeof(text));
    
    new 
start;
    new 
len strlen(text);
    if (
text[len 1] == '"')
    {
        
text[len 1] = '\0';
        
start 1;
    }
    
    
decl String:shortcut[32], String:textclient[64];
    new 
index BreakString(text[start], shortcutsizeof(shortcut));
    
BreakString(text[index], textclientsizeof(textclient));
    
    new 
size GetArraySize(g_Shortcuts);
    for (new 
i!= size; ++i)
    {
        
GetArrayString(g_Shortcutsitextsizeof(text));
        
        if (
strcmp(shortcuttextfalse) == 0)
        {
            
QueryClientConVar(client"cl_disablehtmlmotd"ConVarQueryFinished:ClientConVarclient);
            
            
decl String:title[256];
            
decl String:steamId[64];
            
decl String:userId[16];
            
decl String:name[64];
            
decl String:clientIp[32];
            
            
GetArrayString(g_Titlesititlesizeof(title));
            
GetArrayString(g_Linksitextsizeof(text));
            
            
//GetClientAuthString( client, steamId, sizeof(steamId) );
            
GetClientAuthId(clientAuthId_Steam2steamIdsizeof(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);
            
ReplaceString(textsizeof(text), "{TEXT}"textclient);
            
            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;

Miu is offline
maciasbarlinek
Senior Member
Join Date: May 2015
Old 11-01-2015 , 15:17   Re: Add {TEXT} to Web ShortCuts
Reply With Quote #5

O my god.
It works!!!

Miu, i love you <3

Regards,
maciasbarlinek
__________________
cam0 & lingzhidiyu - The best users

Last edited by maciasbarlinek; 11-02-2015 at 13:24.
maciasbarlinek is offline
maciasbarlinek
Senior Member
Join Date: May 2015
Old 11-02-2015 , 13:26   Re: Add {TEXT} to Web ShortCuts
Reply With Quote #6

But it gives a lot of errors...

Code:
L 11/02/2015 - 16:10:43: [SM] Plugin encountered error 15: Array index is out of bounds
L 11/02/2015 - 16:10:43: [SM] Displaying call stack trace for plugin "webshortcuts_csgo.smx":
L 11/02/2015 - 16:10:43: [SM]   [0]  Line 59, ...\Scripting\webshortcuts_csgo.sp::OnSay()
Line 59:
Code:
    BreakString(text[index], textclient, sizeof(textclient));
__________________
cam0 & lingzhidiyu - The best users
maciasbarlinek is offline
Miu
Veteran Member
Join Date: Nov 2013
Old 11-02-2015 , 13:37   Re: Add {TEXT} to Web ShortCuts
Reply With Quote #7

Right, my bad. See if this still gives you errors:

PHP Code:
public Action:OnSay(clientargs)
{
    if (!
client)return Plugin_Continue;
    
    
    
decl String:text[512];
    
GetCmdArgString(textsizeof(text));
    
    new 
start;
    new 
len strlen(text);
    if (
text[len 1] == '"')
    {
        
text[len 1] = '\0';
        
start 1;
    }
    
    
decl String:shortcut[32], String:textclient[64];
    new 
index BreakString(text[start], shortcutsizeof(shortcut));
    if(
index != -1)
        
BreakString(text[index], textclientsizeof(textclient));
    
    new 
size GetArraySize(g_Shortcuts);
    for (new 
i!= size; ++i)
    {
        
GetArrayString(g_Shortcutsitextsizeof(text));
        
        if (
strcmp(shortcuttextfalse) == 0)
        {
            
QueryClientConVar(client"cl_disablehtmlmotd"ConVarQueryFinished:ClientConVarclient);
            
            
decl String:title[256];
            
decl String:steamId[64];
            
decl String:userId[16];
            
decl String:name[64];
            
decl String:clientIp[32];
            
            
GetArrayString(g_Titlesititlesizeof(title));
            
GetArrayString(g_Linksitextsizeof(text));
            
            
//GetClientAuthString( client, steamId, sizeof(steamId) ); 
            
GetClientAuthId(clientAuthId_Steam2steamIdsizeof(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);
            
ReplaceString(textsizeof(text), "{TEXT}"textclient);
            
            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;

Miu is offline
maciasbarlinek
Senior Member
Join Date: May 2015
Old 11-02-2015 , 14:56   Re: Add {TEXT} to Web ShortCuts
Reply With Quote #8

Lol nice..

Now seems good (working without errors).

Thank you again.
__________________
cam0 & lingzhidiyu - The best users
maciasbarlinek 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 02:02.


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