AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Whats wrong with this [DBI] (https://forums.alliedmods.net/showthread.php?t=53537)

Styles 04-05-2007 23:04

Whats wrong with this [DBI]
 
Code:

public client_putinserver(id)
{
        if(dbc == SQL_FAILED)
        {
                return PLUGIN_HANDLED
        }
        new authid[33], query[256];
        get_user_authid(id, authid, 32)
        format(query,255,"SELECT steamid FROM bmjailmod")
        result = dbi_query(dbc,"%s",query)
        if(result <= RESULT_NONE && equali(authid, "STEAM_ID_PENDING"))
        {
                client_print(0, print_chat, "[Jail Mod Debug] Trying to add %s", authid);
                format(query,255,"INSERT INTO bmjailmod (steamid,flag) VALUES('%s', '0')",authid)
                dbi_query(dbc,"%s",query)
                client_print(id,print_console,"%s",query)
                server_print("%s",query)
        }
        dbi_free_result(result)
        return PLUGIN_CONTINUE;
}

I tryed Returning it handled it doesn't work eathier.

This only adds the FIRST person in the server. whY?

Nican 04-05-2007 23:33

Re: Whats wrong with this [DBI]
 
i like sqlx better

PHP Code:

new errnumerror[128]
mysql SQL_Connect(dbtupleerrnumerror128)
if (!
mysql)
    return 
PLUGIN_HANDLED
    
new authid[33], error[256]
get_user_authid(idauthid32)
new 
Handle:que SQL_PrepareQuery(mysql,"SELECT steamid FROM bmjailmod WHERE steamid = '%s'",authid)


//If it could not execute query
if(!SQL_Execute(que)){
    
SQL_QueryError(que,error,256)
    
log_amx("Error: %s",error)
    return 
PLUGIN_HANDLED
}

//If could find anyone, insert it
if(SQL_AffectedRows(que) == && !equali(authid"STEAM_ID_PENDING")){
    new 
Handle:query SQL_PrepareQuery(mysql,"INSERT INTO bmjailmod (steamid,flag) VALUES('%s', '0')",authid)

    if(!
SQL_Execute(que)){
        
SQL_QueryError(query,error,256)
        
log_amx("Error: Could not insert user: %s",error)
    } else { 
        
log_amx("%s succefuly inserted",authid)
        
SQL_FreeHandle(query)
    }
}
//Free handle query
SQL_FreeHandle(que)
//free mysql handle
SQL_FreeHandle(que


Styles 04-06-2007 00:15

Re: Whats wrong with this [DBI]
 
Please use DBI because TS uses that.

Drak 04-06-2007 00:37

Re: Whats wrong with this [DBI]
 
TS doesn't 'use' anything. He just switched to a different module, for whatever reason.
Also, am I reading this wrong?
Code:
if(result <= RESULT_NONE && equali(authid, "STEAM_ID_PENDING"))

Doesn't this mean if you're SteamID is pending, let's continue on.. Which doesn't make much sence

Try changing it with
Code:
if(result <= RESULT_NONE && !equali(authid, "STEAM_ID_PENDING"))

(Not Equal) ...

Styles 04-06-2007 01:52

Re: Whats wrong with this [DBI]
 
o hahaha nice catch, wasnt paying attention i guess :P
Thanks.

Styles 04-06-2007 02:19

Re: Whats wrong with this [DBI]
 
Still not working :( shit It doesn't allways add people.

Drak 04-06-2007 02:29

Re: Whats wrong with this [DBI]
 
Uhh, errors? Is it returning anything?
Code:
public client_putinserver(id) {     if(dbc == SQL_OK) return PLUGIN_HANDLED             new authid[35],query[256];     get_user_authid(id, authid, 34)     format(query,255,"SELECT steamid FROM bmjailmod WHERE steamid = '%s'",authid)     result = dbi_query(dbc,"%s",query)     if(!result == RESULT_NONE && !equali(authid, "STEAM_ID_PENDING"))     {         client_print(0, print_chat, "[Jail Mod Debug] Trying to add %s", authid);         format(query,255,"INSERT INTO bmjailmod (steamid,flag) VALUES('%s', '0')",authid)         dbi_query(dbc,"%s",query)         client_print(id,print_console,"%s",query)         server_print("%s",query)     }     dbi_free_result(result)     return PLUGIN_CONTINUE; }

You should also look what Nican did, I basically did just that. And like I said, you're returning stuff:
"client_print(0, print_chat, "[Jail Mod Debug] Trying to add %s", authid);"
Is it printing out everyones steamid that joins?

teame06 04-06-2007 02:31

Re: Whats wrong with this [DBI]
 
Code:
if(result <= RESULT_NONE && equali(authid, "STEAM_ID_PENDING"))

You should not be checking the results like that.

Code:
    /* Error checking correctly so you can log stuff */     if(result == RESULT_FAILED)     {         /* Log saying your query failed */         return PLUGIN_CONTINUE;     } else if(result == RESULT_NONE) {         /* No data return from query */         return PLUGIN_CONTINUE;     }     /* Then retrieve the data */     /* or         If you do not care for logging then do */     if(result <= RESULT_NONE)     {         /* The query failed or no data from query */         return PLUGIN_CONTINUE     }     /* Do rest of the code to retrieve data from query*/

Styles 04-06-2007 03:10

Re: Whats wrong with this [DBI]
 
Okay well I have a:
Code:

set_task(1.0,"check_int",0,"",0,"b")
in Plugin_init

Then that runs:
Code:

public check_int()
{
        new players[32], num;
        get_players(players,num);
       
        for( new i = 0;  i < 32; i++ )
        {
                check_jail(players[i]);
                //set_user_maxspeed(i, Float:320);
        }
        return PLUGIN_HANDLED
}

Then that runs:
Code:

if(flagNum == 1) {
                get_user_aiming(id,entid,entbody,200)
                if(get_distance(origin,jailone) <= 100.0)
                        set_user_origin(entid,jailone)
        } else if (flagNum == 2) {

I don't know if thats even working right. Its not teleporting them back in every time.


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

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