AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting (https://forums.alliedmods.net/forumdisplay.php?f=107)
-   -   MySQL Get Entry and query it (https://forums.alliedmods.net/showthread.php?t=266249)

Fireflasch7 07-13-2015 14:58

MySQL Get Entry and query it
 
Hi,
i have a question how to Query a simpler int in a MySQL database (0,1) and then query it in an If-loop ob it is 1? I tryed it but it give a lot of Args errors. Can you pla help me?
Regards Fireflasch7

RedSword 07-13-2015 15:02

Re: MySQL Get Entry and query it
 
Could you reformulate your question ? an "If-loop" sound strange to me. Also why don't you show us the code you have until this point ? That might clarify your question.

ThatOneGuy 07-13-2015 22:53

Re: MySQL Get Entry and query it
 
Perhaps he meant a "while" loop?...

@ OP: Here is a basis for starting with SQL: https://wiki.alliedmods.net/SQL_(SourceMod_Scripting)

Fireflasch7 07-14-2015 11:01

Re: MySQL Get Entry and query it
 
here this is my code
but it doent Work
https://forums.alliedmods.net/data:i...ooooAKKKKAP//Z
#include <sourcemod>
#include <cstrike>

new Handle:DB = INVALID_HANDLE;
Handle query = INVALID_HANDLE;
//new String:sAuth[20];

#define PLUGIN_VERSION "1.1.2.0"

public Plugin:myinfo =
{
name = "VIP Tag",
author = "Goof",
description = "Vip Tag",
version = PLUGIN_VERSION,
url = ""
}

public OnPluginStart()
{
new String:Error[70];
DB = SQL_Connect("VIP", true, Error, sizeof(Error));
if(DB == INVALID_HANDLE)
{
PrintToServer("Cannot connect to MySQL Database %s", Error);
CloseHandle(DB);
} else {
PrintToServer("Successfuly Connected to VIP");
}

}


public OnClientConnected(client)
{
query = SQL_Query(DB, "SELECT Enable FROM Tag WHERE steamid = 'STEAM_1:0:60899418'");
if (query == INVALID_HANDLE)
{
new String:error[255];
SQL_GetError(DB, error, sizeof(error));
PrintToServer("Failed to query (error: %s)", error)
} else if(query == 1)
{
CS_SetClientClanTag(client, "✰VIP✰");
}
}

Fireflasch7 07-14-2015 11:14

Re: MySQL Get Entry and query it
 
here this is my code
but it doent Work
https://forums.alliedmods.net/data:i...ooooAKKKKAP//Z
#include <sourcemod>
#include <cstrike>

new Handle:DB = INVALID_HANDLE;
Handle query = INVALID_HANDLE;
//new String:sAuth[20];

#define PLUGIN_VERSION "1.1.2.0"

public Plugin:myinfo =
{
name = "VIP Tag",
author = "Goof",
description = "Vip Tag",
version = PLUGIN_VERSION,
url = ""
}

public OnPluginStart()
{
new String:Error[70];
DB = SQL_Connect("VIP", true, Error, sizeof(Error));
if(DB == INVALID_HANDLE)
{
PrintToServer("Cannot connect to MySQL Database %s", Error);
CloseHandle(DB);
} else {
PrintToServer("Successfuly Connected to VIP");
}

}


public OnClientConnected(client)
{
query = SQL_Query(DB, "SELECT Enable FROM Tag WHERE steamid = 'STEAM_1:0:60899418'");
if (query == INVALID_HANDLE)
{
new String:error[255];
SQL_GetError(DB, error, sizeof(error));
PrintToServer("Failed to query (error: %s)", error)
} else if(query == 1)
{
CS_SetClientClanTag(client, "✰VIP✰");
}
}

R1KO 07-14-2015 12:55

Re: MySQL Get Entry and query it
 
PHP Code:

public OnClientPostAdminCheck(client)
{
    
decl String:sQuery[256], String:sAuth[32];
    
GetClientAuthString(clientsAuthsizeof(sAuth));
    
FormatEx(sQuerysizeof(sQuery), "SELECT Enable FROM Tag WHERE steamid = '%s'"sAuth);
    
SQL_TQuery(DBSQL_LoadClientsQueryGetClientUserId(client));
}

public 
SQL_LoadClient(Handle:hOwnerHandle:hQuery, const String:sError[], any:UserID)
{
    if (
hQuery == INVALID_HANDLE || sError[0])
    {
        
LogError("SQL_LoadClient: %s"sError);
    }
    
    new 
iClient GetClientOfUserId(UserID);
    if ( 
iClient && SQL_FetchRow(hQuery))
    {
        if(
SQL_FetchInt(hQuery0))
        {
            
CS_SetClientClanTag(client"✰VIP✰");
        }        
    } 



Fireflasch7 07-15-2015 07:15

Re: MySQL Get Entry and query it
 
Thank you for you help but i get the following Error:
Native "ReadPackCell" reported: Invalid data pack handle 2 (error 7)
L 07/15/2015 - 13:07:25: [SM] Displaying call stack trace for plugin "VIPTag.smx":
L 07/15/2015 - 13:07:25: [SM] [0] Line 52, C:\Users\Max\Desktop\csgo\sourcemod-1.7.2-windows\addons\sourcemod\scripting\VIPTag.sp: :SQL_LoadClient()

R1KO 07-15-2015 13:50

Re: MySQL Get Entry and query it
 
fixed https://forums.alliedmods.net/showpo...08&postcount=6


All times are GMT -4. The time now is 11:27.

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