Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function servercmdNewAccount(%client, %username, %password)
- {
- if(%client.username !$= "")
- {
- messageClient(%client, 'MsgAccountCreationFailure', "You are already logged in. Please log out before creating a new account.");
- return;
- }
- if(getLineCount("ennRP/server/accounts/"@ strLwr(%username) @".txt"))
- {
- messageClient(%client, 'MsgAccountCreationFailure', "Sorry, but that username has already been taken. Please choose another username.");
- return;
- }
- if(getLineCount("ennRP/server/accounts/"@ strLwr(%username) @".txt"))
- {
- messageClient(%client, 'MsgAccountCreationFailure', "Sorry, but that username has already been taken. Please choose another username.");
- return;
- }
- if(strLen(%userName) < 5)
- {
- messageClient(%client, 'MsgAccountCreationFailure', "Sorry, but your username must have at least 5 characters. Please choose a longer username.");
- return;
- }
- if(strLen(%password) < 6)
- {
- messageClient(%client, 'MsgAccountCreationFailure', "Sorry, but your password must have at least 6 characters. Please choose a longer password.");
- return;
- }
- %client.username = %username;
- %client.password = %password;
- %client.setStuds(100);
- %client.level = 1;
- %client.class = 1;
- messageClient(%client, 'MsgAccountCreation',
- "Your new account has been created. Your username is" SPC %username @ ".\n"@
- "Your password is" SPC %password @ ". Don't forget your password. It's important.");
- }
- function servercmdLogin(%client, %username, %password)
- {
- if(!getLineCount("ennRP/server/accounts/"@ strLwr(%username) @".txt"))
- {
- messageClient(%client, 'MsgAccountLoginFailure', "Sorry, but that account does not exist. Please verify that you have spelled your username correctly.");
- return;
- }
- if(!isObject(%f = EnnRP_FileObject))
- %f = new FileObject(EnnRp_FileObject);
- %f.openForRead("ennRP/server/accounts/"@ strLwr(%username) @".txt");
- %n = %f.readLine();.
- if(%password !$= %f.readLine())
- {
- messageClient(%client, 'MsgAccountLoginFailure', "Sorry, but your password is incorrect. Please verify that you have typed your password in correctly.");
- %f.close();
- return;
- }
- //Success
- messageClient(%client, 'MsgAccountLogin', "You have successfully logged in.");
- %client.username = %n;
- %client.password = %password;
- %client.setStuds(%f.readLine());
- %client.level = %f.readLine();
- %client.class = %f.readLine();
- %client.colorSkin = %f.readLine();
- %client.headCode = %f.readLine();
- %client.visorCode = %f.readLine();
- %client.backCode = %f.readLine();
- %client.leftHandCode = %f.readLine();
- %client.chestCode = chestShowImage;
- %client.faceCode = faceplateShowImage;
- %client.headCodeColor = addTaggedString($legoColor[%f.readLine()]);
- %client.visorCodeColor = addTaggedString($legoColor[%f.readLine()]);
- %client.backCodeColor = addTaggedString($legoColor[%f.readLine()]);
- %client.leftHandCodeColor = addTaggedString($legoColor[%f.readLine()]);
- %client.chestdecalcode = addTaggedString(%f.readLine());
- %client.facedecalcode = addTaggedString(%f.readLine());
- %client.bodytype = %f.readLine();
- servercmdarmsncrotch(%client,%client.bodytype);
- if(isObject(%player = %client.player))
- {
- %player.unMountImage($headSlot);
- %player.unMountImage($visorSlot);
- %player.unMountImage($backSlot);
- %player.unMountImage($leftHandSlot);
- %player.unMountImage($chestSlot);
- %player.unMountImage($faceSlot);
- %player.unMountImage(7);
- if(%client.team $= "")
- %player.setSkinName(%client.colorSkin);
- %player.mountImage(%client.headCode, $headSlot, 1, %client.headCodeColor);
- %player.mountImage(%client.visorCode, $visorSlot, 1, %client.visorCodeColor);
- %player.mountImage(%client.backCode, $backSlot, 1, %client.backCodeColor);
- %player.mountImage(%client.leftHandCode, $leftHandSlot, 1, %client.leftHandCodeColor);
- %player.mountImage(%client.chestCode, $chestSlot, 1, %client.chestdecalcode);
- %player.mountImage(%client.faceCode, $faceSlot, 1, %client.facedecalcode);
- }
- //Inventory
- %client.primaryWeapon = %f.readLine();
- %client.secondaryWeapon = %f.readLine();
- %client.Chest = %f.readLine();
- %client.Helmet = %f.readLine();
- %client.Ammo = %f.readLine();
- if(isObject(%client.player))
- { //These should probably be saved to the player
- %client.player.primaryWeapon = %client.primaryWeapon;
- %client.player.secondaryWeapon = %client.secondaryWeapon;
- %client.player.Chest = %client.Chest;
- %client.player.Helmet = %client.Helmet;
- %client.player.Ammo = %client.Ammo;
- }
- for(%x = 1; %x <= 28; %x++)
- %client.inventory[%x] = %f.readLine();
- %client.guild = %f.readLine();
- %f.close();
- if(!guildExists(%client.guild))
- {
- %client.guild = "";
- messageClient(%client,'MsgLeaveGuild', "Your, uh, guild got dissolved while you were gone. You can go join another guild or create your own now.");
- saveAccount(%client);
- }
- }
- function saveAccount(%client) {
- echo("Saveaccount called.");
- if(%client.username $= "")
- {
- echo("Error in saving account: client" SPC %client SPC "is not logged in.");
- return;
- }
- if(!isObject(%f = EnnRP_FileObject))
- %f = new FileObject(EnnRp_FileObject);
- %f.openForWrite("ennRP/server/accounts/"@ strLwr(%client.username) @".txt");
- %f.writeLine(%client.userName);
- %f.writeLine(%client.password);
- %f.writeLine(%client.studMoney);
- %f.writeLine(%client.level);
- %f.writeLine(%client.class);
- %f.writeLine(%client.colorSkin);
- %f.writeLine(%client.headCode);
- %f.writeLine(%client.visorCode);
- %f.writeLine(%client.backCode);
- %f.writeLine(%client.leftHandCode);
- %f.writeLine(%client.headCodeColorCode);
- %f.writeLine(%client.visorCodeColorCode);
- %f.writeLine(%client.backCodeColorCode);
- %f.writeLine(%client.leftHandCodeColorCode);
- %f.writeLine(%client.chestDecalCodeCode);
- %f.writeLine(%client.faceDecalCodeCode);
- %f.writeLine(%client.bodyType);
- %f.writeLine(%client.primaryWeapon);
- %f.writeLine(%client.secondaryWeapon);
- %f.writeLine(%client.chest);
- %f.writeLine(%client.helmet);
- %f.writeLine(%client.ammo);
- for(%x = 1; %x <= 28; %x++)
- %f.writeLine(%client.inventory[%x]);
- %f.writeLine(%client.guild);
- %f.close();
- }
- function setEnnRP()
- {
- setModPaths("fps;dtb;tbm;common;ennRP");
- }
- function ServerCmdUpdatePrefs(%client, %name, %skin, %headCode, %visorCode, %backCode, %leftHandCode, %headCodeColor, %visorCodeColor, %backCodeColor, %leftHandCodeColor, %chestdecalcode, %facedecalcode, %bodytype)
- {
- %client.headCodeColorCode = %headCodeColor;
- %client.visorCodeColorCode = %visorCodeColor;
- %client.backCodeColorCode = %backCodeColor;
- %client.leftHandCodeColorCode = %leftHandCodeColor;
- %client.chestdecalcodeCode = %chestdecalcode;
- %client.facedecalcodeCode = %facedecalcode;
- Parent::ServerCmdUpdatePrefs(%client, %name, %skin, %headCode, %visorCode, %backCode, %leftHandCode, %headCodeColor, %visorCodeColor, %backCodeColor, %leftHandCodeColor, %chestdecalcode, %facedecalcode, %bodytype);
- }
- function GameConnection::onDrop(%client, %reason)
- {
- if(%client.username !$= "")
- saveAccount(%client);
- Parent::onDrop(%client, %reason);
- }
- function saveBlocks(%a, %b)
- {
- echo("saveBlocks");
- for(%i = 0; %i < ClientGroup.getCount(); %i++ )
- {
- if(ClientGroup.getObject(%i).username !$= "")
- saveAccount(ClientGroup.getObject(%i));
- }
- Parent::saveBlocks(%a, %b);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement