21.03.2014, 10:39
try this
pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
new query[300];
if(dialogid == DIALOG_REGISTER)
{
if(!response) return Kick(playerid);
if(strlen(inputtext) < 6 || strlen(inputtext) > 129)
{
new string[128];
SendClientMessage(playerid, COLOR_RED, "[ERROR]: Your password must be 6 to 129 characters long!");
format(string, sizeof(string), "This server requires you to register an account before playing\n\nUsername: %s\n\nEnter your desired password below then click ok.",PlayerName(playerid));
ShowPlayerDialog(playerid,DIALOG_REGISTER,DIALOG_STYLE_INPUT,"{EDDC57}Registration required",string,"Register","Cancel");
return 1;
} else {
mysql_format(MysqlCon, query, sizeof(query), "INSERT INTO `players` (`user`, `pass`, `IP`) VALUES ('%e', '%s', '%s')", PlayerName(playerid), PasswordHash(inputtext), PlayerIP(playerid));
mysql_tquery(MysqlCon, query, "OnPlayerRegister", "i", playerid);
}
}
if(dialogid == DIALOG_LOGIN)
{
if(!response) return Kick(playerid);
if(!strcmp(PasswordHash(inputtext), pInfo[playerid][pPass], false))
{
mysql_format(MysqlCon, query, sizeof(query), "SELECT * FROM `players` WHERE `user` = '%e' LIMIT 1", PlayerName(playerid));
mysql_tquery(MysqlCon, query, "OnPlayerLogin", "i", playerid);
} else {
LoginAttempt[playerid]++; new string[128];
if(LoginAttempt[playerid] == 1)
{
format(string, sizeof(string), "Before playing you must login\n\nUsername: %s\n\nEnter your password below and click login",PlayerName(playerid));
ShowPlayerDialog(playerid,DIALOG_LOGIN,DIALOG_STYLE_PASSWORD,"{EDDC57}Login required",string,"Login","Cancel");
SendClientMessage(playerid, -1,"{B30000}[ERROR]: {FFFFFF}You have entered an incorrect password. [1/3]");
} else if(LoginAttempt[playerid] == 2)
{
format(string, sizeof(string), "Before playing you must login\n\nUsername: %s\n\nEnter your password below and click login",PlayerName(playerid));
ShowPlayerDialog(playerid,DIALOG_LOGIN,DIALOG_STYLE_PASSWORD,"{EDDC57}Login required",string,"Login","Cancel");
SendClientMessage(playerid, -1,"{B30000}[ERROR] {FFFFFF}You have entered an incorrect password. [2/3]");
} else if(LoginAttempt[playerid] == 3)
{
SendClientMessage(playerid, -1,"{B30000}[ERROR] {FFFFFF}You have entered an incorrect password. [3/3]");
format(string,sizeof(string),"{208DD6}[SERVER] {FFFFFF}%s[%d] has been kicked from the server. (Max password attempts)",PlayerName(playerid),playerid);
SendClientMessageToAll(COLOR_WHITE,string);
Kick(playerid);
}
}
}
if(dialogid == DIALOGWEAPONS)
{
if(response)
{
switch(listitem)
{
case 0:
{
if(GetPlayerMoney(playerid) <1500) return SendClientMessage(playerid, COLOR_GRAD, "You don't have enough money to buy this item!");
SendClientMessage(playerid, COLOR_GRAD, "You bought a deagle for 15k!");
GivePlayerMoney(playerid, -1500);
GivePlayerWeapon(playerid,24, 9999999);
}
case 1:
{
if(GetPlayerMoney(playerid) <2500) return SendClientMessage(playerid, COLOR_GRAD, "You don't have enough money to buy this item!");
SendClientMessage(playerid, COLOR_GRAD, "You bought a shotgun for 2.5k!");
GivePlayerMoney(playerid, -2500);
GivePlayerWeapon(playerid, 25, 9999999);
}
case 2:
{
if(GetPlayerMoney(playerid) <5000) return SendClientMessage(playerid, COLOR_GRAD, "You don't have enough money to buy this item!");
SendClientMessage(playerid, COLOR_GRAD, "You bought an MP5 for 5k!");
GivePlayerMoney(playerid, -5000);
GivePlayerWeapon(playerid, 29 ,9999999);
}
case 3:
{
if(GetPlayerMoney(playerid) <170000) return SendClientMessage(playerid, COLOR_GRAD, "You don't have enough money to buy this item!");
SendClientMessage(playerid, COLOR_GRAD, "You bought a spas12 for 170k!");
GivePlayerMoney(playerid, -170000);
GivePlayerWeapon(playerid, 27, 9999999);
}
case 4:
{
if(GetPlayerMoney(playerid) <50000) return SendClientMessage(playerid, COLOR_GRAD, "You don't have enough money to buy this item!");
SendClientMessage(playerid, COLOR_GRAD, "You bought an for 50k!");
GivePlayerMoney(playerid, -50000);
GivePlayerWeapon(playerid,30 ,9999999);
}
case 5:
{
if(GetPlayerMoney(playerid) <60000) return SendClientMessage(playerid, COLOR_GRAD, "You don't have enough money to buy this item!");
SendClientMessage(playerid, COLOR_GRAD, "You bought an for 60k!");
GivePlayerMoney(playerid, -60000);
GivePlayerWeapon(playerid, 31, 9999999);
}
case 6:
{
if(GetPlayerMoney(playerid) <150000) return SendClientMessage(playerid, COLOR_GRAD, "You don't have enough money to buy this item!");
SendClientMessage(playerid, COLOR_GRAD, "You bought a sniper for 150k!");
GivePlayerMoney(playerid, -150000);
GivePlayerWeapon(playerid, 34, 9999999);
}
case 7:
{
if(GetPlayerMoney(playerid) <10000) return SendClientMessage(playerid, COLOR_GRAD, "You don't have enough money to buy this item!");
new Float:armour;
GetPlayerArmour(playerid, armour);
if(armour == 100) return SendClientMessage(playerid, COLOR_GRAD,"You already have a full vest!");
SendClientMessage(playerid, COLOR_GRAD, "You bought a half vest for 10k!");
GivePlayerMoney(playerid, -10000);
SetPlayerArmour(playerid, 50);
}
case 8:
{
if(GetPlayerMoney(playerid) <20000) return SendClientMessage(playerid, COLOR_GRAD, "You don't have enough money to buy this item!");
new Float:armour;
GetPlayerArmour(playerid, armour);
if(armour == 100) return SendClientMessage(playerid, COLOR_GRAD, "You already have a full vest!");
SendClientMessage(playerid, COLOR_GRAD, "You bought a full vest for 20k!");
GivePlayerMoney(playerid, -20000);
SetPlayerArmour(playerid, 100);
}
}
return 1;
}
}