AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Pinfo change rounds with steamid (https://forums.alliedmods.net/showthread.php?t=94961)

HLM 06-17-2009 17:51

Pinfo change rounds with steamid
 
I am trying to make Pinfo more of an admin query tool so my admins can get a little more info from a user (without having to go into console, then go to hlsw, etcetera)

I basically want to change the rounds section with the players steamID I dont know where or how to begin on doing this..

can I get some help??

(original)
PHP Code:

/*
 *  Comments: 
 *        Displays player information. For Example...
 *        First Nick is the very first nick they had when their profile was created.
 *        Time Played is total time person has played on your server. Not just their current session.
 *        [ FIRST NICK: OneEyed ][ CONNECTS: 152 ][ ROUNDS: 25 ][ TIME PLAYED: 2 Days 3 Hrs 52 Mins ]
 *
 *    Note:
 *        Plugin is self-sufficient, just compile and add to plugins.ini / plugin folder and your set.
 *        All player data will be saved into pinfo.vault @ amxmodx/data/vault folder.
 *
 *    Chat Command:
 *        !info name        - Typed in chat.  If no name specified, returns your own info.
 *        
 *  Version :     2.0
 *    Requires:    AMXX 1.70+ and NVAULT module
 *    Gametype:     CS/NS/DOD
 *
 *    Author:        OneEyed
 *    Date:        01-23-2006
 *    Email:        [email protected]
 *    IRC:        #modns (gamesurge.net) 
 *
 *     Tested :
 *        WIN32 Tested and Approved! LINUX untested.
 * 
 *  Credits: 
 *       voogru - He used it on his server (I sorta replicated it)
 * 
 *    Change Log:
 *        v2.0 - Updated plugin to use nVault instead of *.ini file.
 *        v1.1 - Fixed to update played time at round end/map change, no more looped task.
 * 
 */

//---------------------------------------------------------------------------------------------
//-------------------DO NOT EDIT BELOW---------------------------------------------------------
#include <amxmodx>
#include <amxmisc>
#include <nvault>

new Float:g_onlinetime[33]
new 
maxplayers

new Vault
static const VAULTNAME[] = "pinfo"

static const TITLE[] = "PInfo"
static const VERSION[] = "2.0"
static const AUTHOR[] = "OneEyed"
//---------------------------------------------------------------------------------------------------
public plugin_init() 
{
    
register_plugin(TITLEVERSIONAUTHOR)
    
register_cvar(TITLE,VERSION,FCVAR_SERVER)    //plugin displays as cvar for HLSW or whatever
    
    
maxplayers get_maxplayers()
    
register_clcmd("say","handle_say")
    
    new 
modname[32]
    
get_modname(modname,31)
    
    if(
equali("cstrike",modname))
        
register_event("SendAudio","EndofRound","a","2=%!MRAD_terwin","2=%!MRAD_ctwin","2=%!MRAD_rounddraw"
    else if(
equali("ns",modname))
        
register_event("GameStatus""EndofRound""ab""1=2")
    else if(
equali("dod",modname))
        
register_event("RoundState","EndofRound","a","1=3","1=4")
}
//---------------------------------------------------------------------------------------------------
public plugin_end() {    //update user on map change but not 2 times
    
new Float:gametime get_gametime()
    for(new 
id=1;id<=maxplayers;id++)
        if( 
is_user_connected(id) )
            
updateUser(id00floatround(gametime g_onlinetime[id]))
}
//---------------------------------------------------------------------------------------------------
public EndofRound() {
    new 
Float:gametime get_gametime()
    for(new 
id=1;id<=maxplayers;id++)
        if( 
is_user_connected(id) && !is_user_bot(id)) {
            
updateUser(id10floatround(gametime g_onlinetime[id]))
            
g_onlinetime[id] = gametime
        
}
}
//---------------------------------------------------------------------------------------------------
public client_putinserver(id) {
    if(
is_user_connected(id) && !is_user_bot(id)) {
        
updateUser(id010)
        
g_onlinetime[id] = get_gametime() - 3.0
    
}
}
//---------------------------------------------------------------------------------------------------
public client_disconnect(id) {
    if(!
is_user_bot(id))
        
updateUser(id00floatround(get_gametime()-g_onlinetime[id]))
    
g_onlinetime[id] = 0.0
}
//---------------------------------------------------------------------------------------------------
public handle_say(id) {
    new 
said[192]
    
read_args(said,191)
    
remove_quotes(said)
    if( (
containi(said"!info") != -1) ) {
        new 
info[7]
        new 
name[34]
        new 
data[2]
        
data[0] = id
        
        parse
(saidinfo6name33)
        if(
equali(info"!info"))
            if(
equal(name[0],"")) {
                
data[1] = id
                set_task
(0.1"printUserInfo"iddata2)
            }
            else
            {
                
data[1] = cmd_target(id,name,2// Don't block access...
                
if(data[1]) 
                    
set_task(0.1"printUserInfo"iddata2)
                else 
                    
client_print(id,print_chat,"[PInfo] - There is no player with that name.")    
            }
    }
    return 
PLUGIN_CONTINUE
}
//---------------------------------------------------------------------------------------------------
updateUser(idroundsconnectstime) {
    
    
Vault nvault_openVAULTNAME )
    if(
Vault == INVALID_HANDLE)
       
server_print("Error opening nVault file: %s",VAULTNAME)
    else 
    {
        new 
steamid[32], playerinfo[4][32// "FIRSTNICK"  "ROUNDS" "CONNECTIONS" "TOTALTIME"
        
new key[32], val[511], TimeStamp

        get_user_authid
(id,steamid,31)
        
format(key,32,"%s",steamid)

        if( 
nvault_lookup(Vaultkeyval510TimeStamp) ) 
        {
            
parse(valplayerinfo[0], 31playerinfo[1], 31playerinfo[2], 31playerinfo[3], 31)
            new 
update[511]
            
rounds += str_to_numplayerinfo[1] )
            
connects += str_to_numplayerinfo[2] )
            
time += str_to_numplayerinfo[3] )
            
format(update,510,"^"%s^" %i %i %i",playerinfo[0], roundsconnectstime)
            
nvault_set(Vaultkeyupdate)
        }
        else 
        {
            new 
update[511], name[32]
            
get_user_name(idname31)
            
format(update,510,"^"%s^" %i %i %i",name,0,1,0)
            
nvault_set(Vaultkeyupdate)
        }
        
nvault_close(Vault)
    }
}
//---------------------------------------------------------------------------------------------------
public printUserInfo(userids[]) 

    new 
