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

Client authentication


Post New Thread Reply   
 
Thread Tools Display Modes
chemicstry
Junior Member
Join Date: Jan 2010
Old 04-03-2010 , 06:24   Re: Client authentication
Reply With Quote #11

The problem is that i dont know how to use extensions. I pasted sdkhooks.inc file into my plugin but it doesnt compile (web compiler), #include <sdkhooks> doesnt work too. Please help me

I have to compile with visual studio?

EDIT: ok now, i didnt know that sourcemod has compiler in scripting dir

Last edited by chemicstry; 04-03-2010 at 06:43.
chemicstry is offline
chemicstry
Junior Member
Join Date: Jan 2010
Old 04-03-2010 , 08:11   Re: Client authentication
Reply With Quote #12

String question: How do i remove the first part of the string? in php there is a function substr(string, n), but i cant find it on sourcemod. Let's say i have STEAM_0:0:123456789 and i want to remove the first ten characters, the result should be 123456789. How to do that?

GetClientAuthString gives STEAM_0:0:123456789 or 0:0:123456789 ?
chemicstry is offline
exvel
SourceMod Donor
Join Date: Jun 2006
Location: Russia
Old 04-03-2010 , 08:55   Re: Client authentication
Reply With Quote #13

I don't think there is a function for this.

I've written a stock that can do this:
PHP Code:
/**
 * Copy part of the string into another string 
 *
 * @param szInput    String you need to copy from
 * @param szOutput    String you need to copy to
 * @param maxlen    Maximum lenght of the szOutput string
 * @param start     Position you need to start copy from, if -1 then copy from the beginning
 * @param end       Position you need to end copy, if -1 then copy to the end of the string
 * @return            No return
 */
