21.02.2009, 12:46
Hey, I created a login and register script using pStats etc... now I went to test today with my team and I realised that only two people can login/register, I have no idea why, if ID 0 and 1 are taken, and ID 2 joins and types /register <pass> it doesnt say anything, if he tries /login <pass> it says 'please login'
(Note this code was not stolen it was created by the Lethotas scripting team and remains property of the Lethotas Scripting team)
Register
Login:
Pastebin link: http://pastebin.com/dfe2771d
- Paladin
(Note this code was not stolen it was created by the Lethotas scripting team and remains property of the Lethotas Scripting team)
Register
Код:
if (strcmp(cmd, "/register", true) == 0) { if(IsPlayerConnected(playerid)) { if(pInfo[playerid][pLoggedin] == 1) { SendClientMessage(playerid,COLOR_LIGHTGREEN,"SERVER: You are already logged in."); return 1; } new File: hFile = fopen(pFilename[playerid], io_read); if(hFile) { SendClientMessage(playerid,COLOR_LIGHTGREEN,"SERVER: That name is already registered, try another one"); Kick(playerid); return 1; } tmp = strtok(cmdtext, idx); if(!strlen(tmp)){ SendClientMessage(playerid, COLOR_LIGHTGREEN, "USAGE: /REGISTER [PASSWORD]"); return 1; } new File: account = fopen(pFilename[playerid], io_write); if (account) { strmid(pInfo[playerid][pPassword], tmp, 0, strlen(tmp), 255); new file[128]; { format(file, sizeof file, "Password: %s\n\r", pInfo[playerid][pPassword]); { fwrite(account, file); } format(file, sizeof file, "AdminLevel: %d\n\r",pInfo[playerid][pAdmin]); { fwrite(account, file); } format(file, sizeof file, "Needs Greeter Help: %d\n\r",pInfo[playerid][pHelp]); { fwrite(account, file); } format(file, sizeof file, "Greeter Duty: %d\n\r",pInfo[playerid][pGduty]); { fwrite(account, file); } format(file, sizeof file, "Greeter: %d\n\r",pInfo[playerid][pGreeter]); { fwrite(account, file); } format(file, sizeof file, "Cash: %d\n\r", pInfo[playerid][pCash]); { fwrite(account, file); } format(file, sizeof file, "Cop Rank: %d\n\r", pInfo[playerid][pCop]); { fwrite(account, file); } format(file, sizeof file, "Medic rank: %d\n\r", pInfo[playerid][pMedic]); { fwrite(account, file); } format(file, sizeof file, "Agent Rank: %d\n\r", pInfo[playerid][pAgent]); { fwrite(account, file); } format(file, sizeof file, "Presidential Security: %d\n\r", pInfo[playerid][pPS]); { fwrite(account, file); } format(file, sizeof file, "On Duty: %d\n\r", pInfo[playerid][pDuty]); { fwrite(account, file); } format(file, sizeof file, "Jailed: %d\n\r", pInfo[playerid][pJail]); { fwrite(account, file); } format(file, sizeof file, "Drivers License: %d\n\r", pInfo[playerid][pLicense]); { fwrite(account, file); } format(file, sizeof file, "Passport: %d\n\r", pInfo[playerid][pPassport]); { fwrite(account, file); } format(file, sizeof file, "Muted: %d\n\r", pInfo[playerid][pMute]); { fwrite(account, file); } format(file, sizeof file, "Skin: %d\n\r", pInfo[playerid][pSkin]); { fwrite(account, file); } format(file, sizeof file, "Duty Skin: %d\n\r", pInfo[playerid][pDutySkin]); { fwrite(account, file); } format(file, sizeof file, "Wanted: %d\n\r", pInfo[playerid][pWanted]); { fwrite(account, file); } format(file, sizeof file, "Car: %d\n\r", pInfo[playerid][pCar]); { fwrite(account, file); } format(file, sizeof file, "Car Locked/Unlocked: %d\n\r", pInfo[playerid][pCarLocked]); { fwrite(account, file); } } fclose(account); SendClientMessage(playerid,COLOR_LIGHTGREEN,"SERVER: Your account has been successfully registered"); SendClientMessage(playerid,COLOR_LIGHTGREEN,"SERVER: You have been auto logged in"); pInfo[playerid][pLoggedin] = 1; SpawnPlayer(playerid); SetPlayerSkin(playerid, 259); TogglePlayerControllable(playerid, true); } return 1; } }
Код:
if (strcmp(cmd, "/login",true) == 0) { if(pInfo[playerid][pLoggedin] == 1) // If player is already logged in. { SendClientMessage(playerid,COLOR_LIGHTGREEN,"SERVER: You are already logged in!"); return 1; } tmp = strtok(cmdtext, idx); // Retrieves the second argument of /LOGIN and stores it in tmp if(!strlen(tmp)) // If only /LOGIN is typed without a password { SendClientMessage(playerid, COLOR_LIGHTGREEN, "USAGE: /LOGIN [PASSWORD]"); return 1; } if(!fexist(pFilename[playerid])) // If the account is not yet registered. { SendClientMessage(playerid, COLOR_LIGHTGREEN, "SERVER: That account is not yet registered, please use /REGISTER [PASSWORD]"); return 1; } new File:account = fopen(pFilename, io_read); if (account) { new pass[256]; new passres[128], value[128]; fread(account, pass, sizeof pass); passres = GetFileString(pass); if (!strcmp("Password", passres)) { value = GetFileValue(pass); strmid(pInfo[playerid][pPassword], value, 0, strlen(value)-1, 128); } if (!strcmp(pInfo[playerid][pPassword], tmp, true)) { while (fread(account, pass, 256)) { passres = GetFileString(pass); if (strfind(passres, "AdminLevel") != -1) // Retrieves the admin level { value = GetFileValue(pass); pInfo[playerid][pAdmin] = strval(value); } if (strfind(passres, "Cash") != -1) // Retrieves the stored cash amount { value = GetFileValue(pass); pInfo[playerid][pCash] = strval(value); } } fclose(account); pInfo[playerid][pLoggedin] = 1; } else { SendClientMessage(playerid, COLOR_LIGHTGREEN, "SERVER: Incorrect Password."); fclose(account); return 1; } GivePlayerMoney(playerid, pInfo[playerid][pCash]); format(str, sizeof str, "SERVER: You are now logged in!"); SendClientMessage(playerid, COLOR_LIGHTGREEN, str); TogglePlayerControllable(playerid, true); SpawnPlayer(playerid); SetPlayerSkin(playerid, pInfo[playerid][pSkin]); if (pInfo[playerid][pAdmin] > 0) { format(str, sizeof str, "SERVER: You logged in as a level %d admin!", pInfo[playerid][pAdmin]); SendClientMessage(playerid, COLOR_YELLOW, str); } new string[128]; new tmpname[128]; if(pInfo[playerid][pJail] == 1) { SetPlayerPos(playerid, 1950.3784,-4959.1797,1.3590); TogglePlayerControllable(playerid, false); SendClientMessage(playerid, COLOR_LIGHTRED, "You logged in and were jailed!"); format(string, sizeof(string), "[A] %s(%d) has logged in and was jailed", tmpname, playerid); SendClientMessageToAdmins(COLOR_YELLOW, string, 1); } } else { SendClientMessage(playerid, COLOR_LIGHTGREEN, "SERVER: That account is not yet registered, please use /REGISTER [PASSWORD]"); return 1; } }
- Paladin