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

sv_downloadurl


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Russianeer
SourceMod Donor
Join Date: Feb 2011
Old 08-09-2012 , 00:07   sv_downloadurl
Reply With Quote #1

Does anyone know at what points does the server send the client the sv_downloadurl when he connects to the server? Since I want to override that value using SendConVarValue based on the client's location.

Last edited by Russianeer; 08-09-2012 at 00:13.
Russianeer is offline
MasterOfTheXP
Veteran Member
Join Date: Aug 2011
Location: Cloudbank
Old 08-09-2012 , 01:02   Re: sv_downloadurl
Reply With Quote #2

Fake sv_downloadurl to players does just that--uses SendConVarValue on that cvar, which appears to only fake it. However, perhaps you can send 'em the value before they become in-game (OnClientConnected?) but that might not work.
__________________
Plugins / My Steam / TF2 Sandbox (plugin beta testing!)
MasterOfTheXP is offline
Russianeer
SourceMod Donor
Join Date: Feb 2011
Old 08-09-2012 , 01:14   Re: sv_downloadurl
Reply With Quote #3

Code:
public OnClientPutInServer(client)
{
	if(fakeURL_enabled && !IsFakeClient(client))
	{
		SendConVarValue(client, sv_downloadurl, fakeURL);
	}
}
OnClientPutInServer is obviously quite late for what I am trying to achieve, later than the download. Hopefully if I network it on event "player_connect", it will be soon enough.

Also, I need SendConVarValue(), but since I am writing an extension, I can not use any sourcepawn functions.



Never mind, found this:

PHP Code:
static cell_t SendConVarValue(IPluginContext *pContext, const cell_t *params)
{
    
Handle_t hndl static_cast<Handle_t>(params[2]);
    
HandleError err;
    
ConVar *pConVar;

    
char *value;
    
pContext->LocalToString(params[3], &value);
    
    if ((
err=g_ConVarManager.ReadConVarHandle(hndl, &pConVar)) != HandleError_None)
    {
        return 
pContext->ThrowNativeError("Invalid convar handle %x (error %d)"hndlerr);
    }
    
    
char data[256];
    
bf_write buffer(datasizeof(data));

    
buffer.WriteUBitLong(NET_SETCONVARNETMSG_BITS);
    
buffer.WriteByte(1);
    
buffer.WriteString(pConVar->GetName());
    
buffer.WriteString(value);

    
CPlayer *pPlayer g_Players.GetPlayerByIndex(params[1]);
    
    if (!
pPlayer)
    {
        return 
pContext->ThrowNativeError("Client index %d is invalid"params[1]);
    }
    
    if (!
pPlayer->IsConnected())
    {
        return 
pContext->ThrowNativeError("Client %d is not connected"params[1]);
    }
    
    if (
pPlayer->IsFakeClient())
    {
        return 
pContext->ThrowNativeError("Client %d is fake and cannot be targeted"params[1]);
    }
    
    
INetChannel *netchan static_cast<INetChannel *>(engine->GetPlayerNetInfo(params[1]));
    if (
netchan == NULL)
    {
        return 
0;
    }
    
    
netchan->SendData(buffer);
    
    return 
1;


Last edited by Russianeer; 08-09-2012 at 01:18.
Russianeer is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 08-09-2012 , 10:43   Re: sv_downloadurl
Reply With Quote #4

I'd recommend testing sending it to the client in the OnClientConnected event, which means you need to create a class that implements IClientListener.
__________________
Not currently working on SourceMod plugin development.
Powerlord 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 11:24.


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