stock CopyStringPart(const String:szInput[], String:szOutput[], maxlenstart=-1end=-1)
{
    if (
start == -1)
        
start 0;
    
    if (
end == -1)
        
end strlen(szInput);
    
    if (
start >= end)
        return;
    
    for (new 
start0end && maxlen-1i++, j++)
    {
        
szOutput[j] = szInput[i];
        
szOutput[j+1] = 0;
    }

__________________
For admins: My plugins

For developers: Colors library

Last edited by exvel; 04-03-2010 at 08:58.
exvel is offline
Send a message via ICQ to exvel
chemicstry
Junior Member
Join Date: Jan 2010
Old 04-03-2010 , 11:08   Re: Client authentication
Reply With Quote #14

Works perfectly thanks! More questions Is there something like 'in' operator? on eventscripts i used "if (server_var(clientip) in server_var(iplist))" how to do that in sourcemod?

EDIT: solved with adt_array

Last edited by chemicstry; 04-03-2010 at 12:18.
chemicstry is offline
marvelaugusts
BANNED
Join Date: Apr 2010
Old 04-05-2010 , 05:01   Re: Client authentication
Reply With Quote #15

Well i don't know should i put my question here or not but i have one problem. As when i logged into website and where i open three to five pages. But when i log out from one pages than still its showing login on the other pages. I am creating website using V. B. Net. Can anyone provide me the way or code from which i can solve this problem.
marvelaugusts is offline
chemicstry
Junior Member
Join Date: Jan 2010
Old 04-05-2010 , 10:20   Re: Client authentication
Reply With Quote #16

Code:
Hook events etc...

public Event_PlayerDeath(Handle:event, const String:name[], bool:dontBroadcast)
{
    new bool:headshot = GetEventBool(event, "headshot"), attacker = GetEventInt(event, "attacker"), aci = GetClientOfUserId(attacker), cSteamid[30], sSteamid[30]
    GetClientAuthString(aci, cSteamid, sizeof(cSteamid))
    CopyStringPart(cSteamid, sSteamid, sizeof(sSteamid), 10, -1)
    if (FindStringInArray(cArray, sSteamid) != -1)
    {
        if (headshot)
        {
            new playercash = GetEntData(aci, MoneyOffset, 4);
            playercash += 500
            SetEntData(aci, MoneyOffset, playercash, 4, true)
        } else {
            new playercash = GetEntData(aci, MoneyOffset, 4);
            playercash += 200
            SetEntData(aci, MoneyOffset, playercash, 4, true)
        }
    }
}
In array there is stored players steamid last numbers (after STEAM_0:0: ), but this sometimes work and sometimes it doesnt. I tested and when it doesnt work it stops at "if (FindStringInArray(cArray, sSteamid) != -1)" how to fix this?

EDIT: Solved its because i havent checked if client is in game and got errors

L 04/05/2010 - 00:01:24: [SM] Displaying call stack trace for plugin "vipmod.smx":
L 04/05/2010 - 00:01:24: [SM] [0] Line 379, D:\sourcemod\scripting\vipmod.sp::Event_Round Start()
L 04/05/2010 - 00:03:17: [SM] Native "IsPlayerAlive" reported: Client 1 is not in game

EDIT2: Now i have another error:

L 04/05/2010 - 18:017: [SM] Native "GetClientAuthString" reported: Client index 0 is invalid
L 04/05/2010 - 18:017: [SM] Displaying call stack trace for plugin "vipmod.smx":
L 04/05/2010 - 18:017: [SM] [0] Line 404, D:\sourcemod\scripting\vipmod.sp::Event_Playe rDeath()

there is no bots on the server how could this happen?

Last edited by chemicstry; 04-05-2010 at 11:06.
chemicstry is offline
Leonardo
Veteran Member
Join Date: Feb 2010
Location: 90's
Old 04-05-2010 , 14:53   Re: Client authentication
Reply With Quote #17

PHP Code:
public Event_PlayerDeath(Handle:event, const String:name[], bool:dontBroadcast)
{
    new 
bool:headshot GetEventBool(event"headshot"), attacker GetEventInt(event"attacker"), aci GetClientOfUserId(attacker), cSteamid[30], sSteamid[30]
    if(
aci && IsClientInGame(aci) && IsClientAuthorized(aci))
    {
        
GetClientAuthString(acicSteamidsizeof(cSteamid))
        if(!
StrEqual(cSteamid,"BOT",false) && !StrContains(cSteamid,"STEAM_ID_",false))
        {
            
CopyStringPart(cSteamidsSteamidsizeof(sSteamid), 10, -1)
            if (
FindStringInArray(cArraysSteamid) != -1)
            {
                if (
headshot)
                {
                    new 
playercash GetEntData(aciMoneyOffset4);
                    
playercash += 500
                    SetEntData
(aciMoneyOffsetplayercash4true)
                } else {
                    new 
playercash GetEntData(aciMoneyOffset4);
                    
playercash += 200
                    SetEntData
(aciMoneyOffsetplayercash4true)
                }
            }
        }
    }

no?
__________________
Leonardo is offline
chemicstry
Junior Member
Join Date: Jan 2010
Old 04-06-2010 , 08:42   Re: Client authentication
Reply With Quote #18

Now this happens only on map start:

Code:
L 04/06/2010 - 12:34:38: SourceMod error session started
L 04/06/2010 - 12:34:38: Info (map "de_3rdstreet") (file "errors_20100406.log")
L 04/06/2010 - 12:34:38: [SM] Native "GetClientAuthString" reported: Client index 0 is invalid
L 04/06/2010 - 12:34:38: [SM] Displaying call stack trace for plugin "vipmod.smx":
L 04/06/2010 - 12:34:38: [SM]   [0]  Line 409, D:\sourcemod\scripting\vipmod.sp::Event_PlayerDeath()
L 04/06/2010 - 12:34:59: Error log file session closed.
L 04/06/2010 - 14:33:01: SourceMod error session started
L 04/06/2010 - 14:33:01: Info (map "knas_sandland_css") (file "errors_20100406.log")
L 04/06/2010 - 14:33:01: [SM] Native "GetClientAuthString" reported: Client index 0 is invalid
L 04/06/2010 - 14:33:01: [SM] Displaying call stack trace for plugin "vipmod.smx":
L 04/06/2010 - 14:33:01: [SM]   [0]  Line 409, D:\sourcemod\scripting\vipmod.sp::Event_PlayerDeath()
L 04/06/2010 - 14:47:04: Error log file session closed.
L 04/06/2010 - 15:11:21: SourceMod error session started
L 04/06/2010 - 15:11:21: Info (map "de_piranesi") (file "errors_20100406.log")
L 04/06/2010 - 15:11:21: [SM] Native "GetClientAuthString" reported: Client index 0 is invalid
L 04/06/2010 - 15:11:21: [SM] Displaying call stack trace for plugin "vipmod.smx":
L 04/06/2010 - 15:11:21: [SM]   [0]  Line 409, D:\sourcemod\scripting\vipmod.sp::Event_PlayerDeath()
L 04/06/2010 - 15:29:58: Error log file session closed.
It seems that event playerdeath fires on mapchange, but its not a big deal.
chemicstry is offline
Leonardo
Veteran Member
Join Date: Feb 2010
Location: 90's
Old 04-06-2010 , 10:40   Re: Client authentication
Reply With Quote #19

what is a Line 409 ?
__________________
Leonardo is offline
chemicstry
Junior Member
Join Date: Jan 2010
Old 04-06-2010 , 14:01   Re: Client authentication
Reply With Quote #20

Quote:
Originally Posted by Leonardo View Post
what is a Line 409 ?
Code:
public Event_PlayerDeath(Handle:event, const String:name[], bool:dontBroadcast)
{
    new attacker = GetEventInt(event, "attacker"), bool:headshot = GetEventBool(event, "headshot"), cSteamid[30], sSteamid[30]
    new aci = GetClientOfUserId(attacker)
[409]    GetClientAuthString(aci, cSteamid, sizeof(cSteamid))
    CopyStringPart(cSteamid, sSteamid, sizeof(sSteamid), 10, -1)
    if (FindStringInArray(cArray, sSteamid) != -1)
    {
        if (headshot)
        {
            new playercash = GetEntData(aci, MoneyOffset, 4);
            playercash += 500
            SetEntData(aci, MoneyOffset, playercash, 4, true)
        } else {
            new playercash = GetEntData(aci, MoneyOffset, 4);
            playercash += 200
            SetEntData(aci, MoneyOffset, playercash, 4, true)
        }
    }
}
Is it posable that FindStringInArray(cArray, sSteamid) sometimes doesn't work? because it doesn't give any error but doesn't work too.

Last edited by chemicstry; 04-06-2010 at 14:05.
chemicstry 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 16:54.


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