AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Need Some Help With My Plugin (https://forums.alliedmods.net/showthread.php?t=48138)

umarsa 12-05-2006 17:08

Need Some Help With My Plugin
 
1st of all if you are goind to tell me to use a plugin already made then dont post here because i dont want another one.

I have made a piece of code that when people with my clan tag come in it checks them to see if they have a fake tag.
It Just doesnt work..

Code:


#include <amxmodx>
#include <amxmisc>
#include <sqlx>
 
#define PLUGIN "Name Force And Tag Protection"
#define VERSION "1.0"
#define AUTHOR "umarsa"

new Handle:g_SqlTuple
new g_Error[512]
 
public plugin_init()
{
// ----------------------------------Register Things------------------------------------------------
        register_plugin(PLUGIN, VERSION, AUTHOR)       
        register_cvar("sv_nftp", "1")
        register_clcmd("say showinfo", "showinfo")
        register_clcmd("steamid", "showinfo")
        register_clcmd("myname", "showinfo")
        register_clcmd("myip", "showinfo")
        register_clcmd("muuserid", "showinfo")
// -------------------------------------------------------------------------------------------------

// --------------------------------SQL Connect------------------------------------------------------
        g_SqlTuple = SQL_MakeDbTuple("localhost","uwc3_user","noob","amx")
        new ErrorCode,Handle:SqlConnection = SQL_Connect(g_SqlTuple,ErrorCode,g_Error,511)
        if(SqlConnection == Empty_Handle)
        set_fail_state(g_Error) 
        new Handle:Queries[3]
        Queries[0] = SQL_PrepareQuery(SqlConnection,"CREATE TABLE IF NOT EXISTS `set_names` (`steamid` VARCHAR( 17 ) NOT NULL ,`g_name` VARCHAR( 23 ) NOT NULL ) TYPE = MYISAM COMMENT = 'Used By A Plugin In A HLDS Server';")
        Queries[1] = SQL_PrepareQuery(SqlConnection,"CREATE TABLE IF NOT EXISTS `set_names` (`steamid` VARCHAR( 17 ) NOT NULL ,`g_name` VARCHAR( 23 ) NOT NULL ) TYPE = MYISAM COMMENT = 'Used By A Plugin In A HLDS Server';")
        Queries[2] = SQL_PrepareQuery(SqlConnection,"CREATE TABLE IF NOT EXISTS `set_names` (`steamid` VARCHAR( 17 ) NOT NULL ,`g_name` VARCHAR( 23 ) NOT NULL ) TYPE = MYISAM COMMENT = 'Used By A Plugin In A HLDS Server';") 
        for(new Count;Count < 3;Count++)
        {
        if(!SQL_Execute(Queries[Count]))
        {
        SQL_QueryError(Queries[Count],g_Error,511)
        set_fail_state(g_Error)
        }

        SQL_FreeHandle(Queries[Count])
        }
 
        SQL_FreeHandle(SqlConnection) 
// -------------------------------------------------------------------------------------------------
}
 
public client_putinserver(id)
{
        check_tag(id)
}

public client_infochanged(id)
{
        check_tag(id)
}
               
public check_tag(id)
{             
        if(!get_cvar_num("sv_nftp"))
        return PLUGIN_HANDLED
       
        if(is_user_bot(id))
        return PLUGIN_HANDLED

       
        new BaseDir[64], File[222], data[222], line, stxtsize, authid[34], name[44]
        get_configsdir(BaseDir, 221)
        get_user_authid(id, authid, 33)
        get_user_name(id, name, 43)
        new userid = get_user_userid(id)
       
        format(File, 221, "%s/tag.cfg", BaseDir)
        server_print("Base Directory: %s", BaseDir)
       
        if (!file_exists(File)) {
                log_message("[NFTP] Tag Protection File Not Found")
                server_print("[NFTP] Shutting Down Due To No File Found")
                return PLUGIN_HANDLED
        }
       
        while(read_file(File,line++,data,221,stxtsize))
       
        if (containi(name[43], "[CcC] "))
        {
        if (containi(data[221], authid))
        {
        client_print(id, print_console, "[NFTP] Your Authid Found In Database, You Are Allowed The [CcC] Tag In Your Name")
        force_name(id)
        return PLUGIN_HANDLED
        } else {
        force_name(id)
        client_print(0, print_console, "[NFTP] Fake Tag Triggered By %s. Not Found In Database. Not In Clan", name)
        client_print(id, print_console, "")
        client_print(id, print_console, "[NFTP] (N)ame (F)orce & (T)ag (P)rotector")
        client_print(id, print_console, "You have been kick due to the fact you are NOT in the clan. If you are in the clan this may be a mistake as you are not in the database. Go to the forums and post your steamid with your ingame name.")
        client_print(id, print_console, "In the time that it will take for you to be identified you are NOT in the clan so change your name and play on the server.")
        client_print(id, print_console, "Thank You, Have A Good Day.")
        client_print(id, print_console, "")
        server_cmd("kick #%s  Read Your Console For Info Why", userid)
        return PLUGIN_HANDLED
        }
        }
       
        if (containi(name[43], "[CcC]"))
        {
        if (containi(data[221], authid))
        {
        client_print(id, print_console, "[NFTP] Your Authid Found In Database, You Are Allowed The [CcC] Tag In Your Name")
        force_name(id)
        return PLUGIN_HANDLED
        } else {
        force_name(id)
        client_print(0, print_console, "[NFTP] Fake Tag Triggered By %s. Not Found In Database. Not In Clan", name)
        client_print(id, print_console, "")
        client_print(id, print_console, "[NFTP] (N)ame (F)orce & (T)ag (P)rotector")
        client_print(id, print_console, "You have been kick due to the fact you are NOT in the clan. If you are in the clan this may be a mistake as you are not in the database. Go to the forums and post your steamid with your ingame name.")
        client_print(id, print_console, "In the time that it will take for you to be identified you are NOT in the clan so change your name and play on the server.")
        client_print(id, print_console, "Thank You, Have A Good Day.")
        client_print(id, print_console, "")
        server_cmd("kick #%d  Read Your Console For Info Why", userid)
        return PLUGIN_HANDLED
        }
        }
       
        return PLUGIN_HANDLED
}

public showinfo(id)
{
        new authid[32], name[44], ip[33]
        new userid = get_user_userid(id)
        get_user_authid(id,authid,31)
        get_user_name(id, name, 43)
        get_user_ip(id, ip, 32)
        client_print(id, print_console, "Your STEAMID Is: ^"%s^"", authid)
        client_print(id, print_console, "Your Name Is: ^"%s^"", name)
        client_print(id, print_console, "Your Ip Is: ^"%s^"", ip)
        client_print(id, print_console, "Your Userid Is: ^"#%d^"", userid)
       
        return PLUGIN_HANDLED
}

public force_name(id)

        if(is_user_bot(id))
        return PLUGIN_HANDLED

        new ErrorCode,Handle:SqlConnection = SQL_Connect(g_SqlTuple,ErrorCode,g_Error,511)
        if(g_SqlTuple == Empty_Handle)
        set_fail_state(g_Error)
        new authid[32]
        get_user_authid(id, authid, 31)
        new Handle:Query = SQL_PrepareQuery(SqlConnection,"SELECT * FROM set_names WHERE steamid='%s'", authid)
        if(!SQL_Execute(Query))
        {
        SQL_QueryError(Query,g_Error,511)
        set_fail_state(g_Error)
        }
       
       
        while(SQL_MoreResults(Query))
        {
        new name[33]
        get_user_name(id, name, 32)
        new tag[256]
        SQL_ReadResult(Query, 1, tag, 255)
        set_user_info(id, "name", tag)


        SQL_NextRow(Query)
        }
       
        SQL_FreeHandle(Query)
        SQL_FreeHandle(SqlConnection)
}

public plugin_end()
    SQL_FreeHandle(g_SqlTuple)

Now it stopped working with that code above there but when it did not check their name for the tag it worked perfectly but it would kick ANYONE that was not in my sql.
This was my code with out the checking name :
All the same but this public function diffrent:
Code:


public check_tag(id)
{             
        if(!get_cvar_num("sv_nftp"))
        return PLUGIN_HANDLED
       
        if(is_user_bot(id))
        return PLUGIN_HANDLED

       
        new BaseDir[64], File[222], data[222], line, stxtsize, authid[34], name[44]
        get_configsdir(BaseDir, 221)
        get_user_authid(id, authid, 33)
        get_user_name(id, name, 43)
        new userid = get_user_userid(id)
       
        format(File, 221, "%s/tag.cfg", BaseDir)
       
        if (!file_exists(File)) {
                log_message("[NFTP] Tag Protection File Not Found")
                server_print("[NFTP] Shutting Down Due To No File Found")
                return PLUGIN_HANDLED
        }
       
        while(read_file(File,line++,data,221,stxtsize))
       
        if (containi(data[221], authid))
        {
        client_print(id, print_console, "[NFTP] Your Authid Found In Database, You Are Allowed The [CcC] Tag In Your Name")
        force_name(id)
        return PLUGIN_HANDLED
        } else {
        force_name(id)
        client_print(0, print_console, "[NFTP] Fake Tag Triggered By %s. Not Found In Database. Not In Clan", name)
        client_print(id, print_console, "")
        client_print(id, print_console, "[NFTP] (N)ame (F)orce & (T)ag (P)rotector")
        client_print(id, print_console, "You have been kick due to the fact you are NOT in the clan. If you are in the clan this may be a mistake as you are not in the database. Go to the forums and post your steamid with your ingame name.")
        client_print(id, print_console, "In the time that it will take for you to be identified you are NOT in the clan so change your name and play on the server.")
        client_print(id, print_console, "Thank You, Have A Good Day.")
        client_print(id, print_console, "")
        server_cmd("wait;wait;wait;wait;wait;kick #%s  Read Your Console For Info Why", userid)
        return PLUGIN_HANDLED
        }
       
        if (containi(data[221], authid))
        {
        client_print(id, print_console, "[NFTP] Your Authid Found In Database, You Are Allowed The [CcC] Tag In Your Name")
        force_name(id)
        return PLUGIN_HANDLED
        } else {
        force_name(id)
        client_print(0, print_console, "[NFTP] Fake Tag Triggered By %s. Not Found In Database. Not In Clan", name)
        client_print(id, print_console, "")
        client_print(id, print_console, "[NFTP] (N)ame (F)orce & (T)ag (P)rotector")
        client_print(id, print_console, "You have been kick due to the fact you are NOT in the clan. If you are in the clan this may be a mistake as you are not in the database. Go to the forums and post your steamid with your ingame name.")
        client_print(id, print_console, "In the time that it will take for you to be identified you are NOT in the clan so change your name and play on the server.")
        client_print(id, print_console, "Thank You, Have A Good Day.")
        client_print(id, print_console, "")
        server_cmd("wait;wait;wait;wait;wait;kick #%d  Read Your Console For Info Why", userid)
        return PLUGIN_HANDLED
        }
       
        return PLUGIN_HANDLED
}

Can someone help me?

dutchmeat 12-05-2006 17:40

Re: Need Some Help With My Plugin
 
First of all, do NOT use 'server_cmd("wait;wait;wait;wait;wait;kick'
I once tried it in a mod, and it really stopped the timer :).
You should try 'set_task' instead.
Also, you should check if the playername is EXACTLY like the one in the file, else you could do something like this:

original user: [mytag] owner
fake user: [mytag] ownerCookies?

umarsa 12-05-2006 17:41

Re: Need Some Help With My Plugin
 
Oh, the wait wait wait thing was a test i forgot to take that out and i know to use set_task


All times are GMT -4. The time now is 06:56.

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