public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]) { switch( dialogid ) { case DIALOG_REGISTER: { if (!response) return Kick(playerid); if(response) { if(!strlen(inputtext)) return ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, ""COL_WHITE"reg",""COL_WHITE"bad pass.\n"COL_WHITE"type pass to reg.","reg","exit"); new INI:File = INI_Open(UserPath(playerid)); INI_SetTag(File,"data"); INI_WriteInt(File,"Password",udb_hash(inputtext)); INI_WriteInt(File,"Cash",0); INI_WriteInt(File,"Admin",0); INI_WriteInt(File,"Age",0); INI_WriteInt(File,"Sex",2); INI_WriteInt(File,"Skin",0); INI_WriteInt(File,"Location",0); INI_Close(File); ShowPlayerDialog(playerid, DIALOG_AGE, DIALOG_STYLE_INPUT,"Age?","\nType age using numbers.","ok",""); } } case DIALOG_AGE: { if(!response) return Kick(playerid); if(response) { new age, message[64]; age = strval(inputtext); if(age < 13 || age > 70) { ShowPlayerDialog(playerid, DIALOG_AGE, DIALOG_STYLE_INPUT,"Age?","Type age using numbers.","Ok",""); SendClientMessage(playerid, 0x33CCFFAA, "at least 13 years!"); } else { PlayerInfo[playerid][pAge] = age; SendClientMessage(playerid, 0x33CCFFAA, message); ShowPlayerDialog(playerid, DIALOG_SEX, DIALOG_STYLE_LIST,"male or female","male\nfemale","Ok",""); } } } case DIALOG_SEX: { if(response) { if(listitem == 0) { PlayerInfo[playerid][pSex] = 0; PlayerInfo[playerid][pSkin] = 20; printf("Skin has been set to 20"); ShowPlayerDialog(playerid, DIALOG_LOCATION, DIALOG_STYLE_LIST,"spawn","LS ","OK",""); } if(listitem == 1) { PlayerInfo[playerid][pSex] = 1; PlayerInfo[playerid][pSkin] = 12; printf("Skin has been set to 12"); ShowPlayerDialog(playerid, DIALOG_LOCATION, DIALOG_STYLE_LIST,"SPAWN","LOS SANTOS","OK",""); } } } case DIALOG_LOCATION: { if(!response) return Kick(playerid); if(response) { new message[64]; if(listitem == 0) { PlayerInfo[playerid][pLocation] = 0; format(message, sizeof(message), "MSG"); SendClientMessage(playerid, 0xFFFFFFFF, message); SetSpawnInfo(playerid, 0, PlayerInfo[playerid][pSkin], 1713.6101,-1912.2190,13.5669,85.9081, 0, 0, 0, 0, 0, 0); SpawnPlayer(playerid); } if(listitem == 1) { PlayerInfo[playerid][pLocation] = 1; format(message, sizeof(message), "MSG"); SendClientMessage(playerid, 0xFFFFFFFF, message); SetSpawnInfo(playerid, 0, PlayerInfo[playerid][pSkin], 1642.1584, -2334.1926, -2.6797, 359.7559, 0, 0, 0, 0, 0, 0); SpawnPlayer(playerid); } if(listitem == 2) { PlayerInfo[playerid][pLocation] = 2; format(message, sizeof(message), "MSG"); SendClientMessage(playerid, 0xFFFFFFFF, message); SetSpawnInfo(playerid, 0, PlayerInfo[playerid][pSkin], 1642.1584, -2334.1926, -2.6797, 359.7559, 0, 0, 0, 0, 0, 0); SpawnPlayer(playerid); } } } case DIALOG_LOGIN: { if ( !response ) return Kick ( playerid ); if( response ) { if(udb_hash(inputtext) == PlayerInfo[playerid][pPass]) { INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid); GivePlayerMoney(playerid, PlayerInfo[playerid][pCash]); SetSpawnInfo(playerid, 0, PlayerInfo[playerid][pSkin], 1642.1584, -2334.1926, -2.6797, 359.7559, 0, 0, 0, 0, 0, 0); SpawnPlayer(playerid); } else { Kick(playerid); } return 1; } } } return 1; }
// Check the file opened correctly
if (myFile != INI_NO_FILE)
if(fexist(UserPath(playerid))) return ShowPlayerDialog(playerid, DIALOG_REG, DIALOG_STYLE_MSGBOX, "error", "you are alredy regisred!", "ok", ""); |
[data] Location = 0 Skin = 20 Sex = 0 Age = 18 Admin = 0 Cash = 0 Password = 19726487
new INI:File = INI_Open(UserPath(playerid)); INI_SetTag(File,"data"); INI_WriteInt(File,"Cash",GetPlayerMoney(playerid)); INI_WriteInt(File,"Admin",PlayerInfo[playerid][pAdmin]); INI_WriteInt(File,"Age",PlayerInfo[playerid][pAge]); INI_WriteInt(File,"Sex", PlayerInfo[playerid][pSex]); INI_WriteInt(File,"Skin", PlayerInfo[playerid][pSkin]); INI_WriteInt(File,"Location", PlayerInfo[playerid][pLocation]); INI_Close(File);
forward LoadUser_data(playerid,name[],value[]); public LoadUser_data(playerid,name[],value[]) { INI_Int("Password",PlayerInfo[playerid][pPass]); INI_Int("Cash",PlayerInfo[playerid][pCash]); INI_Int("Admin",PlayerInfo[playerid][pAdmin]); INI_Int("Sex", PlayerInfo[playerid][pSex]); INI_Int("Age",PlayerInfo[playerid][pAge]); INI_Int("Skin", PlayerInfo[playerid][pSkin]); INI_Int("Location", PlayerInfo[playerid][pLocation]); return 1; }