SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Thread Tools Display Modes
Old 25/03/2016, 11:49 AM   #1
Big Clucker
Join Date: Jan 2013
Posts: 57
Reputation: 2
Default MYSQL Ban Check

I'm trying to create a mysql script. I have a login / account system.

When a admin bans a player, it adds the information (Name, IP, Reason etc) into a MySQL table "bans"

Under OnPlayerConnect, I currently use this:

pawn Code:
Player[playerid][Logged] = 0;
    TogglePlayerSpectating(playerid, true);
    GetPlayerName(playerid, playername, sizeof(playername));
    mysql_format(mysql, query, sizeof(query), "SELECT `Password`, `ID` FROM `accounts` WHERE `Name` = '%e' LIMIT 1", playername);
    mysql_tquery(mysql, query, "OnAccountCheck", "i", playerid);

I would like to make it so when they join, it searches the bans mysql table for the playername and IP and if it matches, it'll kick the player with a message or dialog with the ban information in.

My OnAccountCheck
pawn Code:
public OnAccountCheck(playerid)
    cache_get_data(rows, fields, mysql);
        cache_get_field_content(0, "Password", Player[playerid][Password], mysql, 129);
        Player[playerid][ID] = cache_get_field_content_int(0, "ID");
        ShowPlayerDialog(playerid, LoginDialog, DIALOG_STYLE_PASSWORD, "Login", "Welcome player!\nYour account has been found in our database. Please fill in your password:", "Login", "Quit");
        ShowPlayerDialog(playerid, RegisterDialog, DIALOG_STYLE_PASSWORD, "Register", "Welcome player!\nYour account has not been registered yet. Please fill in your desired password:", "Register", "Quit");
    return true;
theonethatownz is offline   Reply With Quote
Old 25/03/2016, 08:18 PM   #2
Huge Clucker
Join Date: Nov 2011
Location: La Lima, Honduras.
Posts: 212
Reputation: 2
Default Respuesta: MYSQL Ban Check

It would be something like:
pawn Code:
new query[126];
    format(query,sizeof(query),"SELECT * FROM table_bans WHERE Name='%s'",playername);
    if(cache_num_rows() > 0)
        new banstring[256];
        new bName[30],bIP[30],bAdmin[30],bReason[30];
        format(banstring,sizeof(banstring),"Name: %s\nIP: %s\nAdmin: %s\nReason: %s",bName,bIP,bAdmin,bReason);
        ShowPlayerDialog(playerid,DIALOG_BAN,DIALOG_STYLE_MSGBOX,"Account Banned",banstring,"Aceptar","");

I'm not very sure about function cache_num_rows, but try it., but try it.

sorry for my bad english.
mcreed is offline   Reply With Quote

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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Someone please check this mysql STONEGOLD Scripting Help 2 06/06/2015 06:54 AM
Mysql queriesYou have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for th audriuxxx Scripting Help 4 11/04/2014 07:42 PM
[HELP] mysql check V4at Scripting Help 10 25/02/2014 08:52 PM
[Help] Mysql check VMe89 Scripting Help 1 20/03/2012 06:16 PM
mysql check ajwar Scripting Help 2 08/02/2012 04:03 PM

All times are GMT. The time now is 03:05 PM.

Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.