if(dialogid == SEXMENU) { if(response) { //man new name[MAX_PLAYER_NAME],query[128],psex[2]; GetPlayerName(playerid,name,sizeof(name)); format(query,sizeof(query),"INSERT INTO accounts WHERE name='%s' (psex) VALUES ('1') ",psex); mysql_function_query(sqlconnect,query,false,"",""); SetPlayerSkin(playerid, 185); ShowPlayerDialog(playerid, AGEMENU, DIALOG_STYLE_INPUT, "{00C0FF}Amzius", "{FFFFFF}Kiek jums metu ?", "Submit", "Cancel"); return 0; } else { //woman new name[MAX_PLAYER_NAME],query[128],psex[2]; GetPlayerName(playerid,name,sizeof(name)); format(query,sizeof(query),"INSERT INTO accounts WHERE name='%s' (psex) VALUES ('2') ",psex); mysql_function_query(sqlconnect,query,false,"",""); SetPlayerSkin(playerid, 193); ShowPlayerDialog(playerid, AGEMENU, DIALOG_STYLE_INPUT, "{00C0FF}Amzius", "{FFFFFF}Kiek jums metu ?", "Submit", "Cancel"); return 0; } }
if(dialogid == SEXMENU) // could probably use a switch here, as well
{
new name[MAX_PLAYER_NAME], query[128];
GetPlayerName(playerid, name, sizeof(name));
format(query, sizeof(query), "UPDATE accounts SET psex=%d WHERE name='%s'", (response) ? 1 : 2, name);
mysql_function_query(sqlconnect, query, false, "", "");
SetPlayerSkin(playerid, (response) ? 185 : 193);
ShowPlayerDialog(playerid, AGEMENU, DIALOG_STYLE_INPUT, "{00C0FF}Amzius", "{FFFFFF}Kiek jums metu ?", "Submit", "Cancel");
}
Update, not insert. And while we're at it, this block of code can be compacted. Always avoid duplicate code. If a change is to be made, you want to do it in only one place.
pawn Код:
|
format(query,sizeof(query),"UPDATE accounts SET psex='1' WHERE name='%s' ",psex);
//sql new name[MAX_PLAYER_NAME],query[128],page[10]; GetPlayerName(playerid,name,sizeof(name)); new input = mysql_escape_string(inputtext,page,sqlconnect); format(query,sizeof(query),"UPDATE accounts SET page=input WHERE name='%s' ",name,page); mysql_function_query(sqlconnect,query,false,"",""); //--------
if(dialogid == AGEMENU) { if(response) { if(strlen(inputtext)>=2) { //format(query, sizeof(query), "UPDATE accounts SET psex=%d WHERE name='%s'", (response) ? 1 : 2, name); //sql new name[MAX_PLAYER_NAME],query[128],page[10]; GetPlayerName(playerid,name,sizeof(name)); new input = mysql_escape_string(inputtext,page,sqlconnect); format(query,sizeof(query),"UPDATE accounts SET page='input' WHERE name='%s' ",name,page); mysql_function_query(sqlconnect,query,false,"",""); //-------- ShowPlayerDialog(playerid, EMAILMENU, DIALOG_STYLE_INPUT, "{00C0FF}El.pasto adresas", "{FFFFFF}Iveskite savo el.pasto adresa ?\n\n{FFF1AF}El.pasto adresas bus reikalingas jeigu pamirsite slaptazodi", "Submit", "Cancel"); } else { SendClientMessage(playerid,COLOR_RED,"Neivedete amziaus arba jusu amzius nera tinkamas "); ShowPlayerDialog(playerid, AGEMENU, DIALOG_STYLE_INPUT, "{00C0FF}Amzius", "{FFFFFF}Kiek jums metu ?", "Submit", "Cancel"); } return 1; } }
if(dialogid == AGEMENU) { if(response) { if(strlen(inputtext)>=2) { //sql new name[MAX_PLAYER_NAME],query[128]; GetPlayerName(playerid,name,sizeof(name)); format(query,sizeof(query),"UPDATE accounts SET page = '%d' WHERE name='%s'", inputtext,name); mysql_function_query(sqlconnect,query,false,"",""); //-------- ShowPlayerDialog(playerid, EMAILMENU, DIALOG_STYLE_INPUT, "{00C0FF}El.pasto adresas", "{FFFFFF}Iveskite savo el.pasto adresa ?\n\n{FFF1AF}El.pasto adresas bus reikalingas jeigu pamirsite slaptazodi", "Submit", "Cancel"); } else { SendClientMessage(playerid,COLOR_RED,"Neivedete amziaus arba jusu amzius nera tinkamas "); ShowPlayerDialog(playerid, AGEMENU, DIALOG_STYLE_INPUT, "{00C0FF}Amzius", "{FFFFFF}Kiek jums metu ?", "Submit", "Cancel"); } return 1; }