Raised This Month: $ Target: $400
 0% 

How to catch player names from .ini file


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 08-29-2014 , 04:05   Re: How to catch player names from .ini file
Reply With Quote #1

Quote:
Originally Posted by bardukis View Post
That doesnt help me
Since this is the Suggestions/Request, you need to describe what you want the plugin to do that you are requesting.
__________________
fysiks is offline
bardukis
Member
Join Date: Jul 2014
Old 08-29-2014 , 04:46   Re: How to catch player names from .ini file
Reply With Quote #2

Quote:
Originally Posted by fysiks View Post
Since this is the Suggestions/Request, you need to describe what you want the plugin to do that you are requesting.
I just want plugin which give more HP at spawn for player names which are included in .ini file.
bardukis is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 08-29-2014 , 04:57   Re: How to catch player names from .ini file
Reply With Quote #3

Quote:
Originally Posted by bardukis View Post
I just want plugin which give more HP at spawn for player names which are included in .ini file.
That is what you should ask for in your first post (and title). However, if somebody does do it for you, it will likely be based on SteamID, FYI.
__________________
fysiks is offline
Flick3rR
Veteran Member
Join Date: Feb 2014
Location: Bulgaria, Stara Zagora
Old 08-29-2014 , 06:21   Re: How to catch player names from .ini file
Reply With Quote #4

Quote:
Originally Posted by fysiks View Post
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(idszSteamIDcharsmax(szSteamID))
    
    if(
is_user_alive(id) && TrieKeyExists(g_tExistingInIniszSteamID))
    {
        new 
iHP
        TrieGetCell
(g_tExistingInIniszSteamIDiHP)
        
set_user_health(idiHP)
        
client_print(idprint_chat"You are in .ini file and got %d special HP"iHP)
    }
}


public 
LoadSteamIDs()
{
    new 
szFilePath[128]
    
get_configsdir(szFilePathcharsmax(szFilePath))
    
add(szFilePathcharsmax(szFilePath), "/PlayersHP.ini")
    
    new 
file fopen(szFilePath"rt")
    
    if(!
file
    { 
        new 
szMessage[128]
        
formatex(szMessagecharsmax(szMessage), "Unable to open %s"szFilePath)
        
set_fail_state(szMessage)
    } 
    
    new 
szData[128]
    new 
szSteamID[32], szHP[10], iHP
    
    
while(!feof(file)) 
    { 
        
fgets(fileszDatacharsmax(szData)) 
        
        
trim(szData)
        
        if(!
szData[0] || szData[0] == ';' || szData[0] == '/' && szData[1] == '/'
            continue
        
        
parse(szDataszSteamIDcharsmax(szSteamID), szHPcharsmax(szHP))
        
iHP str_to_num(szHP)
        
        
TrieSetCell(g_tExistingInIniszSteamIDiHP)
        
    } 
    
fclose(file
}

public 
plugin_end()
    
TrieDestroy(g_tExistingInIni
Attached Files
File Type: ini PlayersHP.ini (189 Bytes, 73 views)
__________________

Last edited by Flick3rR; 08-29-2014 at 06:24.
Flick3rR is offline
Send a message via Skype™ to Flick3rR
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 21:02.


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