Raised This Month: $32 Target: $400
 8% 

[HOWTO] Ingame Browser


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Tobi17
Senior Member
Join Date: May 2005
Old 05-09-2007 , 18:33   [HOWTO] Ingame Browser
Reply With Quote #1

Hello,

to display external urls for clients within the ingame browser you have to execute the following code:

Code:
public OnPluginStart() 
{
	RegServerCmd("my_browse", my_browse);
}


public Action:my_browse(args)
{
	if (args < 2) {
		PrintToServer("Usage: my_browse <userid><url> - open client ingame browser");
		return Plugin_Handled;
	}

	decl String:client_id[32];
	GetCmdArg(1, client_id, 32);

	new String:client_url[192];
	decl String:argument_string[512];
	GetCmdArgString(argument_string, 512);
	new find_pos = StrContains(argument_string, "http://", true);
	if (find_pos == -1) {
		new argument_count = GetCmdArgs();
		for(new i = 1; i < argument_count; i++) {
			decl String:temp_argument[192];
			GetCmdArg(i+1, temp_argument, 192);
			if ((192 - strlen(client_url)) > strlen(temp_argument)) {
				strcopy(client_url[strlen(client_url)], 192, temp_argument);
			}
		}
	} else {
		strcopy(client_url, 192, argument_string[find_pos]);
	}

	new client = StringToInt(client_id);
	if (client > 0) {
		new player_index = GetClientOfUserId(client);
		if ((player_index > 0) && (!IsFakeClient(player_index)) && (IsClientConnected(player_index))) {
			decl Handle:hBf;
			hBf = StartMessageOne("VGUIMenu", player_index);
			if (hBf != INVALID_HANDLE) {
				BfWriteString(hBf, "info");
				BfWriteByte(hBf,   1);
				BfWriteByte(hBf,   3);
				BfWriteString(hBf, "title");
				BfWriteString(hBf, "MyTitle");
				BfWriteString(hBf, "type");
				BfWriteString(hBf, "2");
				BfWriteString(hBf, "msg");
				BfWriteString(hBf, client_url);
				BfWriteString(hBf, "cmd");
				BfWriteString(hBf, "");
				EndMessage();
			}
		}	
	}		
			
	return Plugin_Handled;
}
This could be maybe useful for anyone.

Bye
Tobi

Last edited by Tobi17; 05-09-2007 at 18:43.
Tobi17 is offline
BAILOPAN
Join Date: Jan 2004
Old 05-09-2007 , 19:04   Re: [HOWTO] Ingame Browser
Reply With Quote #2

Just an FYI on this one: The message can't exceed 255 bytes (including ~1-3 bytes for the header). I ran into this trying to send a long URL. Unlike HL1, you can't break up the message.

EDIT: I didn't mean the above code doesn't work, just that looking for the same HL1 functionality won't work.
__________________
egg

Last edited by BAILOPAN; 05-09-2007 at 19:11.
BAILOPAN is offline
Tobi17
Senior Member
Join Date: May 2005
Old 05-09-2007 , 19:07   Re: [HOWTO] Ingame Browser
Reply With Quote #3

Hello,

the client url is limited to 192 characters. The code above should work without any problems.

Bye
Tobi
Tobi17 is offline
API
Veteran Member
Join Date: May 2006
Old 05-10-2007 , 09:57   Re: [HOWTO] Ingame Browser
Reply With Quote #4

I didn't realize a MOTD window could already be made... nice.
API is offline
Send a message via AIM to API
Reply


Thread Tools
Display Modes

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 15:03.


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