Advertisement
Guest User

Untitled

a guest
Sep 23rd, 2017
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.36 KB | None | 0 0
  1. function servercmdNewAccount(%client, %username, %password)
  2. {
  3. if(%client.username !$= "")
  4. {
  5. messageClient(%client, 'MsgAccountCreationFailure', "You are already logged in. Please log out before creating a new account.");
  6. return;
  7. }
  8.  
  9. if(getLineCount("ennRP/server/accounts/"@ strLwr(%username) @".txt"))
  10. {
  11. messageClient(%client, 'MsgAccountCreationFailure', "Sorry, but that username has already been taken. Please choose another username.");
  12. return;
  13. }
  14. if(getLineCount("ennRP/server/accounts/"@ strLwr(%username) @".txt"))
  15. {
  16. messageClient(%client, 'MsgAccountCreationFailure', "Sorry, but that username has already been taken. Please choose another username.");
  17. return;
  18. }
  19. if(strLen(%userName) < 5)
  20. {
  21. messageClient(%client, 'MsgAccountCreationFailure', "Sorry, but your username must have at least 5 characters. Please choose a longer username.");
  22. return;
  23. }
  24. if(strLen(%password) < 6)
  25. {
  26. messageClient(%client, 'MsgAccountCreationFailure', "Sorry, but your password must have at least 6 characters. Please choose a longer password.");
  27. return;
  28. }
  29. %client.username = %username;
  30. %client.password = %password;
  31. %client.setStuds(100);
  32. %client.level = 1;
  33. %client.class = 1;
  34. messageClient(%client, 'MsgAccountCreation',
  35. "Your new account has been created. Your username is" SPC %username @ ".\n"@
  36. "Your password is" SPC %password @ ". Don't forget your password. It's important.");
  37.  
  38. }
  39.  
  40. function servercmdLogin(%client, %username, %password)
  41. {
  42. if(!getLineCount("ennRP/server/accounts/"@ strLwr(%username) @".txt"))
  43. {
  44. messageClient(%client, 'MsgAccountLoginFailure', "Sorry, but that account does not exist. Please verify that you have spelled your username correctly.");
  45. return;
  46. }
  47. if(!isObject(%f = EnnRP_FileObject))
  48. %f = new FileObject(EnnRp_FileObject);
  49. %f.openForRead("ennRP/server/accounts/"@ strLwr(%username) @".txt");
  50. %n = %f.readLine();.
  51. if(%password !$= %f.readLine())
  52. {
  53. messageClient(%client, 'MsgAccountLoginFailure', "Sorry, but your password is incorrect. Please verify that you have typed your password in correctly.");
  54. %f.close();
  55. return;
  56. }
  57.  
  58. //Success
  59.  
  60. messageClient(%client, 'MsgAccountLogin', "You have successfully logged in.");
  61. %client.username = %n;
  62. %client.password = %password;
  63. %client.setStuds(%f.readLine());
  64. %client.level = %f.readLine();
  65. %client.class = %f.readLine();
  66.  
  67. %client.colorSkin = %f.readLine();
  68. %client.headCode = %f.readLine();
  69. %client.visorCode = %f.readLine();
  70. %client.backCode = %f.readLine();
  71. %client.leftHandCode = %f.readLine();
  72. %client.chestCode = chestShowImage;
  73. %client.faceCode = faceplateShowImage;
  74. %client.headCodeColor = addTaggedString($legoColor[%f.readLine()]);
  75. %client.visorCodeColor = addTaggedString($legoColor[%f.readLine()]);
  76. %client.backCodeColor = addTaggedString($legoColor[%f.readLine()]);
  77. %client.leftHandCodeColor = addTaggedString($legoColor[%f.readLine()]);
  78. %client.chestdecalcode = addTaggedString(%f.readLine());
  79. %client.facedecalcode = addTaggedString(%f.readLine());
  80. %client.bodytype = %f.readLine();
  81. servercmdarmsncrotch(%client,%client.bodytype);
  82. if(isObject(%player = %client.player))
  83. {
  84. %player.unMountImage($headSlot);
  85. %player.unMountImage($visorSlot);
  86. %player.unMountImage($backSlot);
  87. %player.unMountImage($leftHandSlot);
  88. %player.unMountImage($chestSlot);
  89. %player.unMountImage($faceSlot);
  90. %player.unMountImage(7);
  91. if(%client.team $= "")
  92. %player.setSkinName(%client.colorSkin);
  93. %player.mountImage(%client.headCode, $headSlot, 1, %client.headCodeColor);
  94. %player.mountImage(%client.visorCode, $visorSlot, 1, %client.visorCodeColor);
  95. %player.mountImage(%client.backCode, $backSlot, 1, %client.backCodeColor);
  96. %player.mountImage(%client.leftHandCode, $leftHandSlot, 1, %client.leftHandCodeColor);
  97. %player.mountImage(%client.chestCode, $chestSlot, 1, %client.chestdecalcode);
  98. %player.mountImage(%client.faceCode, $faceSlot, 1, %client.facedecalcode);
  99. }
  100. //Inventory
  101. %client.primaryWeapon = %f.readLine();
  102. %client.secondaryWeapon = %f.readLine();
  103. %client.Chest = %f.readLine();
  104. %client.Helmet = %f.readLine();
  105. %client.Ammo = %f.readLine();
  106. if(isObject(%client.player))
  107. { //These should probably be saved to the player
  108. %client.player.primaryWeapon = %client.primaryWeapon;
  109. %client.player.secondaryWeapon = %client.secondaryWeapon;
  110. %client.player.Chest = %client.Chest;
  111. %client.player.Helmet = %client.Helmet;
  112. %client.player.Ammo = %client.Ammo;
  113. }
  114. for(%x = 1; %x <= 28; %x++)
  115. %client.inventory[%x] = %f.readLine();
  116. %client.guild = %f.readLine();
  117. %f.close();
  118.  
  119.  
  120. if(!guildExists(%client.guild))
  121. {
  122. %client.guild = "";
  123. messageClient(%client,'MsgLeaveGuild', "Your, uh, guild got dissolved while you were gone. You can go join another guild or create your own now.");
  124. saveAccount(%client);
  125. }
  126.  
  127. }
  128.  
  129. function saveAccount(%client) {
  130. echo("Saveaccount called.");
  131. if(%client.username $= "")
  132. {
  133. echo("Error in saving account: client" SPC %client SPC "is not logged in.");
  134. return;
  135. }
  136.  
  137. if(!isObject(%f = EnnRP_FileObject))
  138. %f = new FileObject(EnnRp_FileObject);
  139. %f.openForWrite("ennRP/server/accounts/"@ strLwr(%client.username) @".txt");
  140. %f.writeLine(%client.userName);
  141. %f.writeLine(%client.password);
  142. %f.writeLine(%client.studMoney);
  143. %f.writeLine(%client.level);
  144. %f.writeLine(%client.class);
  145. %f.writeLine(%client.colorSkin);
  146. %f.writeLine(%client.headCode);
  147. %f.writeLine(%client.visorCode);
  148. %f.writeLine(%client.backCode);
  149. %f.writeLine(%client.leftHandCode);
  150. %f.writeLine(%client.headCodeColorCode);
  151. %f.writeLine(%client.visorCodeColorCode);
  152. %f.writeLine(%client.backCodeColorCode);
  153. %f.writeLine(%client.leftHandCodeColorCode);
  154. %f.writeLine(%client.chestDecalCodeCode);
  155. %f.writeLine(%client.faceDecalCodeCode);
  156. %f.writeLine(%client.bodyType);
  157. %f.writeLine(%client.primaryWeapon);
  158. %f.writeLine(%client.secondaryWeapon);
  159. %f.writeLine(%client.chest);
  160. %f.writeLine(%client.helmet);
  161. %f.writeLine(%client.ammo);
  162. for(%x = 1; %x <= 28; %x++)
  163. %f.writeLine(%client.inventory[%x]);
  164. %f.writeLine(%client.guild);
  165. %f.close();
  166. }
  167.  
  168.  
  169.  
  170. function setEnnRP()
  171. {
  172. setModPaths("fps;dtb;tbm;common;ennRP");
  173. }
  174.  
  175.  
  176. function ServerCmdUpdatePrefs(%client, %name, %skin, %headCode, %visorCode, %backCode, %leftHandCode, %headCodeColor, %visorCodeColor, %backCodeColor, %leftHandCodeColor, %chestdecalcode, %facedecalcode, %bodytype)
  177. {
  178. %client.headCodeColorCode = %headCodeColor;
  179. %client.visorCodeColorCode = %visorCodeColor;
  180. %client.backCodeColorCode = %backCodeColor;
  181. %client.leftHandCodeColorCode = %leftHandCodeColor;
  182. %client.chestdecalcodeCode = %chestdecalcode;
  183. %client.facedecalcodeCode = %facedecalcode;
  184. Parent::ServerCmdUpdatePrefs(%client, %name, %skin, %headCode, %visorCode, %backCode, %leftHandCode, %headCodeColor, %visorCodeColor, %backCodeColor, %leftHandCodeColor, %chestdecalcode, %facedecalcode, %bodytype);
  185. }
  186.  
  187.  
  188. function GameConnection::onDrop(%client, %reason)
  189. {
  190. if(%client.username !$= "")
  191. saveAccount(%client);
  192. Parent::onDrop(%client, %reason);
  193. }
  194.  
  195. function saveBlocks(%a, %b)
  196. {
  197. echo("saveBlocks");
  198. for(%i = 0; %i < ClientGroup.getCount(); %i++ )
  199. {
  200. if(ClientGroup.getObject(%i).username !$= "")
  201. saveAccount(ClientGroup.getObject(%i));
  202. }
  203. Parent::saveBlocks(%a, %b);
  204. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement