Raised This Month: $51 Target: $400
 12% 

Checking for indvidual steamid is connecting


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
[Black_Jack]
Member
Join Date: Mar 2010
Location: Novosi[Beer]sk
Old 04-07-2010 , 05:39   Checking for indvidual steamid is connecting
Reply With Quote #1

Hi. I try to write plugin, but have a question. How can I chec for idividual steamid. Try to explain: If Steam_0:1:123456 is connectig, then exec function.


Tried to do this, but this didnt work =(
PHP Code:
public client_authorized(id)
{
    
get_user_authid(idSID)
    if(
contain("STEAM:0:1:123456"SIDset_task(0.1, function, id)

And i forgot the function which exec your public function, instead of set_task. Lol
I'm new to scripting
__________________
[Black_Jack] is offline
Send a message via ICQ to [Black_Jack]
xPaw
Retired AMX Mod X Moderator
Join Date: Jul 2008
Old 04-07-2010 , 05:52   Re: Checking for indvidual steamid is connecting
Reply With Quote #2

Code:
public client_authorized( id ) {     new szAuthId[ 40 ];     get_user_authid( id, szAuthId, 39 );         if( equal( szAuthId, "blah" ) )         YourFunction( id ); }
__________________
xPaw is offline
Dr.G
Senior Member
Join Date: Nov 2008
Old 04-07-2010 , 06:05   Re: Checking for indvidual steamid is connecting
Reply With Quote #3

yeah well id recommand to trim strings, atleast if you are using a WIN server.


PHP Code:
/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <amxmisc>

#define PLUGIN "New Plug-In"
#define VERSION "1.0 by Dr.G"
#define AUTHOR "AMXX DoD Team"

new const STEAM_ID[] = "STEAM:0:1:123456"

new p_on

public plugin_init() 
{
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
p_on register_cvar("amx_something""1")
}
public 
client_authorized(id)
{
    if(
is_user_bot(id) || is_user_hltv(id) || !get_pcvar_num(p_on))
        return 
PLUGIN_CONTINUE
    
    
new iSteamStr[32]
    
    
get_user_authid(idiSteamStrsizeof(iSteamStr) - 1)
    
trim(iSteamStr)
    
    if(
equal(STEAM_IDiSteamStr))
    {
        
server_print("User with %s has connected"iSteamStr)
        
doStuff(id)
    }
    
    return 
PLUGIN_CONTINUE
}
doStuff(id) {
    
    
/* Warning: Symbol is never used: "id"... yea yea...*/
    
server_print("..doStuff")
    return 
PLUGIN_CONTINUE

__________________
Dr.G is offline
[Black_Jack]
Member
Join Date: Mar 2010
Location: Novosi[Beer]sk
Old 04-07-2010 , 06:08   Re: Checking for indvidual steamid is connecting
Reply With Quote #4

Thanks very much ^^
__________________
[Black_Jack] is offline
Send a message via ICQ to [Black_Jack]
[Black_Jack]
Member
Join Date: Mar 2010
Location: Novosi[Beer]sk
Old 04-07-2010 , 06:33   Re: Checking for indvidual steamid is connecting
Reply With Quote #5

Hm, And another question. How to add few steamids in 1 const?
MB Like this?
PHP Code:
new const SIDs = {
"111",
"1111",
..
..
..
"22222"
Will this works with my code?
__________________
[Black_Jack] is offline
Send a message via ICQ to [Black_Jack]
Old 04-07-2010, 06:58
Seta00
This message has been deleted by Seta00. Reason: Complete code is better, see below
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 04-07-2010 , 08:06   Re: Checking for indvidual steamid is connecting
Reply With Quote #6

Quote:
Originally Posted by [Black_Jack] View Post
Hm, And another question. How to add few steamids in 1 const?
MB Like this?
...
Will this works with my code?
PHP Code:
//Add as many as you want
new const CheckSteamID[][] = 

    
"STEAM_12345" ,
    
"STEAM_67890" ,
    
"STEAM_10101" ,
    
"STEAM_01010" 
};

public 
client_authorizedid )
{
    new 
szSteamID35 ];
    
get_user_authidid szSteamID charsmaxszSteamID ) );
    
    for ( new 
sizeofCheckSteamID ) ; i++ )
    {
        if ( 
equalszSteamID CheckSteamID] ) )
        {
            
// Player has connected, take action on player.
            // Some functions that you call here may need
            // a delay depending on what it does. If this is 
            // the case, use set_task( 3.0 , "DelayFunc" , id )
            // and place your code in DelayFunc (see below).
        
            //set_user_money( id );
        
}
    }
}

