25.11.2009, 18:06
Код:
if(strcmp(cmd, "/register", true) == 0) { MySQLCheck(); new query[256], name[256]; GetPlayerName(playerid, name, 256); format(query, 256, "SELECT * FROM `users` WHERE `username`='%s'", name); mysql_query(query); mysql_store_result(); if(mysql_num_rows() == 1) { SendClientMessage(playerid, COLOR_RED, "ERROR: Your nickname is already registered! Please login! [/login]"); return 1; } new tmp[256]; tmp = strtok(cmdtext, idx); if(!strlen(tmp)) { SendClientMessage(playerid, COLOR_RED, "ERROR: /register [password]"); return 1; } format(query, 256, "INSERT INTO `users` (`id`, `username`, `password`, `money`) VALUES(NULL, '%s', '%s', '10000');", name, tmp); mysql_query(query); SendClientMessage(playerid, COLOR_GREEN, "Registration Completed!"); mysql_close(); return 1; }
Код:
MySQLCheck() { if(mysql_ping() == -1) { mysql_connect(host, user, database, password); } return 1; }