25.10.2009, 22:55
Hey,
I'm really stuck with the dialog login and register box. Can someone guide me a little on how to do it.
My /login:
My /register:
Any help appericated
Thanks,
I'm really stuck with the dialog login and register box. Can someone guide me a little on how to do it.
My /login:
Code:
new tmp[256]; new playername[MAX_PLAYER_NAME]; if (strcmp(cmd, "/login", true) ==0 ) { if(IsPlayerConnected(playerid)) { new tmppass[64]; if(gPlayerLogged[playerid] == 1) { SendClientMessage(playerid, COLOR_GREY, " You are already logged in."); return 1; } tmp = strtok(cmdtext, idx); if(!strlen(tmp)) { SendClientMessage(playerid, COLOR_GREY, " USAGE: /login [password]"); return 1; } strmid(tmppass, tmp, 0, strlen(cmdtext), 255); OnPlayerLogin(playerid,tmppass); } return 1;
Code:
if (strcmp(cmd, "/register", true)==0) { new string[265]; tmp = strtok(cmdtext, idx); if(!strlen(tmp)) { SendClientMessage(playerid, COLOR_GREY, "USAGE: /register [password]"); return 1; } if (gPlayerAccount[playerid] == 1) { SendClientMessage(playerid, COLOR_GREY, " That name is already registered"); return 1; } strmid(PlayerInfo[playerid][pPassword], tmp, 0, strlen(cmdtext), 255); GetPlayerName(playerid, playername, sizeof(playername)); format(string, sizeof(string), "%s.ini", playername); new File: file = fopen(string, io_read); if (file) { SendClientMessage(playerid, COLOR_GREY, " That name is already registered"); fclose(file); return 1; } new File:hFile; hFile = fopen(string, io_append); new var[32];// format(var, 32, "%s\n", PlayerInfo[playerid][pPassword]);fwrite(hFile, var); format(var, 32, "Rank=%d\n",PlayerInfo[playerid][pRank]);fwrite(hFile, var); format(var, 32, "Reborn=%d\n",PlayerInfo[playerid][pReborn]);fwrite(hFile, var); format(var, 32, "Exp=%d\n",PlayerInfo[playerid][pExp]);fwrite(hFile, var); format(var, 32, "van=%d\n",PlayerInfo[playerid][pVan]);fwrite(hFile, var); format(var, 32, "Kills=%d\n",PlayerInfo[playerid][pKills]);fwrite(hFile, var); format(var, 32, "TKills=%d\n",PlayerInfo[playerid][pTKills]);fwrite(hFile, var); format(var, 32, "GrenadeKills=%d\n",PlayerInfo[playerid][pGrenadekill]);fwrite(hFile, var); format(var, 32, "Mp5Kills=%d\n",PlayerInfo[playerid][pMp5kill]);fwrite(hFile, var); format(var, 32, "KnuckleKills=%d\n",PlayerInfo[playerid][pKnucklekill]);fwrite(hFile, var); format(var, 32, "MenuGoal=%d\n",PlayerInfo[playerid][pMenugoal]);fwrite(hFile, var); format(var, 32, "HeliGoal=%d\n",PlayerInfo[playerid][pHeligoal]);fwrite(hFile, var); format(var, 32, "Armourgoal=%d\n",PlayerInfo[playerid][pArmourgoal]);fwrite(hFile, var); format(var, 32, "Mapgoal=%d\n",PlayerInfo[playerid][pMapgoal]);fwrite(hFile, var); format(var, 32, "Deaths=%d\n",PlayerInfo[playerid][pDeaths]);fwrite(hFile, var); format(var, 32, "Admin=%d\n",PlayerInfo[playerid][pAdmin]);fwrite(hFile, var); format(var, 32, "GM=%d\n",PlayerInfo[playerid][pGM]);fwrite(hFile, var); format(var, 32, "Premium=%d\n",PlayerInfo[playerid][pPremium]);fwrite(hFile, var); format(var, 32, "Money=%d\n",PlayerInfo[playerid][pCash]);fwrite(hFile, var); fclose(hFile); SendClientMessage(playerid, COLOR_WHITE, "Succesfully Registered!"); SendClientMessage(playerid, COLOR_WHITE, "Next time you connect, type /login <password> to log in."); OnPlayerLogin(playerid,PlayerInfo[playerid][pPassword]); return 1; }
Thanks,