Raised This Month: $32 Target: $400
 8% 

can;t insert in mysql


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
alex2001
Member
Join Date: May 2019
Old 06-04-2019 , 13:14   can;t insert in mysql
Reply With Quote #1

Code:
#define DEBUG
#define PLUGIN_AUTHOR "Alex"
#define PLUGIN_VERSION "1.00"

#include <sourcemod>
#include <sdktools>
#include <cstrike>
//#include <sdkhooks>

#pragma semicolon 1
#pragma newdecls required

public Plugin myinfo =  {
	name = "BattlePass", 
	author = PLUGIN_AUTHOR, 
	description = "BattlePass plugin :)", 
	version = PLUGIN_VERSION, 
};

public void OnPluginStart() {
	char error[255];
	Database db = SQL_Connect("battlepass", true, error, sizeof(error));
	
	if (db == null)
	{
		PrintToServer("Could not connect: %s", error);
	}
	else
	{
		PrintToServer("Conectare reusita");
	}
	RegAdminCmd("sm_give_bp", CmdBp, ADMFLAG_ROOT, "");
}

public Action CmdBp(int client, int args) {
	if (args < 1) {
		ReplyToCommand(client, "Foloseste : sm_give_bp <nume>");
		return Plugin_Handled;
	}
	
	char arg1[32];
	GetCmdArg(1, arg1, 32);
	
	char name[32];
	GetClientName(client, name, 32);
	
	char query[200];
	PrintToChat(client, "HH");
	Format(query, 200, "INSERT INTO 'battlepass' (Test) VALUES ('%i')", sizeof(arg1));
	
	return Plugin_Handled;
}
but if in game use sm_give_bp name.. in tabel dosent appear sizeof(arg1)
alex2001 is offline
8guawong
AlliedModders Donor
Join Date: Dec 2013
Location: BlackMarke7
Old 06-04-2019 , 13:28   Re: can;t insert in mysql
Reply With Quote #2

Quote:
Originally Posted by alex2001 View Post
Code:
#define DEBUG
#define PLUGIN_AUTHOR "Alex"
#define PLUGIN_VERSION "1.00"

#include <sourcemod>
#include <sdktools>
#include <cstrike>
//#include <sdkhooks>

#pragma semicolon 1
#pragma newdecls required

public Plugin myinfo =  {
	name = "BattlePass", 
	author = PLUGIN_AUTHOR, 
	description = "BattlePass plugin :)", 
	version = PLUGIN_VERSION, 
};

public void OnPluginStart() {
	char error[255];
	Database db = SQL_Connect("battlepass", true, error, sizeof(error));
	
	if (db == null)
	{
		PrintToServer("Could not connect: %s", error);
	}
	else
	{
		PrintToServer("Conectare reusita");
	}
	RegAdminCmd("sm_give_bp", CmdBp, ADMFLAG_ROOT, "");
}

public Action CmdBp(int client, int args) {
	if (args < 1) {
		ReplyToCommand(client, "Foloseste : sm_give_bp <nume>");
		return Plugin_Handled;
	}
	
	char arg1[32];
	GetCmdArg(1, arg1, 32);
	
	char name[32];
	GetClientName(client, name, 32);
	
	char query[200];
	PrintToChat(client, "HH");
	Format(query, 200, "INSERT INTO 'battlepass' (Test) VALUES ('%i')", sizeof(arg1));
	
	return Plugin_Handled;
}
but if in game use sm_give_bp name.. in tabel dosent appear sizeof(arg1)
u only format the query

i don't even see where you try to insert into mysql

read https://wiki.alliedmods.net/SQL_(SourceMod_Scripting)
__________________
8guawong is offline
alex2001
Member
Join Date: May 2019
Old 06-04-2019 , 13:44   Re: can;t insert in mysql
Reply With Quote #3

can you help me.. i already write.but where is "INSERT" in your link..
i am begginer..

this is ok?
char query[200];
Format(query, 200, "INSERT INTO 'bptabel' (Test) VALUES ('%i')", sizeof(arg1));

SQL_LockDatabase(db);
DBResultSet queryH = SQL_Query(db, query);
if (queryH != null) {
PrintToChat(client, "SUCCES");
}
SQL_UnlockDatabase(db);
delete(queryH);

Last edited by alex2001; 06-04-2019 at 14:16.
alex2001 is offline
8guawong
AlliedModders Donor
Join Date: Dec 2013
Location: BlackMarke7
Old 06-04-2019 , 14:30   Re: can;t insert in mysql
Reply With Quote #4

Quote:
Originally Posted by alex2001 View Post
can you help me.. i already write.but where is "INSERT" in your link..
i am begginer..

this is ok?
char query[200];
Format(query, 200, "INSERT INTO 'bptabel' (Test) VALUES ('%i')", sizeof(arg1));

SQL_LockDatabase(db);
DBResultSet queryH = SQL_Query(db, query);
if (queryH != null) {
PrintToChat(client, "SUCCES");
}
SQL_UnlockDatabase(db);
delete(queryH);
yes but use threading https://wiki.alliedmods.net/SQL_(Sou...ing)#Threading
__________________
8guawong is offline
alex2001
Member
Join Date: May 2019
Old 06-04-2019 , 14:35   Re: can;t insert in mysql
Reply With Quote #5

no.. dont unterstand...can you give me 1 example
alex2001 is offline
alex2001
Member
Join Date: May 2019
Old 06-04-2019 , 17:11   Re: can;t insert in mysql
Reply With Quote #6

Quote:
public Action CmdBp(int client, int args) {
char arg1[32];
bool target;

if (args < 1) {
ReplyToCommand(client, "Foloseste : sm_give_bp <nume>");
return Plugin_Handled;
}

GetCmdArg(1, arg1, sizeof(arg1));

target = FindTarget(client, arg1);



PrintToChat(client, "Nume %i", target);
if (target == -1) {
ReplyToCommand(client, "Jucatorul nu exista");
return Plugin_Handled;
}
else
ReplyToCommand(client, "Jucatorul exista");

char query[200];
Format(query, 200, "INSERT INTO bptabel (Test,nume) VALUES ('%i','%s')", 1, arg1);
DBResultSet queryH = SQL_Query(DB, query);

if (queryH != INVALID_HANDLE) {
ReplyToCommand(client, "succes");
}
else
ReplyToCommand(client, "FAIL");

return Plugin_Handled;
}
if target==-1 .. dosent replay nothing..just command dosent exit

] sm_give_bp alex32
Unknown command: sm_give_bp

Last edited by alex2001; 06-04-2019 at 17:12.
alex2001 is offline
Reply


Thread Tools
Display Modes

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 11:03.


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