Help With MySQL Ban List Script
#1

I'm trying to make it to where when someone is banned, the information about their ban is added to a MySQL database, but when I try and compile this, Pawno crashes. What is wrong? Also, I KNOW there is going to be something wrong with the MySQL stuff, so could you go ahead and fix that now? The table name is bans and the column/field or whatever names are Name, Reason, Admin, and IP. Here's the ban script:

Код:
#include <a_samp>
#include <a_mysql>

if(strcmp(cmd, "/adban", true) == 0 && PlayerAdminLevel[playerid] == 0) // Admin Ban
{
if(!PLAYERLIST_authed[playerid])
{
SendClientMessage(playerid,0xFF0000AA,"Bad Command. Type /commands for available commands depending on your chosen job/skill");
return 1;
}
tmp = strtok(cmdtext, idx);
if(!strlen(tmp)) {
SendClientMessage(playerid, COLOR_ERROR, "USAGE: /adban (id)");
return 1;
}
giveplayerid = strval(tmp);
if(!IsNumeric(tmp)) {
SendClientMessage(playerid, COLOR_ERROR, "USAGE: /adban (id) ID Must be a number");
return 1;
}
new output[255];
new File:ftw=fopen("banlist.txt", io_append);
new str[255];
new str1[255];
new bannername[24];
GetPlayerName(playerid,bannername, 24);
strmid(output,cmdtext,9,strlen(cmdtext));
if (IsPlayerConnected(giveplayerid)) {
SetPlayerInterior(giveplayerid,0);
SetPlayerPos(giveplayerid,-127.0526,2258.4316,29.4287);
SetPlayerFacingAngle(giveplayerid,217.0701);
SetCameraBehindPlayer(giveplayerid);
SetTimer("BanExplosionone",500,0);
AdminKilled[giveplayerid] =1;
GetPlayerName(giveplayerid, string, 24);
format(str, 255, "**(ADMIN BAN)** %s(%d) %s \r\n", string,giveplayerid,output);
format(str1, 255, "**(Banned By)**: %s \r\n",bannername);
SendClientMessageToAll(COLOR_RED, str);
fwrite(ftw, str);
fwrite(ftw, str1);
fclose(ftw);
printf("%s", string);
if(udb_Exists(PlayerName(giveplayerid)) && PLAYERLIST_authed[giveplayerid]) {
dUserSetINT(PlayerName(giveplayerid)).("nameban",1);
}

#define SQL_HOST "secret_host?"
#define SQL_DB "roleplay_bans"
#define SQL_USER "roleplay_bans"
#define SQL_PASS "secret?"

GetPlayerName(playerid,Name,sizeof(Name));
GetPlayerIp(playerid, plrIP, sizeof(plrIP));
mysql_real_escape_string(Name,Name);
mysql_real_escape_string(output,output);
mysql_real_escape_string(bannername,bannername);
mysql_real_escape_string(plrIP,plrIP);
format(query,sizeof(query),"INSERT INTO `"bans"` (Name, Reason, Admin, IP) VALUES ('%s',md5('%s'))",name,output,bannername,plrIP);
mysql_query(query);
mysql_query("INSERT INTO bans (Name, Reason, Admin, IP)

SendClientMessage(giveplayerid,COLOR_RED,"||| YOU HAVE BEEN BANNED FROM THIS SERVER");
SendClientMessage(giveplayerid,COLOR_RED,"||| You can appeal this action at our website");
SendClientMessage(giveplayerid,COLOR_RED,"||| Visit lolcats.com for details");
SendClientMessage(giveplayerid,COLOR_RED,"||| Please note that we do not unban hackers/cheaters");
SendClientMessage(giveplayerid,COLOR_RED,"||| You can also take a screenshot of this message for your unban appeal");
Banning[giveplayerid] = 1;
}
else {
format(string, sizeof(string), "ID (%d) Is not an active player", giveplayerid);
SendClientMessage(playerid, COLOR_ERROR, string);
}
return 1;
}
Reply


Messages In This Thread
Help With MySQL Ban List Script - by jeff223 - 09.08.2009, 12:39
Re: Help With MySQL Ban List Script - by Sergei - 09.08.2009, 12:53
Re: Help With MySQL Ban List Script - by jeff223 - 09.08.2009, 13:21
Re: Help With MySQL Ban List Script - by Sergei - 09.08.2009, 13:34
Re: Help With MySQL Ban List Script - by jeff223 - 09.08.2009, 13:44
Re: Help With MySQL Ban List Script - by Sergei - 09.08.2009, 13:53
Re: Help With MySQL Ban List Script - by jeff223 - 09.08.2009, 14:00
Re: Help With MySQL Ban List Script - by WrathOfGenesis - 09.08.2009, 14:01
Re: Help With MySQL Ban List Script - by bogeymanEST - 09.08.2009, 14:04
Re: Help With MySQL Ban List Script - by jeff223 - 09.08.2009, 14:26

Forum Jump:


Users browsing this thread: 1 Guest(s)