id userids[0]
    new 
playerid userids[1]
    
    
Vault nvault_openVAULTNAME )
    if(
Vault == INVALID_HANDLE)
       
server_print("Error opening nVault file: %s",VAULTNAME)
    else 
    {
        new 
steamid[32], playerinfo[4][64// "FIRSTNICK" "ROUNDS" "CONNECTIONS" "TOTALTIME"
        
new key[32], val[511], TimeStamptext[512]
        
        
get_user_authid(playerid,steamid,31)
        
format(key,32,"%s",steamid)
        
        if( 
nvault_lookup(Vaultkeyval510TimeStamp) ) 
        {
            
parse(valplayerinfo[0], 63playerinfo[1], 63playerinfo[2], 63playerinfo[3], 63)

            new 
Float:gametime get_gametime()
            new 
onlinetime floatroundgametime g_onlinetime[playerid] )
            new 
ptime str_to_num(playerinfo[3]) + onlinetime
            
new days ptime 86400
            
new hours = (ptime 3600) % 24
            
new minutes = (ptime 60) % 60
            
new seconds ptime 60
            
new totaltime[64]
            new 
sday[16], shr[16], smin[16], ssec[16]
            
            
format(sday,15,"%i Day%s ",days, (days==1?"s":""))
            
format(shr,15,"%i Hr%s ",hours, (hours==1?"s":""))
            
format(smin,15,"%i Min%s ",minutes, (minutes==1?"s":""))
            
format(ssec,15,"%i Sec%s ",seconds, (seconds==1?"s":""))
            
format(totaltime63"%s%s%s%s", (days >= sday:""), (hours >= shr:""), smin, (hours==ssec:""))
            
format(text,511,"[ FIRST NICK: %s ][ CONNECTS: %s ][ ROUNDS: %s ][ TIME PLAYED: %s ]",playerinfo[0],playerinfo[2],playerinfo[1],totaltime)
            
client_print(id,print_chat,"%s",text)
            
            
nvault_close(Vault)
            
            
updateUser(playerid00onlinetime)
            
g_onlinetime[playerid] = gametime
        
}
    }
    return 
