|
Senior Member
Join Date: Apr 2015
Location: Belgium
|
06-25-2017
, 01:06
Re: WebLync 0.0.8 - A MOTD redirection service
|
#93
|
Quote:
Originally Posted by Neuro Toxin
Add a static global array to store the target client to the client issuing the command
Code:
static int s_ProfileClientTargetIndex[MAXPLAYERS+1];
In your command callback store the target index into this array like so.
Code:
s_ProfileClientTargetIndex[client] = Targ;
Register the URL Parameter with callback OnAllPluginsStarted
Code:
public void OnAllPluginsLoaded()
{
WebLync_RegisterUrlParam("{TargetSteamID64}", OnReplaceTargetSteamID64);
}
Create the callback and use your code with the static global array to get the target client index. Notice how we store the results in the buffer parameter.
Code:
public bool OnReplaceTargetSteamID64(int client, const char[] paramname, char[] buffer, int maxlength)
{
int target = s_ProfileClientTargetIndex[client];
GetClientAuthId(target, AuthId_SteamID64, buffer, maxlength);
return true;
}
Here is a full working version that I've done up based on your code.
Code:
#include <sourcemod>
#include <weblync>
#pragma newdecls required
#pragma semicolon 1
public Plugin myinfo =
{
name = "WebLync Steam Profile",
author = "Wulfy and Neuro Toxin",
description = "Opens a targets steam profile page using WebLync",
version = "0.0.1",
url = "https://forums.alliedmods.net/showthread.php?t=298458"
}
static int s_ProfileClientTargetIndex[MAXPLAYERS+1];
public void OnPluginStart()
{
RegConsoleCmd("sm_steamprofile", OnProfileCommand);
}
public void OnAllPluginsLoaded()
{
WebLync_RegisterUrlParam("{TargetSteamID64}", OnReplaceTargetSteamID64);
}
public Action OnProfileCommand(int client, int args)
{
if (args == 0)
{
PrintToChat(client, "Usage: !profile <playername>");
return Plugin_Handled;
}
char arg[128];
GetCmdArgString(arg,128);
int target = FindTarget(client,arg,true,false);
s_ProfileClientTargetIndex[client] = target;
WebLync_OpenUrl(client, "http://steamcommunity.com/profiles/{TargetSteamID64}/");
return Plugin_Handled;
}
public bool OnReplaceTargetSteamID64(int client, const char[] paramname, char[] buffer, int maxlength)
{
int target = s_ProfileClientTargetIndex[client];
if (target == 0)
return false;
GetClientAuthId(target, AuthId_SteamID64, buffer, maxlength);
s_ProfileClientTargetIndex[client] = 0;
return true;
}
|
Wow!
Thank you so much! We'll definitely consider using option #2 from your latest update
Awesome work man.
__________________
be happy
|
|
|
|