Okey, lets jump right in to it.
Im kinda new to coding overall.
(made some minecraft bukkit plugins(java) and also some kind of 2d java game about 6-8 moths ago.)
And i started trying with sourcepawn about 1 month ago and after searching the forum, api and wiki, and
whatching some youtube tuts I desided to ask for help.
I think it is pretty simple,
when client connect it checks if his steamid is in the database and if it is he gets the 2 admin flags, if not it checks if he got the 2 flags and if he do it removes them.
(It's for Counter-Strike: Source)
Here is what i currently got:
PHP Code:
#include <sourcemod>
#define PLUGIN_VERSION "1.0"
new Handle:DB = INVALID_HANDLE;
public Plugin:myinfo = {
name = "VipReload",
author = "Mooni",
description = "Vip Reload Plugin",
version = PLUGIN_VERSION,
url = "www.ggaming.se"
};
public OnPluginStart()
{
new String:Error[70];
DB = SQL_Connect("VipPlugin", true, Error, sizeof(Error));
if(DB == INVALID_HANDLE)
{
PrintToServer("[ERROR] Cannot connect to MySQL Server: %s", Error);
CloseHandle(DB);
}
else
{
PrintToServer("Connection Successful");
}
}
public OnClientConnect(client)
{
//I think something like: if(steamid == DBsteamid)
/**
new String:steamid[32];
GetClientAuthString(client, steamid, 32);
if(steamid == hQuery)
{
SetAdminFlag(steamid, ADMFLAG_CUSTOM6);
SetAdminFlag(steamid, ADMFLAG_RESERVATION);
}
**/
}
GetSomeInfo(Handle:DB, const String:name[], client)
{
new Handle:hQuery
new String:query[200]
/* Create enough space to make sure our string is quoted properly */
new buffer_len = strlen(name) * 2 + 1
new String:new_name[buffer_len]
/* Ask the SQL driver to make sure our string is safely quoted */
SQL_QuoteString(DB, name, new_name, buffer_len);
/* Build the query */
Format(query, sizeof(query), "SELECT steamid FROM viplist");
/* Execute the query */
if ((hQuery = SQL_Query(query)) == INVALID_HANDLE)
{
return 0
}
/* Get some info here */
DBsteamid = SQL_FetchRow(hQuery)
CloseHandle(hQuery)
}
And im pretty sure i got the databases.cfg setup right but here it is anyway:
Code:
"VipPlugin"
{
"driver" "default"
"host" "my host ip"
"database" "my db"
"user" "my db user"
"pass" "my db user pw"
//"timeout" "0"
"port" "3306"
}