Raised This Month: $ Target: $400
 0% 

help blacklist system


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
liav319
Junior Member
Join Date: Mar 2009
Old 01-22-2013 , 06:53   help blacklist system
Reply With Quote #1

please help me why i get this error


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

Warning
Loose indentation on line 74
Warning
Unreachable code on line 75
Warning
Loose indentation on line 75
Warning
Loose indentation on line 98
Warning
: Function "client_authorizedold" should return a value on line 103
Warning
Loose indentation on line 123
Error
Invalid expressionassumed zero on line 127
Warning
Loose indentation on line 132
Warning
Loose indentation on line 314
Warning
Loose indentation on line 315

1 Error
.
Could not locate output file C:\****.amx (compile failed). 

PHP Code:
public client_authorized(id) {
    if (
is_user_bot(id))
        return 
PLUGIN_CONTINUE

    
const LEN 32

    
new authid[LEN 1], name[32]

    
get_user_authid(idauthidLEN)
    
get_user_name(idname31)

    
g_regged[id] = checkreg(authidname)

    if (
g_regged[id])
        
server_print("[%s] %s (%s) is registered."PLUGINNAMEnameauthid)
        if (
get_cvar_num(CVAR_KICKNONREGGED)) {
            new 
regurl[128]
            
get_cvar_string(CVAR_REGURLregurl127)
            
server_cmd("kick #%d your Steam ID %s is been blacklisted at %s ."get_user_userid(id), authidregurl
            else {
        
server_print("[%s] %s (%s) is not blacklisted."PLUGINNAMEnameauthid)
        }
    }

    return 
PLUGIN_CONTINUE


Last edited by liav319; 01-22-2013 at 06:54.
liav319 is offline
AngeIII
Senior Member
Join Date: Sep 2007
Location: Latvia
Old 01-22-2013 , 06:58   Re: help blacklist system
Reply With Quote #2

without full code it stink..
__________________
skype: pavle_ivanof
-=ThQ=-
PRIVATE SUPPORT = PAID SUPPORT
AngeIII is offline
Send a message via Skype™ to AngeIII
liav319
Junior Member
Join Date: Mar 2009
Old 01-22-2013 , 07:15   Re: help blacklist system
Reply With Quote #3

PHP Code:
#define PLUGINNAME    "BlackList"
#define VERSION        "0.2"
#define AUTHOR         "JH


#include <amxmodx>
#include <dbi>
#include <amxmisc>
#include <engine>

// ---------- Adjust below settings to your liking ---------------------------------------
// nothing...
// ---------- Adjust above settings to your liking ---------------------------------------

#define CVAR_WHOST            "host"
#define CVAR_WUSER            "user"
#define CVAR_WPASS            "pass"
#define CVAR_WDB            "db"
#define CVAR_KICKNONREGGED    "kicknonregged"
#define CVAR_REGURL            "regurl"
#define CVAR_PREPEND        "prepend"
#define WWWREGTABLE            "listblack"

// Global vars below
new g_regged[33]
new 
g_names[33][32// Max length of name is 31
// Global vars above



public plugin_modules() {
    
require_module("engine")
    
require_module("dbi")
}
    


public 
client_authorized(id) {
    if (
is_user_bot(id))
        return 
PLUGIN_CONTINUE

    
const LEN 32

    
new authid[LEN 1], name[32]

    
get_user_authid(idauthidLEN)
    
get_user_name(idname31)

    
g_regged[id] = checkreg(authidname)

    if (
g_regged[id])
        
server_print("[%s] %s (%s) is registered."PLUGINNAMEnameauthid)
        if (
get_cvar_num(CVAR_KICKNONREGGED)) {
            new 
regurl[128]
            
get_cvar_string(CVAR_REGURLregurl127)
            
server_cmd("kick #%d your Steam ID %s is been blacklisted at %s ."get_user_userid(id), authidregurl
            else {
        
server_print("[%s] %s (%s) is not blacklisted."PLUGINNAMEnameauthid)
        }
    }

    return 
PLUGIN_CONTINUE
}


    
    
public 
client_infochanged(id) {
    if (
is_user_bot(id) || is_user_connecting(id))
        return 
PLUGIN_CONTINUE

    get_user_name
(idg_names[id], 31)
    new 
idd[1]
    
idd[0] = id
    set_task
(0.1"checkname"0idd1)

    return 
PLUGIN_CONTINUE
}

localtrim(stringtotrim[], const LENcharstotrim, const bool:FROMLEFT true) {
    if (
charstotrim <= 0)
        return

    if (
FROMLEFT) {
        new 
maxlen strlen(stringtotrim)
        if (
charstotrim maxlen)
            
charstotrim maxlen

        format
(stringtotrimLEN"%s"stringtotrim[charstotrim])
    }
    else {
        new 
maxlen strlen(stringtotrim) - charstotrim
        
if (maxlen 0)
            
maxlen 0

        format
(stringtotrimmaxlen"%s"stringtotrim)
    }
}

public 
checkname(idd[1]) {
    if (
is_user_bot(idd[0])) // Somehow some realbots slipped past the bot check in client_infochanged! :-(
        
return

    new 
name[32], prepend[32], prependlength
    get_user_name
(idd[0], name31)
    
get_cvar_string(CVAR_PREPENDprepend31)
    
prependlength strlen(prepend)
    if (
g_regged[idd[0]]) {
        
// Registered users shouldn't have names starting with CVAR_PREPEND
        // If length of set name is shorter than prepend string, user's name can't be prepend string. :-)
        
if (strlen(name) >= prependlength && equali(nameprependprependlength)) { // case insensitive...
            // Trim name prependlength chars from left
            
localtrim(name31prependlength)
            
entity_set_string(idd[0], EV_SZ_netnamename)
            
set_user_info(idd[0], "name"name)
            
client_print(idd[0], print_console"Sorry, you can't use the public prefix ^"%s^"in your name because you are blacklisted!"prepend)
        }
        if (!
equal(nameg_names[idd[0]])) {
            
// Update lastusedname in db if it changed
            
update_db_name(idd[0], name)
        }
    }
    else {
        if (!
equal(prependnamestrlen(prepend))) {
            
//server_print("Forcing Pub: name on %s", name)
            
format(name31"%s%s"prependname)
            
entity_set_string(idd[0], EV_SZ_netnamename)
            
set_user_info(idd[0], "name"name)
        }
    }
}

update_db_name(idname[32]) {
    const 
LEN 32
    
const LONGER 128
    
new authid[LEN 1], query[LONGER 1]

    
get_user_authid(idauthidLEN)

    new 
Sql:sql
    
if (!connect(sql)) {
        
log_amx("Error - Couldn't connect to SQL db and thus couldn't update %s to it."authid)
        return
    }

    
format(queryLONGER"UPDATE `%s` SET `lastactivity` = ^"%d^", `lastusedname` = ^"%s^" WHERE `steamid` = ^"%s^""WWWREGTABLEget_systime(), nameauthid)

    new 
Result:result dbi_query(sqlquery)
    if (
result <= RESULT_FAILED) {
        new 
error[256]
        
dbi_error(sqlerror255)
        
log_amx("Error while quering SQL server for update of %s: %s"authiderror)
    }

    
dbi_close(sql)
}

bool:checkreg(authid[], name[]) {
    new 
Sql:sql
    
if (!connect(sql))
        return 
false

    
const LONGER 128
    
new query[LONGER 1]

    
format(queryLONGER"SELECT `regtime` FROM %s WHERE `steamid` = ^"%s^" LIMIT 1"WWWREGTABLEauthid)
    new 
Result:result dbi_query(sqlquery)
    if (
result <= RESULT_FAILED) {
        new 
error[256]
        
dbi_error(sqlerror255)
        
log_amx("Error while quering SQL server for %s, can't check registration: %s"authiderror)
        
dbi_close(sql)
        return 
false
    
}
    else if (
result == RESULT_NONE) {
        
dbi_close(sql)
        return 
false
    
}

    if (!
dbi_nextrow(result)) {
        
dbi_close(sql)
        return 
false // not regged
    
}

    new 
regtime[64]
    
dbi_field(result1regtime63)
    
format_time(regtimesizeof regtime 1"%y%m%d - %H:%M:%S"str_to_num(regtime))

    
server_print("[%s] %s registered at %s"PLUGINNAMEauthidregtime)

    
format(queryLONGER"UPDATE `%s` SET `lastactivity` = ^"%d^", `lastusedname` = ^"%s^" WHERE `steamid` = ^"%s^""WWWREGTABLEget_systime(), nameauthid)

    
dbi_free_result(result)

    
result dbi_query(sqlquery)
    if (
result <= RESULT_FAILED) {
        new 
error[256]
        
dbi_error(sqlerror255)
        
log_amx("Error while trying to update %s's (%s) reg info to SQL database. User is regged though."authiderror)
    }
    
dbi_close(sql)

    return 
true
}

bool:connect(&Sql:sql) {
    const 
LEN 128
    
new host[LEN], user[LEN], pass[LEN], db[LEN], error_msg[LEN]

    
get_cvar_string(CVAR_WHOSThostLEN 1)
    
get_cvar_string(CVAR_WUSERuserLEN 1)
    
get_cvar_string(CVAR_WPASSpassLEN 1)
    
get_cvar_string(CVAR_WDBdbLEN 1)

    
sql dbi_connect(hostuserpassdberror_msgLEN 1)

    if (!
sql) {
        
log_amx("ERROR - Can't connect to SQL db: %s"error_msg)
        return 
false
    
}

    return 
true
}

bool:createtable(&Sql:sql) {
    new 
query[1024] = "CREATE TABLE IF NOT EXISTS `%s` (`steamid` varchar(30) NOT NULL default '', `regtime` int(11) NOT NULL default '0', `lastactivity` int(11) default '0', `lastusedname` varchar(33) NOT NULL default '', PRIMARY KEY  (`steamid`)) TYPE=MyISAM;"
    
format(query1023queryWWWREGTABLE)

    new 
Result:result dbi_query(sqlquery)
    if (
result <= RESULT_FAILED) {
        new 
error[256]
        
dbi_error(sqlerror255)
        
log_amx("Error while trying to create tables: %s"error)
        return 
false
    
}

    return 
true
}



public 
plugin_init() {
    
register_plugin(PLUGINNAMEVERSIONAUTHOR)
    
register_cvar(CVAR_WHOST"localhost")
    
register_cvar(CVAR_WUSER"blist")
    
register_cvar(CVAR_WPASS"bpass")
    
register_cvar(CVAR_WDB"blacklist_23")

    
register_cvar(CVAR_KICKNONREGGED"1")
    
register_cvar(CVAR_REGURL"www.vsite.com")
    
register_cvar(CVAR_PREPEND"")

    new 
sqlcfgpath[128]
    
get_configsdir(sqlcfgpath127)
    
format(sqlcfgpath127"%s/sql.cfg"sqlcfgpath)
    
server_cmd("exec %s"sqlcfgpath)
    
server_exec()

    new 
Sql:sql
    
if (!connect(sql)) {
        
log_amx("Couldn't connect to SQL database at plugin_init! Pausing plugin.")
        
pause("a")
        return
    }
    else if (!
createtable(sql)) {
        
log_amx("Failed creating tables in SQL database at plugin_init! Pausing plugin.")
        
pause("a")
        return
    }
    else
        
server_print("[%s] Connected successfully to SQL database."PLUGINNAME)
    
dbi_close(sql)

liav319 is offline
[PUPPETS] Scooter
Member
Join Date: May 2009
Old 01-22-2013 , 07:23   Re: help blacklist system
Reply With Quote #4

As it seems like you deleted some lines, line 127 in your posted code would be this one:
Code:
entity_set_string(idd[0], EV_SZ_netname, name)
So which line is line 127 in your original file?
[PUPPETS] Scooter is offline
AngeIII
Senior Member
Join Date: Sep 2007
Location: Latvia
Old 01-22-2013 , 07:23   Re: help blacklist system
Reply With Quote #5

try to change
to this:
PHP Code:
public client_infochanged(id) {
    if (
is_user_bot(id) || is_user_connecting(id))
        return 
PLUGIN_CONTINUE;

    
get_user_name(idg_names[id], 31);
    
set_task(0.1"checkname"id);

    return 
PLUGIN_CONTINUE;

and this:
PHP Code:
public checkname(id) {
    if (
is_user_bot(id)) // Somehow some realbots slipped past the bot check in client_infochanged! :-(
        
return

    new 
name[32], prepend[32], prependlength
    get_user_name
(idname31)
    
get_cvar_string(CVAR_PREPENDprepend31)
    
prependlength strlen(prepend)
    if (
g_regged[id]) {
        
// Registered users shouldn't have names starting with CVAR_PREPEND
        // If length of set name is shorter than prepend string, user's name can't be prepend string. :-)
        
if (strlen(name) >= prependlength && equali(nameprependprependlength)) { // case insensitive...
            // Trim name prependlength chars from left
            
localtrim(name31prependlength)
            
entity_set_string(idEV_SZ_netnamename)
            
set_user_info(id"name"name)
            
client_print(idprint_console"Sorry, you can't use the public prefix ^"%s^"in your name because you are blacklisted!"prepend)
        }
        if (!
equal(nameg_names[id])) {
            
// Update lastusedname in db if it changed
            
update_db_name(idname)
        }
    }
    else {
        if (!
equal(prependnamestrlen(prepend))) {
            
//server_print("Forcing Pub: name on %s", name)
            
format(name31"%s%s"prependname)
            
entity_set_string(idEV_SZ_netnamename)
            
set_user_info(id"name"name)
        }
    }
    return;

and check for all errors. some of them should be fix

and yes, this is not "real" code, cause errors show other lines.
__________________
skype: pavle_ivanof
-=ThQ=-
PRIVATE SUPPORT = PAID SUPPORT

Last edited by AngeIII; 01-22-2013 at 07:24. Reason: and yes, I agree with Scooter, cause line 127 is ok..
AngeIII is offline
Send a message via Skype™ to AngeIII
AngeIII
Senior Member
Join Date: Sep 2007
Location: Latvia
Old 01-22-2013 , 07:28   Re: help blacklist system
Reply With Quote #6

and real problem is here:
PHP Code:

public client_authorized(id) {
    if (
is_user_bot(id))
        return 
PLUGIN_CONTINUE

    
const LEN 32

    
new authid[LEN 1], name[32]

    
get_user_authid(idauthidLEN)
    
get_user_name(idname31)

    
g_regged[id] = checkreg(authidname)

    if (
g_regged[id])
        
server_print("[%s] %s (%s) is registered."PLUGINNAMEnameauthid)
        if (
get_cvar_num(CVAR_KICKNONREGGED)) {
            new 
regurl[128]
            
get_cvar_string(CVAR_REGURLregurl127)
            
server_cmd("kick #%d your Steam ID %s is been blacklisted at %s ."get_user_userid(id), authidregurl
            else {
        
server_print("[%s] %s (%s) is not blacklisted."PLUGINNAMEnameauthid)
        }
    }

    return 
PLUGIN_CONTINUE

firstly invalid {}{{{}{{...

something like this will correct:
PHP Code:
public client_authorized(id)
{
    if (
is_user_bot(id))
        return 
PLUGIN_CONTINUE

    
new authid[33], name[32]
    
get_user_authid(idauthid32)
    
get_user_name(idname31)

    
g_regged[id] = checkreg(authidname)

    if (
g_regged[id])
    {
        
server_print("[%s] %s (%s) is registered."PLUGINNAMEnameauthid)
        if (
get_cvar_num(CVAR_KICKNONREGGED))
        {
            new 
regurl[128]
            
get_cvar_string(CVAR_REGURLregurl127)
            
server_cmd("kick #%d your Steam ID %s is been blacklisted at %s ."get_user_userid(id), authidregurl)
        }
        else
        {
                
server_print("[%s] %s (%s) is not blacklisted."PLUGINNAMEnameauthid)
        }
    }

    return 
PLUGIN_CONTINUE

__________________
skype: pavle_ivanof
-=ThQ=-
PRIVATE SUPPORT = PAID SUPPORT
AngeIII is offline
Send a message via Skype™ to AngeIII
liav319
Junior Member
Join Date: Mar 2009
Old 01-22-2013 , 07:47   Re: help blacklist system
Reply With Quote #7

[PUPPETS] Scooter
yes its the real code ,
i just deleted the lines that i tried to do , for the original code .


Quote:
Originally Posted by AngeIII View Post
and real problem is here:
PHP Code:

public client_authorized(id) {
    if (
is_user_bot(id))
        return 
PLUGIN_CONTINUE

    
const LEN 32

    
new authid[LEN 1], name[32]

    
get_user_authid(idauthidLEN)
    
get_user_name(idname31)

    
g_regged[id] = checkreg(authidname)

    if (
g_regged[id])
        
server_print("[%s] %s (%s) is registered."PLUGINNAMEnameauthid)
        if (
get_cvar_num(CVAR_KICKNONREGGED)) {
            new 
regurl[128]
            
get_cvar_string(CVAR_REGURLregurl127)
            
server_cmd("kick #%d your Steam ID %s is been blacklisted at %s ."get_user_userid(id), authidregurl
            else {
        
server_print("[%s] %s (%s) is not blacklisted."PLUGINNAMEnameauthid)
        }
    }

    return 
PLUGIN_CONTINUE

firstly invalid {}{{{}{{...

something like this will correct:
PHP Code:
public client_authorized(id)
{
    if (
is_user_bot(id))
        return 
PLUGIN_CONTINUE

    
new authid[33], name[32]
    
get_user_authid(idauthid32)
    
get_user_name(idname31)

    
g_regged[id] = checkreg(authidname)

    if (
g_regged[id])
    {
        
server_print("[%s] %s (%s) is registered."PLUGINNAMEnameauthid)
        if (
get_cvar_num(CVAR_KICKNONREGGED))
        {
            new 
regurl[128]
            
get_cvar_string(CVAR_REGURLregurl127)
            
server_cmd("kick #%d your Steam ID %s is been blacklisted at %s ."get_user_userid(id), authidregurl)
        }
        else
        {
                
server_print("[%s] %s (%s) is not blacklisted."PLUGINNAMEnameauthid)
        }
    }

    return 
PLUGIN_CONTINUE

thxx alot it work :]

Last edited by liav319; 01-22-2013 at 07:51.
liav319 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 20:38.


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