Well, I've gotten TONS of help in another topic and I believe it's time to start a new one because the script is so revised. Basically what I want it to do is when someone is banned, I wish to have it logged into a database. I have gotten help with that in my other topic and believe the MySQL part is complete. The only problem; though, is that I'm getting some errors. Could someone assist me in fixing them?:
Код:
#include <a_samp>
#include <a_mysql>
public OnPlayerCommandText ( playerid , cmdtext [ ] )
{
new cmd [ 256 ] , idx , tmp [ 256 ];
cmd = strtok ( cmdtext , idx );
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','%s','%s','%s')",Name,output,bannername,plrIP);
mysql_query(query);
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;
}
return 0;
}
Here are the errors (Yes, I have strtok and PlayerAdminLevel defined in the rest of my script, I just don't want to add this until it's complete):