Quote:
Originally Posted by fysiks
it will likely be based on SteamID, FYI.
|
That's right ^^
Here it is. The PLayersHP.ini file must be in your configs folder. I will make example line for you. The structure must be the following:
"SteamID" "Amount of HP for it"
on each new line of the file.
PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <hamsandwich>
#include <fun>
new Trie:g_tExistingInIni
public plugin_init()
{
register_plugin("HP from .ini", "1.0", "Flicker")
RegisterHam(Ham_Spawn, "player", "onPlayerSpawn", true)
g_tExistingInIni = TrieCreate()
LoadSteamIDs()
}
public onPlayerSpawn(id)
{
new szSteamID[32]
get_user_authid(id, szSteamID, charsmax(szSteamID))
if(is_user_alive(id) && TrieKeyExists(g_tExistingInIni, szSteamID))
{
new iHP
TrieGetCell(g_tExistingInIni, szSteamID, iHP)
set_user_health(id, iHP)
client_print(id, print_chat, "You are in .ini file and got %d special HP", iHP)
}
}
public LoadSteamIDs()
{
new szFilePath[128]
get_configsdir(szFilePath, charsmax(szFilePath))
add(szFilePath, charsmax(szFilePath), "/PlayersHP.ini")
new file = fopen(szFilePath, "rt")
if(!file)
{
new szMessage[128]
formatex(szMessage, charsmax(szMessage), "Unable to open %s", szFilePath)
set_fail_state(szMessage)
}
new szData[128]
new szSteamID[32], szHP[10], iHP
while(!feof(file))
{
fgets(file, szData, charsmax(szData))
trim(szData)
if(!szData[0] || szData[0] == ';' || szData[0] == '/' && szData[1] == '/')
continue
parse(szData, szSteamID, charsmax(szSteamID), szHP, charsmax(szHP))
iHP = str_to_num(szHP)
TrieSetCell(g_tExistingInIni, szSteamID, iHP)
}
fclose(file)
}
public plugin_end()
TrieDestroy(g_tExistingInIni)