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

I cant seem to get this working


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Static2601
Senior Member
Join Date: Jun 2010
Old 05-23-2013 , 22:02   I cant seem to get this working
Reply With Quote #1

Im trying to run a code to check if the players steamid matches with what I have stored when they connect to the server. It should then say Match, but keeps saying No Match. Im not sure what im doing wrong, Ive tried soo many different variations and still nothing. right now, this is only a check to see how I would detect certain clients connecting. I would later make it alert admins of players that connected to the server so they can be watched.
Code:
#include <sourcemod>

public Plugin:myinfo = 
{
    name = "New Plugin",
    author = "Unknown",
    description = "<- Description ->",
    version = "1.0",
    url = "<- URL ->"
}
new String:g_SteamId[32] = "STEAM_0:0:42468081";

public OnPluginStart()
{
}
public OnClientConnected()
{
    new Clients = GetMaxClients();
    for (new i=1;i<=Clients;i++)
    {
        decl String:auth[33];
        GetClientAuthString(i, auth, sizeof(auth));
        if (IsClientAuthorized(i) && StrEqual(auth[32], g_SteamId, true))
        {
            PrintToChatAll("Match");
        }    
        else
        {
            PrintToChatAll("No Match");
        }
    }
}
Static2601 is offline
mcpan313
Senior Member
Join Date: Mar 2010
Old 05-23-2013 , 22:10   Re: I cant seem to get this working
Reply With Quote #2

PHP Code:
#include <sourcemod>

new String:g_SteamId[32] = "STEAM_0:0:42468081";

public 
OnClientAuthorized(client, const String:auth[])
{
    if (
IsFakeClient(client))
    {
        
// Ignore bots
        
return;
    }

    if (
StrEqual(authg_SteamId))
    {
        
PrintToConsole(client"Match");
    }
    else
    {
        
PrintToConsole(client"No Match");
    }

__________________
sorry, for my poor english.
mcpan313 is offline
Send a message via MSN to mcpan313
Static2601
Senior Member
Join Date: Jun 2010
Old 05-23-2013 , 22:34   Re: I cant seem to get this working
Reply With Quote #3

ohh, thats a forward, i didnt even look at the api for onclientauthorized. Ill give this a try. Thanks
Static2601 is offline
Static2601
Senior Member
Join Date: Jun 2010
Old 05-25-2013 , 14:38   Re: I cant seem to get this working
Reply With Quote #4

well that does work good and i was wondering how I would get the players other information like current name.

I see that I can getclientofuserid, but I need to first get their userid but how to I get this if I only had their steam id? I think I need to list all clients and get their userid's, then getclientauthstring and see which ones match and take that one and getclientofuserid... Im so lost with this. I normally do this by the trial and error method which I will try all the wrong ways before i find the right way, lol. This wasted alot of my time.

Sourcepawn is the first language ive learned or still learning. Im still struggling to learn everything, though I have learned alot so far and Im always on this site looking at how others made something work. There is still a lot I have problems with but I know where to go when I need help.

Last edited by Static2601; 05-25-2013 at 14:39.
Static2601 is offline
Static2601
Senior Member
Join Date: Jun 2010
Old 05-25-2013 , 15:12   Re: I cant seem to get this working
Reply With Quote #5

yup Ive seen that but im not sure how I would use it to get their name from their steamId.

Last edited by Static2601; 05-25-2013 at 15:13.
Static2601 is offline
Static2601
Senior Member
Join Date: Jun 2010
Old 05-25-2013 , 16:14   Re: I cant seem to get this working
Reply With Quote #6

Ok I figured it how to do it, but if 2 people connect at the same time, could it possibly get the other persons info instead of the one its looking for?
Code:
new String:g_SteamId[32] = "STEAM_0:0:42468081";
public OnPluginStart()
{
}
public OnClientAuthorized(client, const String:auth[])
{
    if (StrEqual(auth, g_SteamId))
    {
        decl String:Name[MAX_NAME_LENGTH]; decl String:IP[18];
        GetClientName(client, Name, sizeof(Name));
        GetClientIP(client, IP, sizeof(IP));
        PrintToChatAll("SteamId: %s, Name: %s, IP: %s", g_SteamId, Name, IP);
    }
}

Last edited by Static2601; 05-25-2013 at 16:15.
Static2601 is offline
Dr. McKay
Sir Dr. SourceMod Plugin Approver Esq. Ltd. M.D. PhD
Join Date: Aug 2011
Location: Atlantis
Old 05-25-2013 , 17:32   Re: I cant seem to get this working
Reply With Quote #7

It's fairly rare that you'll need to use GetClientName. For most situations, the %N format specifier works fine.

PHP Code:
new String:g_SteamId[32] = "STEAM_0:0:42468081";
public 
OnClientAuthorized(client, const String:auth[]) {
    if(
StrEqual(authg_SteamId)) {
        
decl String:IP[18];
        
GetClientIP(clientIPsizeof(IP));
        
PrintToChatAll("SteamID: %s, Name: %N, IP: %s"authclientIP);
    }

http://wiki.alliedmods.net/Format_Cl...Mod_Scripting)
__________________
Dr. McKay is offline
Static2601
Senior Member
Join Date: Jun 2010
Old 05-25-2013 , 18:57   Re: I cant seem to get this working
Reply With Quote #8

Well, I use the name in other places in the plugin like in a menu, it will say options for %s, Name. But im mostly wondering how I can get that clients index or whatever, that wont change and I can call it when i need to, say I need to get there current health or number of deaths. Maybe target will work? Can I target by Steam Id or can I set a variable that only refers to that client?
Static2601 is offline
Dr. McKay
Sir Dr. SourceMod Plugin Approver Esq. Ltd. M.D. PhD
Join Date: Aug 2011
Location: Atlantis
Old 05-26-2013 , 09:22   I cant seem to get this working
Reply With Quote #9

Quote:
Originally Posted by NefariousDomination View Post
Client indexes can change
Not while the client is connected.
__________________
Dr. McKay 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 13:59.


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