public 
DelayFuncid )
{
    
// This will be called 3 seconds (or whatever delay is specific in set_task) 
    // after client_authorized()

    //set_user_money( id );

__________________

Last edited by Bugsy; 04-07-2010 at 08:16.
Bugsy is offline
Dr.G
Senior Member
Join Date: Nov 2008
Old 04-07-2010 , 09:33   Re: Checking for indvidual steamid is connecting
Reply With Quote #7

I would use a Trie

->

PHP Code:
/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <amxmisc>
////////////////////////////////////////////////////////////////////////////////////////////////////
#define PLUGIN "New Plug-In"
#define VERSION "1.0 by Dr.G"
#define AUTHOR "AMXX DoD Team"
////////////////////////////////////////////////////////////////////////////////////////////////////
new const STEAM_IDs[][] = { 
    
    
"STEAM:0:1:123456"
    
"STEAM:0:1:1234567"
    
"STEAM:0:1:12345678"
    
"STEAM:0:1:123456789"
}

new 
p_on
new Trie:SteamList
////////////////////////////////////////////////////////////////////////////////////////////////////
public plugin_init() 
{
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
p_on register_cvar("amx_something""1")
    
    
SteamList TrieCreate()
    
    for(new 
sizeof STEAM_IDs i++)
        
TrieSetCell(SteamListSTEAM_IDs[i], 1)
    
}
////////////////////////////////////////////////////////////////////////////////////////////////////
public client_authorized(id)
{
    if(
is_user_bot(id) || is_user_hltv(id) || !get_pcvar_num(p_on))
        return 
PLUGIN_CONTINUE
    
    
new iSteamStr[32]
    
    
get_user_authid(idiSteamStrsizeof(iSteamStr) - 1)
    
trim(iSteamStr)
    
    if(
TrieKeyExists(SteamListiSteamStr))
    {
        
server_print("User with %s has connected"iSteamStr)
        
doStuff(id)
    }
    
    return 
PLUGIN_CONTINUE
}
////////////////////////////////////////////////////////////////////////////////////////////////////
doStuff(id) {
    
    
/* Warning: Symbol is never used: "id"... */
    
server_print("..doStuff")
    return 
PLUGIN_CONTINUE
}
////////////////////////////////////////////////////////////////////////////////////////////////////
public plugin_end()
{
    
TrieDestroy(SteamList)
}
//////////////////////////////////////////////////////////////////////////////////////////////////// 
__________________
Dr.G is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 04-07-2010 , 10:02   Re: Checking for indvidual steamid is connecting
Reply With Quote #8

Perhaps if data was being read from a file where the list could grow large. I dont see a point in using trie for such a short list. If he decides to read from file, there is an example I recently wrote that reads entries from file and stores in trie

http://forums.alliedmods.net/showpos...7&postcount=13

http://forums.alliedmods.net/showpos...0&postcount=27
__________________
Bugsy is offline
[Black_Jack]
Member
Join Date: Mar 2010
Location: Novosi[Beer]sk
Old 04-07-2010 , 10:52   Re: Checking for indvidual steamid is connecting
Reply With Quote #9

Hmmm... Not compiling with Bugsy's code .

PHP Code:
/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <amxmisc>

#define PLUGIN "New Plug-In"
#define VERSION "1.0"
#define AUTHOR "Black_Jack"


public plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    new const 
SteamIDs[][] = 
    {
        
"STEAM_0:1:234567",
        
"STEAM_0:2:234255",
        
"STEAM_0:1:342356"
    
}
}

public 
client_authorized(id)
{
    new 
temp[35]
    
get_user_authid(idtempsizeof(temp))
    for(new 
isizeof(SteamIDs); i++)
    {
        if(
equal(tempSteamIDs[i]))
        {
            
server_print("123123123")
        }
    }

PHP Code:
Welcome to the AMX Mod X 1.8.1-300 Compiler.
Copyright (c1997-2006 ITB CompuPhaseAMX Mod X Team

Warning
Symbol is assigned a value that is never used"SteamIDs" on line 19
Error
Undefined symbol "SteamIDs" on line 25
Error
: Empty statement on line 25
Error
Undefined symbol "i" on line 25
Error
Too many error messages on one line on line 25

Compilation aborted
.
4 Errors.
Could not locate output file C:\Server\Clear\cstrike\addons\amxmodx\plugins\Untitled.amx (compile failed). 
__________________
[Black_Jack] is offline
Send a message via ICQ to [Black_Jack]
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 04-07-2010 , 11:22   Re: Checking for indvidual steamid is connecting
Reply With Quote #10

You have to make SteamIDs a global variable.
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
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 07:19.


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