Raised This Month: $51 Target: $400
 12% 

MySQL Get Entry and query it


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Fireflasch7
Junior Member
Join Date: Feb 2015
Old 07-13-2015 , 14:58   MySQL Get Entry and query it
Reply With Quote #1

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
Fireflasch7 is offline
RedSword
SourceMod Plugin Approver
Join Date: Mar 2006
Location: Quebec, Canada
Old 07-13-2015 , 15:02   Re: MySQL Get Entry and query it
Reply With Quote #2

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.
__________________
My plugins :
Red Maze
Afk Bomb
RAWR (per player/rounds Awp Restrict.)
Kill Assist
Be Medic

You can also Donate if you appreciate my work
RedSword is offline
ThatOneGuy
Veteran Member
Join Date: Jul 2012
Location: Oregon, USA
Old 07-13-2015 , 22:53   Re: MySQL Get Entry and query it
Reply With Quote #3

Perhaps he meant a "while" loop?...

@ OP: Here is a basis for starting with SQL: https://wiki.alliedmods.net/SQL_(SourceMod_Scripting)
__________________
ThatOneGuy is offline
Fireflasch7
Junior Member
Join Date: Feb 2015
Old 07-14-2015 , 11:01   Re: MySQL Get Entry and query it
Reply With Quote #4

here this is my code
but it doent Work

#include <sourcemod>
#include <cstrike>

new HandleB = 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 is offline
Fireflasch7
Junior Member
Join Date: Feb 2015
Old 07-14-2015 , 11:14   Re: MySQL Get Entry and query it
Reply With Quote #5

here this is my code
but it doent Work

#include <sourcemod>
#include <cstrike>

new HandleB = 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 is offline
R1KO
Member
Join Date: Sep 2013
Old 07-14-2015 , 12:55   Re: MySQL Get Entry and query it
Reply With Quote #6

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✰");
        }        
    } 


Last edited by R1KO; 07-15-2015 at 13:49.
R1KO is offline
Send a message via Skype™ to R1KO
Fireflasch7
Junior Member
Join Date: Feb 2015
Old 07-15-2015 , 07:15   Re: MySQL Get Entry and query it
Reply With Quote #7

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()
Fireflasch7 is offline
R1KO
Member
Join Date: Sep 2013
Old 07-15-2015 , 13:50   Re: MySQL Get Entry and query it
Reply With Quote #8

fixed https://forums.alliedmods.net/showpo...08&postcount=6
R1KO is offline
Send a message via Skype™ to R1KO
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 09:16.


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