Guessing it's because you didn't change "SQL_TConnect(SQLCallback_Connect, "ckSurf");" to connect toy our database?
Edit: You also have a few more errors. Here is how it should look:
Spoiler
PHP Code:
#pragma semicolon 1
#define PLUGIN_VERSION "0.1"
public Plugin:myinfo = { name = "ckSurf Kicker", author = "DeweY", version = PLUGIN_VERSION, description = "Kicks clients with 1000 points or more.", url = "http://Omegagaming.org/" };
Handle g_hDatabase = null;
public void OnPluginStart() { SQL_TConnect(SQLCallback_Connect, "ckSurf"); }
public SQLCallback_Connect(Handle owner, Handle hndl, const char[] error, any data) { if (hndl == null) { SetFailState("Error connecting to database. %s", error); }
g_hDatabase = hndl; }
public void OnClientPostAdminCheck(client) { CheckRank(client); }
public CheckRank(int client) { char query[255]; char SteamID[32]; GetClientAuthId(client, AuthId_Steam2, SteamID, 32); Format(query, 255, "SELECT `score` FROM `ranking` WHERE `id_player`='%s' LIMIT 1", SteamID[10]); SQL_TQuery(g_hDatabase, SQLCallback_LoadPlayerPoints, query, GetClientUserId(client)); }
public SQLCallback_LoadPlayerPoints(Handle owner, Handle hndl, const char[] error, any data) { if (hndl == null) { SetFailState("Error grabbing player points. %s", error); }
int client = GetClientOfUserId(data);
if (SQL_GetRowCount(hndl) == 1) { SQL_FetchRow(hndl); int playerpoints = SQL_FetchInt(hndl, 0); if (playerpoints >= 1000) { KickClient(client, "This server is for beginners."); } } }
Make sure to change the ckSurf to whatever you have in your database.cfg.
Guessing it's because you didn't change "SQL_TConnect(SQLCallback_Connect, "ckSurf");" to connect toy our database?
Edit: You also have a few more errors. Here is how it should look:
Spoiler
PHP Code:
#pragma semicolon 1
#define PLUGIN_VERSION "0.1"
public Plugin:myinfo = { name = "ckSurf Kicker", author = "DeweY", version = PLUGIN_VERSION, description = "Kicks clients with 1000 points or more.", url = "http://Omegagaming.org/" };
Handle g_hDatabase = null;
public void OnPluginStart() { SQL_TConnect(SQLCallback_Connect, "ckSurf"); }
public SQLCallback_Connect(Handle owner, Handle hndl, const char[] error, any data) { if (hndl == null) { SetFailState("Error connecting to database. %s", error); }
g_hDatabase = hndl; }
public void OnClientPostAdminCheck(client) { CheckRank(client); }
public CheckRank(int client) { char query[255]; char SteamID[32]; GetClientAuthId(client, AuthId_Steam2, SteamID, 32); Format(query, 255, "SELECT `score` FROM `ranking` WHERE `id_player`='%s' LIMIT 1", SteamID[10]); SQL_TQuery(g_hDatabase, SQLCallback_LoadPlayerPoints, query, GetClientUserId(client)); }
public SQLCallback_LoadPlayerPoints(Handle owner, Handle hndl, const char[] error, any data) { if (hndl == null) { SetFailState("Error grabbing player points. %s", error); }
int client = GetClientOfUserId(data);
if (SQL_GetRowCount(hndl) == 1) { SQL_FetchRow(hndl); int playerpoints = SQL_FetchInt(hndl, 0); if (playerpoints >= 1000) { KickClient(client, "This server is for beginners."); } } }
Make sure to change the ckSurf to whatever you have in your database.cfg.
friend, the database is set up, including the console does not give me any error.you could tell me what form this query is selecting player_id from the database? I mean, in my database, the player_id is saved only with numbers, that is, has 3 columns the ranking table with the columns: score, nick and player_id, the player id is saved only with numbers, for example 765611234567, that is player_id of one of my users.The error could come from there?
Last edited by cristianronaldo; 05-30-2016 at 22:48.
friend, the database is set up, including the console does not give me any error.you could tell me what form this query is selecting player_id from the database? I mean, in my database, the player_id is saved only with numbers, that is, has 3 columns the ranking table with the columns: score, nick and player_id, the player id is saved only with numbers, for example 765611234567, that is player_id of one of my users.The error could come from there?
Send a picture of your database if it doesn't have any sensitive information in it so I can help you further.
Why go through all that? Why not just store a normal SteamID value? I don't know enough to be able to do all that, at least right now. Sorry.
friend, I did it the right way and it is working!!!!!.now,i need a last help.in my server I have 4 ports, and I need a different minimum of points to enter each theirs.you can add to the plugin some form of for example, on port 111 the minimum points is 1000, in the port 222 is 1500 and so with the other ports?.thanks
I don't know if it's possible to grab the port. The one thing I found using google was:
PHP Code:
int iPort = GetConVarInt(FindConVar("hostport"));
but this requires you to use hostport in the command-line while starting up your server. To test this out and see if it works for you, change your OnPluginStart code to this:
PHP Code:
public void OnPluginStart() { SQL_TConnect(SQLCallback_Connect, "ckSurf");
int iPort = GetConVarInt(FindConVar("hostport")); LogMessage("This servers port is %i", iPort); }
Then look in your console or your log files and see what it says. If it shows "This servers port is " then it will not work, otherwise I'll code something up for you.