switch( dialogid )
{
case Register:
{
new
Query[900],
EscPass[100],
EscName[MAX_PLAYER_NAME],
IP[16];
GetPlayerIp(playerid,IP,sizeof(IP));
mysql_real_escape_string(GetPName(playerid), EscName);
mysql_real_escape_string(inputtext, EscPass);
format(Query, sizeof(Query), "INSERT INTO `playerdata` (User, Password, Cash, Level, EXP, Rank, TurfsCaptured, TurfsLost, Kills, Deaths, Score, Muted, Warnings, Vip, IP) VALUES('%s', '%s', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, '%s')", EscName,EscPass, IP);
mysql_query(Query);
PInfo[playerid][Regged] = 1;
PInfo[playerid][Logged] = 1;
TogglePlayerSpectating(playerid, 0);
SendClientMessage(playerid,COLOR_ORANGE,"[*]: You Have Successfully Registered!");
}
case Login:
{
if(response)
{
new query[90], pname[24], escapepass[100];
GetPlayerName(playerid, pname, 24);
mysql_real_escape_string(inputtext, escapepass);
format(query, sizeof(query), "SELECT `User` FROM `playerdata` WHERE `User` = '%s' AND Password = '%s'", pname, escapepass);
mysql_store_result();
TogglePlayerSpectating(playerid, 0);
new numrows = mysql_num_rows();
if(numrows == 1) MySQL_Login(playerid);
if(!numrows)
{
ShowPlayerDialog(playerid, Login, DIALOG_STYLE_INPUT,""COL_LIGHTBLUE":: "COL_RED"Login", "\t"COL_WHITE"Consipirational Team Death Match (V1.0)\n"COL_RED"You Have Entered Invalid Password\n"COL_WHITE"Welcome Back, \nPlease Enter Your Password Below To Start The Game!", "Login", "Exit");
}
mysql_free_result();
}
}
}
return 1;
}
format(Query, sizeof(Query), "INSERT INTO `playerdata` (User, Password, Cash, Level, EXP, Rank, TurfsCaptured, TurfsLost, Kills, Deaths, Score, Muted, Warnings, Vip, IP) VALUES('%s', '%s', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, '%s')", EscName,EscPass, IP);
//to
format(Query, sizeof(Query), "INSERT INTO `playerdata` (`User`, `Password`, `IP`) VALUES('%s', '%s', '%s')", EscName, EscPass, IP);
stock MySQL_Login(playerid)
{
new query[900], pname[24], savingstring[50];
GetPlayerName(playerid, pname, 24);
format(query, sizeof(query), "SELECT Cash, Level, EXP, Rank, TurfsCaptured, TurfsLost, Kills, Deaths, Score, Muted, Warnings, Vip FROM playerdata WHERE User = '%s'", pname);
mysql_query(query);
mysql_store_result();
while(mysql_fetch_row_format(query,"|"))
{
mysql_fetch_field_row(savingstring, "Cash"); GivePlayerMoney(playerid, strval(savingstring));
mysql_fetch_field_row(savingstring, "Level"); PInfo[playerid][Level] = strval(savingstring);
mysql_fetch_field_row(savingstring, "EXP"); PInfo[playerid][EXP] = strval(savingstring);
mysql_fetch_field_row(savingstring, "Rank"); PInfo[playerid][Rank] = strval(savingstring);
mysql_fetch_field_row(savingstring, "TurfsCaptured"); PInfo[playerid][TurfsCaptured] = strval(savingstring);
mysql_fetch_field_row(savingstring, "TurfsLost"); PInfo[playerid][TurfsLost] = strval(savingstring);
mysql_fetch_field_row(savingstring, "Kills"); PInfo[playerid][Kills] = strval(savingstring);
mysql_fetch_field_row(savingstring, "Deaths"); PInfo[playerid][Deaths] = strval(savingstring);
mysql_fetch_field_row(savingstring, "Score"); PInfo[playerid][Score] = strval(savingstring);
mysql_fetch_field_row(savingstring, "Muted"); PInfo[playerid][Muted] = strval(savingstring);
mysql_fetch_field_row(savingstring, "Warnings"); PInfo[playerid][Warnings] = strval(savingstring);
mysql_fetch_field_row(savingstring, "Vip"); PInfo[playerid][Vip] = strval(savingstring);
}
mysql_free_result();
TogglePlayerSpectating(playerid, 0);
PInfo[playerid][Logged] = 1;
SendClientMessage(playerid,COLOR_ORANGE,"[*]: You Have Successfully Logged In!");
return 1;
}
//
if(mysql_ping() == 1)
{
mysql_debug(1);
printf("[MYSQL] Connection with the database: SUCCESS!");
}
else
{
printf("[MYSQL] Connection with the database: FAIL!");
}
OnGameModeInit, after connecting mysql do:
pawn Код:
And dude, hash your passwords! People trust you, and you just can watch their passwords whenever you want? |
[23:31:57] Loaded 3 filterscripts. [23:31:57] [MYSQL] Connection with the database: SUCCESS! [23:31:57] Developed by: Littlehelper[MDZ] Project Start: Friday, July 20th, 2012 Last Update: July 21th, 2012 |