PLUGIN_HANDLED


I am configuring this for team fortress classic, which doesnt use rounds at all, so that can be completely removed, the only problem is I dont even know how to simply make a plugin that will make the server say hello

:( can someone help me please?

fysiks 06-17-2009 18:43

Re: Pinfo change rounds with steamid
 
Try this:

PHP Code:

/*
 *  Comments: 
 *        Displays player information. For Example...
 *        First Nick is the very first nick they had when their profile was created.
 *        Time Played is total time person has played on your server. Not just their current session.
 *        [ FIRST NICK: OneEyed ][ CONNECTS: 152 ][ ROUNDS: 25 ][ TIME PLAYED: 2 Days 3 Hrs 52 Mins ]
 *
 *    Note:
 *        Plugin is self-sufficient, just compile and add to plugins.ini / plugin folder and your set.
 *        All player data will be saved into pinfo.vault @ amxmodx/data/vault folder.
 *
 *    Chat Command:
 *        !info name        - Typed in chat.  If no name specified, returns your own info.
 *        
 *  Version :     2.0
 *    Requires:    AMXX 1.70+ and NVAULT module
 *    Gametype:     CS/NS/DOD
 *
 *    Author:        OneEyed
 *    Date:        01-23-2006
 *    Email:        [email protected]
 *    IRC:        #modns (gamesurge.net) 
 *
 *     Tested :
 *        WIN32 Tested and Approved! LINUX untested.
 * 
 *  Credits: 
 *       voogru - He used it on his server (I sorta replicated it)
 * 
 *    Change Log:
 *        v2.0 - Updated plugin to use nVault instead of *.ini file.
 *        v1.1 - Fixed to update played time at round end/map change, no more looped task.
 * 
 */

//---------------------------------------------------------------------------------------------
//-------------------DO NOT EDIT BELOW---------------------------------------------------------
#include <amxmodx>
#include <amxmisc>
#include <nvault>

new Float:g_onlinetime[33]
new 
maxplayers

new Vault
static const VAULTNAME[] = "pinfo"

static const TITLE[] = "PInfo"
static const VERSION[] = "2.0"
static const AUTHOR[] = "OneEyed"
//---------------------------------------------------------------------------------------------------
public plugin_init() 
{
    
register_plugin(TITLEVERSIONAUTHOR)
    
register_cvar(TITLE,VERSION,FCVAR_SERVER)    //plugin displays as cvar for HLSW or whatever
    
    
maxplayers get_maxplayers()
    
register_clcmd("say","handle_say")
    
    new 
modname[32]
    
get_modname(modname,31)
    
    if(
equali("cstrike",modname))
        
register_event("SendAudio","EndofRound","a","2=%!MRAD_terwin","2=%!MRAD_ctwin","2=%!MRAD_rounddraw"
    else if(
equali("ns",modname))
        
register_event("GameStatus""EndofRound""ab""1=2")
    else if(
equali("dod",modname))
        
register_event("RoundState","EndofRound","a","1=3","1=4")
}
//---------------------------------------------------------------------------------------------------
public plugin_end() {    //update user on map change but not 2 times
    
new Float:gametime get_gametime()
    for(new 
id=1;id<=maxplayers;id++)
        if( 
is_user_connected(id) )
            
updateUser(id00floatround(gametime g_onlinetime[id]))
}
//---------------------------------------------------------------------------------------------------
public EndofRound() {
    new 
Float:gametime get_gametime()
    for(new 
id=1;id<=maxplayers;id++)
        if( 
is_user_connected(id) && !is_user_bot(id)) {
            
updateUser(id10floatround(gametime g_onlinetime[id]))
            
g_onlinetime[id] = gametime
        
}
}
//---------------------------------------------------------------------------------------------------
public client_putinserver(id) {
    if(
is_user_connected(id) && !is_user_bot(id)) {
        
updateUser(id010)
        
g_onlinetime[id] = get_gametime() - 3.0
    
}
}
//---------------------------------------------------------------------------------------------------
public client_disconnect(id) {
    if(!
is_user_bot(id))
        
updateUser(id00floatround(get_gametime()-g_onlinetime[id]))
    
g_onlinetime[id] = 0.0
}
//---------------------------------------------------------------------------------------------------
public handle_say(id) {
    new 
said[192]
    
read_args(said,191)
    
remove_quotes(said)
    if( (
containi(said"!info") != -1) ) {
        new 
info[7]
        new 
name[34]
        new 
data[2]
        
data[0] = id
        
        parse
(saidinfo6name33)
        if(
equali(info"!info"))
            if(
equal(name[0],"")) {
                
data[1] = id
                set_task
(0.1"printUserInfo"iddata2)
            }
            else
            {
                
data[1] = cmd_target(id,name,2// Don't block access...
                
if(data[1]) 
                    
set_task(0.1"printUserInfo"iddata2)
                else 
                    
client_print(id,print_chat,"[PInfo] - There is no player with that name.")    
            }
    }
    return 
PLUGIN_CONTINUE
}
//---------------------------------------------------------------------------------------------------
updateUser(idroundsconnectstime) {
    
    
Vault nvault_openVAULTNAME )
    if(
Vault == INVALID_HANDLE)
       
server_print("Error opening nVault file: %s",VAULTNAME)
    else 
    {
        new 
steamid[32], playerinfo[4][32// "FIRSTNICK"  "ROUNDS" "CONNECTIONS" "TOTALTIME"
        
new key[32], val[511], TimeStamp

        get_user_authid
(id,steamid,31)
        
format(key,32,"%s",steamid)

        if( 
nvault_lookup(Vaultkeyval510TimeStamp) ) 
        {
            
parse(valplayerinfo[0], 31playerinfo[1], 31playerinfo[2], 31playerinfo[3], 31)
            new 
update[511]
            
rounds += str_to_numplayerinfo[1] )
            
connects += str_to_numplayerinfo[2] )
            
time += str_to_numplayerinfo[3] )
            
format(update,510,"^"%s^" %i %i %i",playerinfo[0], roundsconnectstime)
            
nvault_set(Vaultkeyupdate)
        }
        else 
        {
            new 
update[511], name[32]
            
get_user_name(idname31)
            
format(update,510,"^"%s^" %i %i %i",name,0,1,0)
            
nvault_set(Vaultkeyupdate)
        }
        
nvault_close(Vault)
    }
}
//---------------------------------------------------------------------------------------------------
public printUserInfo(userids[]) 

    new 
