01.12.2009, 15:41
Код:
Hello everybody I want that when player types /register so there is a folder or something else in which his name gets stored and when he again connect the server so no need for again /register [PAWN code]if(strcmp(cmd, "/register", true) == 0) { new tmp[256]; tmp = strtok(cmdtext, idx); if(!strlen(tmp)) { SendClientMessage(playerid, COLOR_WHITE, "USAGE: /register [password]"); } else { if (!dini_Exists(udb_encode(playername))) { dini_Create(udb_encode(playername)); dini_IntSet(udb_encode(playername), "password", udb_hash(tmp)); format(string, sizeof(string), "Account %s created! You can now login with /login %s", playername, tmp); SendClientMessage(playerid, COLOR_YELLOW, string); adminlevel[playerid] = -1; } else { format(string, sizeof(string), "%s is already registered.", playername,tmp); SendClientMessage(playerid, COLOR_BRIGHTRED, string); } } return 1; } if(strcmp(cmd, "/login", true) == 0) { new tmp[256], tmp2[256]; if(logged[playerid] == 1) { SendClientMessage(playerid, COLOR_BRIGHTRED, "You are already logged in."); return 1; } tmp = strtok(cmdtext, idx); if(!strlen(tmp)) { SendClientMessage(playerid, COLOR_WHITE, "USAGE: /login [password]"); } else { if (dini_Exists(udb_encode(playername))) { tmp2 = dini_Get(udb_encode(playername), "password"); if (udb_hash(tmp) != strval(tmp2)) { SendClientMessage(playerid, COLOR_BRIGHTRED, "Invalid Password"); } else { logged[playerid] = 1; format(string, sizeof(string), "%s, you are now logged in .", playername); SendClientMessage(playerid, COLOR_GREEN, string); GivePlayerMoney(playerid, money[playerid]); } } else { format(string, sizeof(string), "You are not registered Type /register [password] to create an account!", playername); SendClientMessage(playerid, COLOR_BRIGHTRED, string); } } return 1; }