22.08.2013, 22:32
Hey guys,
I recently picked SA:MP scripting back up out of boredom, so I decided to do a 100% scratch roleplay server; however I have ran into a small (but severe) issue. I have my MySQL database completely configured, however it's not letting me insert data via script. I have displayed the code below, I cannot figure it out, personally. It's connecting to the database, it's just not inserting data:
Any help will be appreciated (and +rep'ed if you actually explain my mistake to a degree where it'll be difficult for me to repeat the mistake)!
Thanks,
Nmader
I recently picked SA:MP scripting back up out of boredom, so I decided to do a 100% scratch roleplay server; however I have ran into a small (but severe) issue. I have my MySQL database completely configured, however it's not letting me insert data via script. I have displayed the code below, I cannot figure it out, personally. It's connecting to the database, it's just not inserting data:
pawn Код:
public OnPlayerConnect(playerid)
{
new playerName[MAX_PLAYER_NAME];
GetPlayerName(playerid, playerName, MAX_PLAYER_NAME);
new string[256];
format(string,sizeof(string),"GET * FROM bans WHERE `pName` = '%s'", playerName);
mysql_query(string);
new result2[128];
new result3[128];
new String[128];
mysql_retrieve_row();
mysql_get_field("pName", result);
mysql_get_field("pReasonBanned", result2);
mysql_get_field("pBannedBy", result3);
if(strval(result) == 1)
{
format(String, sizeof(String), "This account has been banned for the reason of: %s", result2);
SendClientMessage(playerid, COLOR_RED, String);
format(String, sizeof(String), "Your account was banned by administrator %s", result3);
SendClientMessage(playerid, COLOR_RED, String);
SendClientMessage(playerid, COLOR_RED, "This ban is permanent, you can appeal on our forums:");
SendClientMessage(playerid, COLOR_RED, "http://www.countrylife-rp.comyr.com");
Kick(playerid);
}
else if(strval(result) != 1)
{
new query[128];
SendClientMessage(playerid, COLOR_RED, "You are not banned, for testing porposes, you have been banned");
//format(String, sizeof(String), "INSERT INTO bans (pName, playerBannedBy, playerReasonBanned) VALUES('%s', 'JunkBuster', 'Test Ban')", playerName);
format(String, sizeof(String), "INSERT INTO `bans` (`pName`) VALUES('%s')", playerName);
mysql_query(query);
print("Player banned for bug testing!");
}
return 1;
}
Thanks,
Nmader