24.05.2012, 12:10
Can some one give me a good and simple register/login system for RP server ? PLS
if (strcmp(cmd, "/register", true)==0) { new string[265]; tmp = strtok(cmdtext, idx); if(!strlen(tmp)) { SendClientMessage(playerid, grey, "USAGE: /register [password]"); return 1; } if (gPlayerAccount[playerid] == 1) { SendClientMessage(playerid, grey, " That nickname is already registered"); return 1; } strmid(PlayerInfo[playerid][pPassword], tmp, 0, strlen(cmdtext), 255); String(PlayerInfo[playerid][pPassword]); GetPlayerName(playerid, playername, sizeof(playername)); format(string, sizeof(string), "%s.cer", playername); new File: file = fopen(string, io_read); if (file) { SendClientMessage(playerid, 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, "Level:%d\n",PlayerInfo[playerid][pLevel]);fwrite(hFile, var); format(var, 32, "Exp:%d\n",PlayerInfo[playerid][pExp]);fwrite(hFile, var); PlayerInfo[playerid][pCash] = GetPlayerMoney(playerid); format(var, 32, "Cash:%d\n",PlayerInfo[playerid][pCash]);fwrite(hFile, var); fclose(hFile); SendClientMessage(playerid, white, "Succesfully Registered!"); SendClientMessage(playerid, white, "Next time when you come , use /login [ password ]."); OnPlayerLogin(playerid,PlayerInfo[playerid][pPassword]); return 1; } |
if (strcmp(cmd, "/login", true) ==0 ) { if(IsPlayerConnected(playerid)) { new tmppass[64]; if(gPlayerLogged[playerid] == 1) { SendClientMessage(playerid, grey, " You are already logged in."); return 1; } tmp = strtok(cmdtext, idx); if(!strlen(tmp)) { SendClientMessage(playerid, grey, " USAGE: /login [password]"); return 1; } strmid(tmppass, tmp, 0, strlen(cmdtext), 255); String(tmppass); OnPlayerLogin(playerid,tmppass); } return 1; } |