24.06.2016, 04:29
Please convert these scripts to a_mysql or simple mysql
Код:
SQL::Connect(MYSQL_HOST, MYSQL_USER, MYSQL_DATABASE, MYSQL_PASSWORD); if(!SQL::ExistsTable(""PLAYERS_TABLE"")) { new handle = SQL::Open(SQL::CREATE, ""PLAYERS_TABLE""); SQL::AddTableEntry(handle, "id", SQL_TYPE_INT, 11, true); SQL::AddTableEntry(handle, "username", SQL_TYPE_VCHAR, 24); SQL::AddTableEntry(handle, "password", SQL_TYPE_VCHAR, 114); SQL::AddTableEntry(handle, "ip", SQL_TYPE_VCHAR, 24); SQL::AddTableEntry(handle, "score", SQL_TYPE_INT); SQL::AddTableEntry(handle, "cash", SQL_TYPE_INT); SQL::AddTableEntry(handle, "kills", SQL_TYPE_INT); SQL::AddTableEntry(handle, "deaths", SQL_TYPE_INT); SQL::AddTableEntry(handle, "vip", SQL_TYPE_INT); SQL::AddTableEntry(handle, "level", SQL_TYPE_INT); SQL::AddTableEntry(handle, "helper", SQL_TYPE_INT); SQL::AddTableEntry(handle, "hours", SQL_TYPE_INT); SQL::AddTableEntry(handle, "minutes", SQL_TYPE_INT); SQL::AddTableEntry(handle, "seconds", SQL_TYPE_INT); SQL::AddTableEntry(handle, "wanteds", SQL_TYPE_INT); SQL::AddTableEntry(handle, "laston", SQL_TYPE_VCHAR, 48); SQL::AddTableEntry(handle, "joined", SQL_TYPE_VCHAR, 48); SQL::AddTableEntry(handle, "mutedsec", SQL_TYPE_INT); SQL::AddTableEntry(handle, "cmdmutedsec", SQL_TYPE_INT); SQL::AddTableEntry(handle, "jailedsec", SQL_TYPE_INT); SQL::AddTableEntry(handle, "warns", SQL_TYPE_INT); SQL::AddTableEntry(handle, "fs", SQL_TYPE_INT); SQL::AddTableEntry(handle, "skin", SQL_TYPE_INT); SQL::AddTableEntry(handle, "Pistol", SQL_TYPE_INT); SQL::AddTableEntry(handle, "Ammo1", SQL_TYPE_INT); SQL::AddTableEntry(handle, "Sub", SQL_TYPE_INT); SQL::AddTableEntry(handle, "Ammo2", SQL_TYPE_INT); SQL::AddTableEntry(handle, "Rifle", SQL_TYPE_INT); SQL::AddTableEntry(handle, "Ammo3", SQL_TYPE_INT); SQL::AddTableEntry(handle, "Assault", SQL_TYPE_INT); SQL::AddTableEntry(handle, "Ammo4", SQL_TYPE_INT); SQL::AddTableEntry(handle, "Shotgun", SQL_TYPE_INT); SQL::AddTableEntry(handle, "Ammo5", SQL_TYPE_INT); SQL::Close(handle); print("[SSF]: '"PLAYERS_TABLE"' table created successfully!"); } else if(SQL::ExistsTable(""PLAYERS_TABLE"")) { printf("[SSF]: Total %d accounts loaded from '"PLAYERS_TABLE"'", SQL::CountRows(""PLAYERS_TABLE"")); } if(!SQL::ExistsTable(""BANS_TABLE"")) { new handle = SQL::Open(SQL::CREATE, ""BANS_TABLE""); SQL::AddTableEntry(handle, "ban_id", SQL_TYPE_INT, 11, true); SQL::AddTableEntry(handle, "ban_username", SQL_TYPE_VCHAR, 24); SQL::AddTableEntry(handle, "ban_ip", SQL_TYPE_VCHAR, 24); SQL::AddTableEntry(handle, "ban_by", SQL_TYPE_VCHAR, 24); SQL::AddTableEntry(handle, "ban_on", SQL_TYPE_VCHAR, 24); SQL::AddTableEntry(handle, "ban_reason", SQL_TYPE_VCHAR, 24); SQL::AddTableEntry(handle, "ban_expire", SQL_TYPE_INT); SQL::Close(handle); print("[SSF]: '"BANS_TABLE"' table created successfully!"); } else if(SQL::ExistsTable(""BANS_TABLE"")) { printf("[SSF]: Total %d bans loaded from '"BANS_TABLE"'", SQL::CountRows(""BANS_TABLE"")); }
Код:
if(SQL::RowExistsEx(""BANS_TABLE"", "ban_username", GetName(playerid))) { new handle = SQL::OpenEx(SQL::READ, ""BANS_TABLE"", "ban_username", GetName(playerid)); SQL::ReadString(handle, "ban_username", string[1], 24); SQL::ReadString(handle, "ban_ip", string[2], 24); SQL::ReadString(handle, "ban_by", string[3], 24); SQL::ReadString(handle, "ban_on", string[4], 24); SQL::ReadString(handle, "ban_reason", string[5], 24); SQL::ReadInt(handle, "ban_expire", expire); SQL::Close(handle); if(expire > gettime() || expire == 0) { strcat(DIALOG, ""white"Your account is banned from this server,\n\n"); format(string2, sizeof(string2), ""white"Username: "red"%s\n", string[1]); strcat(DIALOG, string2); format(string2, sizeof(string2), ""white"IP: "red"%s\n", string[2]); strcat(DIALOG, string2); format(string2, sizeof(string2), ""white"Banned by: "red"%s\n", string[3]); strcat(DIALOG, string2); format(string2, sizeof(string2), ""white"Reason: "red"%s\n", string[5]); strcat(DIALOG, string2); format(string2, sizeof(string2), ""white"Ban date: "red"%s\n", string[4]); strcat(DIALOG, string2); new expire2[68]; if(expire == 0) expire2 = "PERMANENT"; else expire2 = ConvertTime(expire); format(string2, sizeof(string2), ""white"Timeleft: "red"%s\n\n", expire2); strcat(DIALOG, string2); strcat(DIALOG, ""white"If you think that you got banned wrongfully, please make an appeal on our forums.\n"); strcat(DIALOG, "Make sure you saved this box by pressing F8."); ShowPlayerDialog(playerid, DIALOG_COMMON, DIALOG_STYLE_MSGBOX, "Notice", DIALOG, "Close", ""); DelayKick(playerid); return true; } else { SQL::DeleteRowEx(""BANS_TABLE"", "ban_username", GetName(playerid)); Server(playerid, "Your account's ban has expired."); } } else if(SQL::RowExistsEx(""BANS_TABLE"", "ban_ip", GetIP(playerid))) { new handle = SQL::OpenEx(SQL::READ, ""BANS_TABLE"", "ban_ip", GetIP(playerid)); SQL::ReadString(handle, "ban_username", string[1], 24); SQL::ReadString(handle, "ban_ip", string[2], 24); SQL::ReadString(handle, "ban_by", string[3], 24); SQL::ReadString(handle, "ban_on", string[4], 24); SQL::ReadString(handle, "ban_reason", string[5], 24); SQL::ReadInt(handle, "ban_expire", expire); SQL::Close(handle); if(expire > gettime() || expire == 0) { strcat(DIALOG, ""white"Your IP is banned from this server,\n\n"); format(string2, sizeof(string2), ""white"Username: "red"%s\n", string[1]); strcat(DIALOG, string2); format(string2, sizeof(string2), ""white"IP: "red"%s\n", string[2]); strcat(DIALOG, string2); format(string2, sizeof(string2), ""white"Banned by: "red"%s\n", string[3]); strcat(DIALOG, string2); format(string2, sizeof(string2), ""white"Reason: "red"%s\n", string[5]); strcat(DIALOG, string2); format(string2, sizeof(string2), ""white"Ban date: "red"%s\n", string[4]); strcat(DIALOG, string2); new expire2[68]; if(expire == 0) expire2 = "PERMANENT"; else expire2 = ConvertTime(expire); format(string2, sizeof(string2), ""white"Timeleft: "red"%s\n\n", expire2); strcat(DIALOG, string2); strcat(DIALOG, ""white"If you think that you got banned wrongfully, please make an appeal on our forums.\n"); strcat(DIALOG, "Make sure you saved this box by pressing F8."); ShowPlayerDialog(playerid, DIALOG_COMMON, DIALOG_STYLE_MSGBOX, "Notice", DIALOG, "Close", ""); DelayKick(playerid); return true; } else { SQL::DeleteRowEx(""BANS_TABLE"", "ban_username", GetName(playerid)); Server(playerid, "Your IP's ban has expired."); } }