[SOLVED]Bans -
jamesb93 - 16.01.2010
Код:
Im making my bans save to a database but I get an error in the my_log:
Код:
[19:29:41] mysql_query("INSERT INTO 'bans' (name, ip, banner, reason, month, day, year) VALUES ('[RG]James','49','[RG]James','dipshit','1','16', '2010'");
[19:29:41] MySQL Query Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''bans' (name, ip, banner, reason, month, day, year) VALUES ('[RG]James','49','[R' at line 1 (Error ID 1064) -> Query returned false (0)
This is my /ban:
pawn Код:
if(strcmp(cmd, "/ban", true) == 0) { new giveplayerid; giveplayerid = ReturnUser(tmp); new giveplayer[MAX_PLAYER_NAME]; new string[256]; new sendername[MAX_PLAYER_NAME]; new playerip[20]; if(IsPlayerConnected(playerid)) { tmp = strtok(cmdtext, idx); if(!strlen(tmp)) { SendClientMessage(playerid, COLOR_RED, "USAGE: /ban [playerid/PartOfName] [reason]"); return 1; } giveplayerid = ReturnUser(tmp); if (PlayerInfo[playerid][pAdmin] >= 3) { if(IsPlayerConnected(giveplayerid)) { if(giveplayerid != INVALID_PLAYER_ID) { GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer)); GetPlayerName(playerid, sendername, sizeof(sendername)); new length = strlen(cmdtext); while ((idx < length) && (cmdtext[idx] <= ' ')) { idx++; } new offset = idx; new result[64]; while ((idx < length) && ((idx - offset) < (sizeof(result) - 1))) { result[idx - offset] = cmdtext[idx]; idx++; } result[idx - offset] = EOS; if(!strlen(result)) { SendClientMessage(playerid, COLOR_RED, "USAGE: /ban [playerid/PartOfName] [reason]"); return 1; } format(string, sizeof(string), "In Game Name: %s", giveplayer); SendClientMessage(giveplayerid,COLOR_YELLOW,string); format(string, sizeof(string), "Who Banned You: %s", sendername); SendClientMessage(giveplayerid,COLOR_YELLOW,string); BanStats(giveplayerid); format(string, sizeof(string), "Take a SS of this (F8) and go to rock-gaming.com"); SendClientMessage(giveplayerid,COLOR_GREEN,string); new year, month,day; getdate(year, month, day); GetPlayerIp(giveplayerid, playerip, 16); new query[128]; format(query, sizeof(query), "INSERT INTO 'bans' (name, ip, banner, reason, month, day, year) VALUES ('%s','%d','%s','%s','%d','%d', '%d')", giveplayer,playerip,sendername,result,month,day,year); mysql_query(query); format(string, sizeof(string), " %s was banned by %s, reason: %s (%d-%d-%d)", giveplayer, sendername, (result),month,day,year); SendClientMessageToAll(COLOR_YELLOW, string); BanLog(string); Kick(giveplayerid); return 1; } } else { format(string, sizeof(string), " %d is not an active player.", giveplayerid); SendClientMessage(playerid, COLOR_RED, string); } } else return SendClientMessage(playerid, RED, "ERROR: You are not an admin"); } return 1; }
Will this work also? Havent been able to try it:
pawn Код:
new query
[265];
new pip
[20];
new ip
[20]; GetPlayerIp
(playerid, pip,
16);
format(query,
sizeof(query
),
"SELECT type FROM 'bans' WHERE ip = '%s'", ip
);
if(strcmp(pip, ip
) == 1) { SendClientMessage
(playerid, COLOR_RED,
"You Are Banned From This Server"); SendClientMessage
(playerid, COLOR_RED,
"To Appeal This Ban Please Goto Out Forums"); SendClientMessage
(playerid, COLOR_RED,
"At http://www.rock-gaming.com[url=http://]");
return 1;
} if(strcmp(pip, ip
) == 0) { //other crap here
thanks
Re: Bans -
Blacklite - 16.01.2010
should be `bans` not 'bans'
Re: Bans -
jamesb93 - 16.01.2010
The string dosent save the IP for some reason
Comes up as like 49
Re: Bans -
GTAguillaume - 16.01.2010
Код:
if(strcmp(pip, ip) == 1)
{
SendClientMessage(playerid, COLOR_RED, "You Are Banned From This Server");
SendClientMessage(playerid, COLOR_RED, "To Appeal This Ban Please Goto Out Forums");
SendClientMessage(playerid, COLOR_RED, "At www.rock-gaming.com");
return 1;
}
strcmp return
0 when the strings are equal,
Re: Bans -
jamesb93 - 16.01.2010
yea lol ty
Still though the string of the players IP gets saved wrongly
Re: Bans -
s0nic - 17.01.2010
Playerip should be a string(%s)..
Try this out:
pawn Код:
format(query, sizeof(query), "INSERT INTO `bans` (`name`, `ip`, `banner`, `reason`, `month`, `day`, `year`) VALUES ('%s','%s','%s','%s','%d','%d','%d')", giveplayer,playerip,sendername,result,month,day,year);
Re: Bans -
jamesb93 - 17.01.2010
Okay now my loading is fucked up lol
The log says
Код:
[13:25:02] mysql_query("SELECT ip FROM `bans` WHERE ip = ''"); Return: 1
[13:25:02] mysql_store_result();
and the script has;
pawn Код:
public OnPlayerConnect
(playerid
){ new query
[265];
new pip
[20];
new ip
[20];
GetPlayerIp
(playerid, pip,
16);
format(query,
sizeof(query
),
"SELECT ip FROM `bans` WHERE ip = '%s'", ip
);
mysql_query
(query
);
mysql_store_result
();
if(strcmp(pip, ip
) == 0) { SendClientMessage
(playerid, COLOR_RED,
"You Are Banned From This Server");
SendClientMessage
(playerid, COLOR_RED,
"To Appeal This Ban Please Goto Out Forums");
SendClientMessage
(playerid, COLOR_RED,
"At http://www.rock-gaming.com[url=http://][/url]");
Kick
(playerid
);
} else {
anyone know why?
Re: Bans -
Blacklite - 17.01.2010
Do it like this:
pawn Код:
public OnPlayerConnect
(playerid
){ new query
[265];
new ip
[20];
GetPlayerIp
(playerid, ip,
16);
format(query,
sizeof(query
),
"SELECT ip FROM `bans` WHERE ip = '%s'", ip
);
mysql_query
(query
);
mysql_store_result
();
if(mysql_num_rows
() > 0) { SendClientMessage
(playerid, COLOR_RED,
"You Are Banned From This Server");
SendClientMessage
(playerid, COLOR_RED,
"To Appeal This Ban Please Goto Out Forums");
SendClientMessage
(playerid, COLOR_RED,
"At http://www.rock-gaming.com[url=http://][/url]");
Kick
(playerid
);
} else {
(Assuming mysql_num_rows() is the function to get the amount of rows retrieved)
Re: Bans -
jamesb93 - 17.01.2010
Yes thanks got it
Re: [SOLVED]Bans -
Simsissle - 07.02.2010
SAGE, who are you? Why do you have Rock Gaming code?