Raised This Month: $ Target: $400
 0% 

Webshortcuts upgrade?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
The Killer (DK)
Member
Join Date: Mar 2008
Old 10-20-2008 , 14:29   Webshortcuts upgrade?
Reply With Quote #1

hey,

I was thinking if someone would help me with adding a function to this great plugin:
http://forums.alliedmods.net/showthr...t=58668&page=3
(post #26 by gemeni) i wanna have {NEXTMAP} added to the plugin so i get this option:

"!nextmap" "Next Map" http://www.mydomain/maps/{nextmap}/index.php

but dont know how to.. could someone tell me what i did wrong or make it for me?
this is my version i was trying to make:

Code:
 
new Handle:g_Shortcuts;
new Handle:g_Titles;
new Handle:g_Links;
new Handle:cvar2;
new String:g_ServerIp [32];
new String:g_ServerPort [16];
new String:g_nextmap [32];
public OnPluginStart()
{
 CreateConVar( "!commands_version", PLUGIN_VERSION, "", FCVAR_REPLICATED );
 
 RegConsoleCmd( "say", OnSay );
 RegConsoleCmd( "say_team", OnSay );
 
 g_Shortcuts = CreateArray( 32 );
 g_Titles = CreateArray( 64 );
 g_Links = CreateArray( 512 );
 
 new Handle:cvar = FindConVar( "hostip" );
 new hostip = GetConVarInt( cvar );
 FormatEx( g_ServerIp, sizeof(g_ServerIp), "%u.%u.%u.%u",
  (hostip >> 24) & 0x000000FF, (hostip >> 16) & 0x000000FF, (hostip >> 8) & 0x000000FF, hostip & 0x000000FF );
 
 cvar = FindConVar( "hostport" );
 GetConVarString( cvar, g_ServerPort, sizeof(g_ServerPort) );
 
 cvar2 = FindConVar( "sm_nextmap" );
GetConVarString( cvar2, g_nextmap, sizeof(g_nextmap) );
 
 LoadWebshortcuts();
}
 
public OnMapEnd()
{
 LoadWebshortcuts();
}
 
public Action:OnSay( client, args )
{
 decl String:text [512];
 GetCmdArgString( text, sizeof(text) );
 
 new start;
 new len = strlen(text);
 if ( text[len-1] == '"' )
 {
  text[len-1] = '\0';
  start = 1;
 }
 
 decl String:shortcut [32];
 BreakString( text[start], shortcut, sizeof(shortcut) );
 
 new size = GetArraySize( g_Shortcuts );
 for (new i; i != size; ++i)
 {
  GetArrayString( g_Shortcuts, i, text, sizeof(text) );
 
  if ( strcmp( shortcut, text, false ) == 0 )
  {
   decl String:title [64];
   decl String:steamId [64];
   decl String:userId [16];
   decl String:name [64];
   decl String:clientIp [32];
   decl String:time [12];
   decl String:mapName[32];
 
   GetArrayString( g_Titles, i, title, sizeof(title) );
   GetArrayString( g_Links, i, text, sizeof(text) );
 
   GetClientAuthString( client, steamId, sizeof(steamId) );
   FormatEx( userId, sizeof(userId), "%u", GetClientUserId( client ) );
   GetClientName( client, name, sizeof(name) );
   GetClientIP( client, clientIp, sizeof(clientIp) );
   FormatTime(time, sizeof(time), "%H:%M:%S");
   GetCurrentMap(mapName, sizeof(mapName));
 
   ReplaceString( title, sizeof(title), "{SERVER_IP}", g_ServerIp);
   ReplaceString( title, sizeof(title), "{SERVER_PORT}", g_ServerPort);
   ReplaceString( title, sizeof(title), "{NEXTMAP}", g_nextmap);
   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( title, sizeof(title), "{THETIME}", time);
   ReplaceString( title, sizeof(title), "{CURRENTMAP}", mapName);
 
   ReplaceString( text, sizeof(text), "{SERVER_IP}", g_ServerIp);
   ReplaceString( text, sizeof(text), "{SERVER_PORT}", g_ServerPort);
   ReplaceString( text, sizeof(text), "{NEXTMAP}", g_nextmap);
   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), "{THETIME}", time);
   ReplaceString( text, sizeof(text), "{CURRENTMAP}", mapName);
 
   ShowMOTDPanel( client, title, text, MOTDPANEL_TYPE_URL );
  }
 }
 
 return Plugin_Continue; 
}
 
LoadWebshortcuts()
{
 decl String:buffer [1024];
 BuildPath( Path_SM, buffer, sizeof(buffer), "plugins/!commands.cfg" );
 
 if ( !FileExists( buffer ) )
 {
  return;
 }
 
 new Handle:f = OpenFile( buffer, "r" );
 if ( f == INVALID_HANDLE )
 {
  LogError( "[SM] Could not open file: %s", buffer );
  return;
 }
 
 ClearArray( g_Shortcuts );
 ClearArray( g_Titles );
 ClearArray( g_Links );
 
 decl String:shortcut [32];
 decl String:title [64];
 decl String:link [512];
 while ( !IsEndOfFile( f ) && ReadFileLine( f, buffer, sizeof(buffer) ) )
 {
  TrimString( buffer );
  if ( buffer[0] == '\0' || buffer[0] == ';' || ( buffer[0] == '/' && buffer[1] == '/' ) )
  {
   continue;
  }
 
  new pos = BreakString( buffer, shortcut, sizeof(shortcut) );
  if ( pos == -1 )
  {
   continue;
  }
 
  new linkPos = BreakString( buffer[pos], title, sizeof(title) );
  if ( linkPos == -1 )
  {
   continue;
  }
 
  strcopy( link, sizeof(link), buffer[linkPos+pos] );
  TrimString( link );
 
  PushArrayString( g_Shortcuts, shortcut );
  PushArrayString( g_Titles, title );
  PushArrayString( g_Links, link );
 }
 
 CloseHandle( f );
}

hope someone wanna help me.

Thanks in advance! :-)

-:Killer:-

BTW: sorry about my english.. im danish

Last edited by The Killer (DK); 11-02-2008 at 10:31.
The Killer (DK) is offline
The Killer (DK)
Member
Join Date: Mar 2008
Old 10-22-2008 , 17:34   Re: Webshortcuts upgrade?
Reply With Quote #2

no one know how to do it or?. just dont know what im meaning? :-/

-:Killer:-
The Killer (DK) 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 20:19.


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