AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   MySQL if problem (https://forums.alliedmods.net/showthread.php?t=116782)

Stulle 01-26-2010 15:36

MySQL if problem
 
Hi, i like to check if a player ist already at the MySQL database when hes connecting.

At the server_print i can see that all is fine (shows the same id's), but at the if loop it dosen't work.

PHP Code:

public client_connect(id)
{
    new 
Sql:mysql dbi_connect(MYSQL_DATA[0], MYSQL_DATA[1], MYSQL_DATA[2], MYSQL_DATA[3])

    new 
connect_steamid[35]
    
get_user_authid(id,connect_steamid,35)

    new 
steam_check dbi_query(mysql"SELECT steamid FROM stats WHERE steamid = '%s'"connect_steamid)
    
server_print("%s - %s"steam_checkconnect_steamid)
    if(
connect_steamid[0] == steam_check) {
        
server_print("ID vorhanden %s",connect_steamid[0])
    }



Exolent[jNr] 01-26-2010 15:53

Re: MySQL if problem
 
It would be much better to use client_authorized( ) since that is when the client's SteamID is authorized with the server.

Code:
public client_authorized(id) {     new Sql:mysql = dbi_connect(MYSQL_DATA[0], MYSQL_DATA[1], MYSQL_DATA[2], MYSQL_DATA[3])     new connect_steamid[35]     get_user_authid(id,connect_steamid,35)     new rows, Result:ret = dbi_query2(mysql, rows, "SELECT steamid FROM stats WHERE steamid = '%s'", connect_steamid)     if(rows > 0) {         // exists     }         dbi_free_result(ret)         dbi_close(mysql) }

Also, read up on how the functions work and what you can do:
http://www.amxmodx.org/funcwiki.php?go=module&id=5

Stulle 01-26-2010 16:11

Re: MySQL if problem
 
ah ok, thanks that works fine :)


All times are GMT -4. The time now is 07:22.

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