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)", hndl, err);
}
char data[256];
bf_write buffer(data, sizeof(data));
buffer.WriteUBitLong(NET_SETCONVAR, NETMSG_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;
}