Code: Select all
#include <amxmodx>
#include <amxmisc>
#include <orpheu>
#include <hamsandwich>
new Trie:ReplacementsTrie
new ConfigFile[] = "steamID_replacements.ini"
public plugin_precache()
{
loadConfigFile(ReplacementsTrie=TrieCreate(),ConfigFile)
OrpheuRegisterHook(OrpheuGetFunction("SV_GetIDString"),"OnSV_GetIDString",OrpheuHookPost)
register_plugin("steamID_replacer","1.0","joaquimandrade")
}
loadConfigFile(Trie:replacementsTrie,configFile[])
{
new path[100]
get_configsdir(path,charsmax(path))
format(path,charsmax(path),"%s/%s",path,configFile)
new file = fopen(path,"r")
if(file)
{
new line[100]
new steamIDLeft[32]
new steamIDRight[32]
new lineNumber = 1
while(fgets(file,line,charsmax(line)))
{
trim(line)
if(line[0] != '#')
{
strbreak(line,steamIDLeft,charsmax(steamIDLeft),steamIDRight,charsmax(steamIDRight))
if(steamIDLeft[0] && steamIDRight[0])
{
TrieSetString(replacementsTrie,steamIDLeft,steamIDRight)
}
else
{
server_print("[steamID_replacements] Line number %d is invalid",lineNumber)
}
}
lineNumber++
}
fclose(file)
}
else
{
file = fopen(path,"w+")
if(file)
{
fprintf(file,"# Add lines with format ORIGINAL REPLACEMENT^n")
fclose(file)
set_fail_state("[steamID_replacements] Created base file")
}
else
{
set_fail_state("[steamID_replacements] Failed to create base file")
}
}
}
public OnSV_GetIDString(x)
{
static steamID[32]
OrpheuGetReturn(steamID,charsmax(steamID))
if(TrieKeyExists(ReplacementsTrie,steamID))
{
static newSteamID[32]
TrieGetString(ReplacementsTrie,steamID,newSteamID,charsmax(newSteamID))
OrpheuSetReturn(newSteamID)
}
}
Code: Select all
# Add lines with format ORIGINAL REPLACEMENT
"BOT" "VALVE_ID_PENDING"
Code: Select all
L 12/20/2015 - 11:56:02: Start of error session.
L 12/20/2015 - 11:56:02: Info (map "de_dust2") (file "addons/amxmodx/logs/error_20151220.log")
L 12/20/2015 - 11:56:02: [ORPHEU] Function "SV_GetIDString" not found
L 12/20/2015 - 11:56:02: [AMXX] Displaying debug trace (plugin "steamidreplacer.amxx")
L 12/20/2015 - 11:56:02: [AMXX] Run time error 10: native error (native "OrpheuGetFunction")
L 12/20/2015 - 11:56:02: [AMXX] [0] steamidreplacer.sma::plugin_precache (line 57)
Code: Select all
{
"name" : "SV_GetIDString",
"library" : "engine",
"arguments" :
[
{
"type" : "pointer"
}
],
"return" :
{
"type" : "char *"
},
"identifiers":
[
{
"os" : "windows",
"value" : [0x55,0x8B,"*",0x83,"*","*",0x8B,"*","*",0xC6]
},
{
"os" : "linux",
"value" : "SV_GetIDString"
}
]
}