Код:
loadServerMottos() {
query[0] = 0;
format(query, sizeof(query), "SELECT `id`,`message`,`type` FROM `servermottos`");
mysql_function_query(g_mysql_handle, query, true, "OnLoadServerMottos", "");
}
forward OnLoadServerMottos();
public OnLoadServerMottos() {
new rows, fields;
new id_string[128];
new type;
cache_get_data(rows, fields);
for(new i=0;i<rows;i++) {
if(ServerMottos[i][EMottoSQLID] != 0) continue; //Also used for reloading the mottos
cache_get_row(i, 0, id_string);
ServerMottos[i][EMottoSQLID] = strval(id_string);
cache_get_row(i, 1, ServerMottos[i][ESVMottoName]);
cache_get_row(i, 2, id_string);
type = strval(id_string);
ServerMottos[i][ESVMottoType] = ESpecialMottoTypes:type;
}
return 1;
}
changeHostNameText() {
if(svnamechangeallowed == 1) {
new index = findRandServerMottoSQLID();
if(index == -1) return 0;
new msg[128];
if(ServerMottos[index][ESVMottoType] == MottoType_Normal) {
format(msg, sizeof(msg), "hostname %s", ServerMottos[index][ESVMottoName]);
}
if(index != -1) {
SendRconCommand(msg);
}
}
return 1;
}
findRandServerMottoSQLID() {
new maxamount;
for(new i=0;i<sizeof(ServerMottos);i++) {
if(ServerMottos[i][EMottoSQLID]) {
maxamount++;
}
}
if(maxamount != 0) {
return RandomEx(0, maxamount);
} else {
return -1;
}
}
Fixed it myself.