id userids[0]
    new 
playerid userids[1]
    
    
Vault nvault_openVAULTNAME )
    if(
Vault == INVALID_HANDLE)
       
server_print("Error opening nVault file: %s",VAULTNAME)
    else 
    {
        new 
steamid[32], playerinfo[4][64// "FIRSTNICK" "ROUNDS" "CONNECTIONS" "TOTALTIME"
        
new key[32], val[511], TimeStamptext[512]
        
        
get_user_authid(playerid,steamid,31)
        
format(key,32,"%s",steamid)
        
        if( 
nvault_lookup(Vaultkeyval510TimeStamp) ) 
        {
            
parse(valplayerinfo[0], 63playerinfo[1], 63playerinfo[2], 63playerinfo[3], 63)

            new 
Float:gametime get_gametime()
            new 
onlinetime floatroundgametime g_onlinetime[playerid] )
            new 
ptime str_to_num(playerinfo[3]) + onlinetime
            
new days ptime 86400
            
new hours = (ptime 3600) % 24
            
new minutes = (ptime 60) % 60
            
new seconds ptime 60
            
new totaltime[64]
            new 
sday[16], shr[16], smin[16], ssec[16]
            
            
format(sday,15,"%i Day%s ",days, (days==1?"s":""))
            
format(shr,15,"%i Hr%s ",hours, (hours==1?"s":""))
            
format(smin,15,"%i Min%s ",minutes, (minutes==1?"s":""))
            
format(ssec,15,"%i Sec%s ",seconds, (seconds==1?"s":""))
            
format(totaltime63"%s%s%s%s", (days >= sday:""), (hours >= shr:""), smin, (hours==ssec:""))
            
format(text,511,"[ FIRST NICK: %s ][ CONNECTS: %s ][SteamID: %s ][ TIME PLAYED: %s ]",playerinfo[0],playerinfo[2],steamid,totaltime)
            
client_print(id,print_chat,"%s",text)
            
            
nvault_close(Vault)
            
            
updateUser(playerid00onlinetime)
            
g_onlinetime[playerid] = gametime
        
}
    }
    return 
PLUGIN_HANDLED



HLM 06-17-2009 19:05

Re: Pinfo change rounds with steamid
 
Yes, that worked! thanks a million!!

(now to learn a little more about amxx scripting..)

HLM 07-27-2009 17:11

Re: Pinfo change rounds with steamid
 
sorry for resurrecting an old thread, but now after users join the game, it times out with a segmentation fault.. theres not much to say.. its a linux server.. here is the info I obtained that 'might' help in stomping out why.. I have proven that it is the plugin by running just that plugin (with no other mods, and with other mods)

Code:

L 07/27/2009 - 16:03:24: [META] (debug:3) Calling NeoTF_i486.so:ClientPutInServer()
L 07/27/2009 - 16:03:24: [NEOTF] NeoTFClientPutInServer: 0x10065f4 (-[EVIL]- Loose<5><>)
L 07/27/2009 - 16:03:24: [META] (debug:3) Calling admin_MM_i386.so:ClientPutInServer()
L 07/27/2009 - 16:03:24: [META] (debug:3) Calling HookMod_i386.so:ClientPutInServer()
L 07/27/2009 - 16:03:24: [META] (debug:3) Calling foxbot_MM_i586.so:ClientPutInServer()
L 07/27/2009 - 16:03:24: [META] (debug:3) Calling EntMod_i386.so:ClientPutInServer()
L 07/27/2009 - 16:03:24: [META] (debug:3) Calling tfctech_mm_i386.so:ClientPutInServer()
L 07/27/2009 - 16:03:24: [META] (debug:3) Calling sc-prot_mm_i686.so:ClientPutInServer()
L 07/27/2009 - 16:03:24: [META] (debug:3) Calling RadioMod_i386.so:ClientPutInServer()
L 07/27/2009 - 16:03:24: [META] (debug:3) Calling tfc_i386.so:ClientPutInServer()
L 07/27/2009 - 16:03:24: [META] (debug:3) Calling HookMod_i386.so:ClientPutInServer_Post()
L 07/27/2009 - 16:03:24: [META] (debug:3) Calling EntMod_i386.so:ClientPutInServer_Post()
L 07/27/2009 - 16:03:24: [META] (debug:3) Calling amxmodx_mm_i386.so:ClientPutInServer_Post()
./hlds_run: line 321: 11032 Segmentation fault      $HL_CMD

I dont know whats causing it..

AMXX shows no errors... that is the best info I could get on my problem, im sorry :(

fysiks 07-27-2009 17:44

Re: Pinfo change rounds with steamid
 
So, if you just disable this plugin (and only this plugin) it still crashes?

HLM 07-27-2009 18:10

Re: Pinfo change rounds with steamid
 
no, this plugin alone is causing a crash, everything else is causing crashes, more specifically when a player 'connects' I think it is on precaching resources..

more direct answer to your question: no, it will not crash with this plugin OFF, but rather when it is ON


All times are GMT -4. The time now is 15:43.

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