Advertisement
Guest User

Untitled

a guest
May 19th, 2017
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 11.12 KB | None | 0 0
  1. const
  2.     Color = $E56600;
  3.     BasicEp = 500;
  4.     PPL = 20;
  5.  
  6. var
  7.     LoggedIn : array[1..32] of boolean;
  8.     PwList : tstringarray;
  9.     //Integer arrays
  10.     Ep,
  11.     Level,
  12.     Mana,
  13.     ManaFull,
  14.     SkillPoints,
  15.     Skill1,
  16.     Skill2,
  17.     Skill3,
  18.     Skill4,
  19.     Skill5,
  20.     Skill6,
  21.     Skill7,
  22.     Skill8,
  23.     Skill9,
  24.     Skill10, Skill1Cool : array[1..32] of integer;
  25.     AccountName : array[1..32] of string;
  26.     GlobalID : integer;
  27.  
  28. function Implode(const AryStr: array of string; const Delimiter: string): string;
  29. var
  30.     i: word;
  31. begin
  32.     Result := '';
  33.     if (GetArrayLength(AryStr) > 0) then begin
  34.         for i := 0 to GetArrayLength(AryStr) - 1 do
  35.             Result := Result + AryStr[i] + Delimiter;
  36.         Delete(Result, Length(Result) - Length(Delimiter) + 1, Length(Delimiter));
  37.     end;
  38. end;
  39.    
  40. function Explode(Source: string; const Delimiter: string): array of string;
  41. var
  42.   Position, DelLength, ResLength: integer;
  43. begin
  44.   DelLength := Length(Delimiter);
  45.   Source := Source + Delimiter;
  46.   repeat
  47.     Position := Pos(Delimiter, Source);
  48.     SetArrayLength(Result, ResLength + 1);
  49.     Result[ResLength] := Copy(Source, 1, Position - 1);
  50.     ResLength := ResLength + 1;
  51.     Delete(Source, 1, Position + DelLength - 1);
  52.   until (Position = 0);
  53.   SetArrayLength(Result, ResLength - 1);
  54. end;
  55.  
  56. procedure ModifyFileLine(const Filename: string; const Line: word; const Content: string);
  57.  
  58. var
  59.     FileAryStr : array of string;
  60.     FileSource : string;
  61.    
  62. begin
  63.     FileSource := ReadFile(Filename);
  64.     FileAryStr := Explode(FileSource, #13#10);
  65.     FileAryStr[Line] := Content;
  66.     FileSource := Implode(FileAryStr, #13#10);
  67.     WriteFile(Filename, FileSource);
  68. end;
  69.  
  70. function deg2rad(deg: single): single;
  71. begin
  72.   result:=deg/(180/pi);
  73. end;
  74.  
  75. procedure Nova(X,Y,speed,decentralize,power: single; ID,style: byte; n: integer);
  76.  
  77. var i: integer;
  78. begin
  79.  
  80.   for i:=0 to n do
  81.     CreateBullet(X + (cos(deg2rad(360 / n * i))*decentralize),Y + (sin(deg2rad(360 / n * i))*decentralize),(cos(deg2rad(360 / n * i))*speed),(sin(deg2rad(360 / n * i))*speed),power,style,ID);
  82. end;
  83.  
  84. procedure GetStats(const FileName: string; const ID: byte);
  85. var
  86.     FileSource, Content : string;
  87.     FileAryStr : array of string;
  88.  
  89. begin
  90.     FileSource := ReadFile(FileName);
  91.     FileAryStr := Explode(FileSource, #13#10);
  92.     //Level
  93.     Content := FileAryStr[15];
  94.     Level[ID] := StrToInt(Copy(Content,7,length(Content)));
  95.     //Mana
  96.     Content := FileAryStr[16];
  97.     Mana[ID] := StrToInt(Copy(Content,6,length(Content)));
  98.     ManaFull[ID] := Mana[ID];
  99.     //SkillPoints
  100.     Content := FileAryStr[17];
  101.     SkillPoints[ID] := StrToInt(Copy(Content,13,length(Content)));
  102.     //Ep
  103.     Content := FileAryStr[18];
  104.     Ep[ID] := StrToInt(Copy(Content,4,length(Content)));
  105.     //Skills
  106.     Content := FileAryStr[4];
  107.     Skill1[ID] := StrToInt(Copy(Content,8,length(Content)));
  108.     Content := FileAryStr[5];
  109.     Skill2[ID] := StrToInt(Copy(Content,8,length(Content)));
  110.     Content := FileAryStr[6];
  111.     Skill3[ID] := StrToInt(Copy(Content,8,length(Content)));
  112.     Content := FileAryStr[7];
  113.     Skill4[ID] := StrToInt(Copy(Content,8,length(Content)));
  114.     Content := FileAryStr[8];
  115.     Skill5[ID] := StrToInt(Copy(Content,8,length(Content)));
  116.     Content := FileAryStr[9];
  117.     Skill6[ID] := StrToInt(Copy(Content,8,length(Content)));
  118.     Content := FileAryStr[10];
  119.     Skill7[ID] := StrToInt(Copy(Content,8,length(Content)));
  120.     Content := FileAryStr[11];
  121.     Skill8[ID] := StrToInt(Copy(Content,8,length(Content)));
  122.     Content := FileAryStr[12];
  123.     Skill9[ID] := StrToInt(Copy(Content,8,length(Content)));
  124.     Content := FileAryStr[13];
  125.     Skill10[ID] := StrToInt(Copy(Content,9,length(Content)));
  126. end;
  127.  
  128. procedure WriteStats(const FileName: string; const ID: byte);
  129.  
  130. begin
  131.     ModifyFileLine(FileName,4,'Skill1=' + IntToStr(Skill1[ID]));
  132.     ModifyFileLine(FileName,5,'Skill2=' + IntToStr(Skill2[ID]));
  133.     ModifyFileLine(FileName,6,'Skill3=' + IntToStr(Skill3[ID]));
  134.     ModifyFileLine(FileName,7,'Skill4=' + IntToStr(Skill4[ID]));
  135.     ModifyFileLine(FileName,8,'Skill5=' + IntToStr(Skill5[ID]));
  136.     ModifyFileLine(FileName,9,'Skill6=' + IntToStr(Skill6[ID]));
  137.     ModifyFileLine(FileName,10,'Skill7=' + IntToStr(Skill7[ID]));
  138.     ModifyFileLine(FileName,11,'Skill8=' + IntToStr(Skill8[ID]));
  139.     ModifyFileLine(FileName,12,'Skill9=' + IntToStr(Skill8[ID]));
  140.     ModifyFileLine(FileName,13,'Skill10=' + IntToStr(Skill10[ID]));
  141.     ModifyFileLine(FileName,15,'Level=' + IntToStr(Level[ID]));
  142.     ModifyFileLine(FileName,16,'Mana=' + IntToStr(Mana[ID]));
  143.     ModifyFileLine(FileName,17,'SkillPoints=' + IntToStr(SkillPoints[ID]));
  144.     ModifyFileLine(FileName,18,'Ep=' + IntToStr(Ep[ID]));
  145. end;
  146.  
  147. procedure OnLeaveGame(ID, Team: byte;Kicked: boolean);
  148.  
  149. begin
  150.  
  151. if LoggedIn[ID] then
  152.     WriteStats('scripts/ZRPG/Accounts/' + AccountName[ID] + '.txt',ID);
  153. end;
  154.  
  155. procedure AppOnIdle(Ticks: integer);
  156.  
  157. var
  158.     i : integer;
  159.  
  160. begin
  161.  
  162. for i := 1 to 32 do
  163. DrawText(i,'Level: ' + IntToStr(Level[i]) + ' Mana: ' + IntToStr(Mana[i]) + ' Ep: ' + IntToStr(Ep[i]) + '/' + IntToStr(500*(Level[i] +1)),330,Color,0.09,20,370);
  164.  
  165.     for i := 1 to 32 do
  166.     if Mana[i] < ManaFull[i] then begin
  167.         for i := 1 to 32 do
  168.         Mana[i] := Mana[i] + 1;
  169.     end;
  170.    
  171.     for i := 1 to 32 do
  172.     if Skill1Cool[i] > -1 then begin
  173.         for i := 1 to 32 do
  174.         Skill1Cool[i] := Skill1Cool[i] -1;
  175.     end;
  176.    
  177.     for i := 1 to 32 do
  178.     if Skill1Cool[i] = 0 then WriteConsole(i, 'The Skill Knife Wave have just cooled down!',Color);
  179.    
  180. end;
  181.  
  182. procedure OnJoinGame(ID, Team: byte);
  183.  
  184. begin
  185.     Level[ID] := 0;
  186.     Ep[ID] := 0;
  187.     ManaFull[ID] := 100;
  188.     Mana[ID] := 100;
  189.     Skill1[ID] := 0;
  190.     Skill2[ID] := 0;
  191.     Skill3[ID] := 0;
  192.     Skill4[ID] := 0;
  193.     Skill5[ID] := 0;
  194.     Skill6[ID] := 0;
  195.     Skill7[ID] := 0
  196.     Skill8[ID] := 0
  197.     Skill9[ID] := 0;
  198.     Skill10[ID] := 0;
  199. end;
  200.  
  201. function OnPlayerCommand(ID: Byte; Text: string): boolean;
  202.  
  203. var
  204.     Password : string;
  205.     i : integer;
  206.    
  207.  
  208. begin
  209.  
  210. if LowerCase(GetPiece(Text,' ',0)) = '/create' then begin
  211.     AccountName[ID] := RegExpReplace('[/\///|/?/</>]',GetPiece(Text,' ',1),'_',true);
  212.     Password := GetPiece(Text,' ',2);
  213.     try
  214.         if not FileExists('scripts/ZRPG/Accounts/' + AccountName[ID] + '.txt') then
  215.         begin      
  216.             WriteFile('scripts/ZRPG/Accounts/' + AccountName[ID] + '.txt','--AccData--');
  217.             ModifyFileLine('scripts/ZRPG/Accounts/' + AccountName[ID] + '.txt',1,AccountName[ID]);
  218.             ModifyFileLine('scripts/ZRPG/Accounts/' + AccountName[ID] + '.txt',2,MD5String(Password));
  219.             ModifyFileLine('scripts/ZRPG/Accounts/' + AccountName[ID] + '.txt',3,'--Skills--');
  220.             ModifyFileLine('scripts/ZRPG/Accounts/' + AccountName[ID] + '.txt',4,'Skill1=0');
  221.             ModifyFileLine('scripts/ZRPG/Accounts/' + AccountName[ID] + '.txt',5,'Skill2=0');
  222.             ModifyFileLine('scripts/ZRPG/Accounts/' + AccountName[ID] + '.txt',6,'Skill3=0');
  223.             ModifyFileLine('scripts/ZRPG/Accounts/' + AccountName[ID] + '.txt',7,'Skill4=0');
  224.             ModifyFileLine('scripts/ZRPG/Accounts/' + AccountName[ID] + '.txt',8,'Skill5=0');
  225.             ModifyFileLine('scripts/ZRPG/Accounts/' + AccountName[ID] + '.txt',9,'Skill6=0');
  226.             ModifyFileLine('scripts/ZRPG/Accounts/' + AccountName[ID] + '.txt',10,'Skill7=0');
  227.             ModifyFileLine('scripts/ZRPG/Accounts/' + AccountName[ID] + '.txt',11,'Skill8=0');
  228.             ModifyFileLine('scripts/ZRPG/Accounts/' + AccountName[ID] + '.txt',12,'Skill9=0');
  229.             ModifyFileLine('scripts/ZRPG/Accounts/' + AccountName[ID] + '.txt',13,'Skill10=0');
  230.             ModifyFileLine('scripts/ZRPG/Accounts/' + AccountName[ID] + '.txt',14,'--LVL--');
  231.             ModifyFileLine('scripts/ZRPG/Accounts/' + AccountName[ID] + '.txt',15,'Level=0');
  232.             ModifyFileLine('scripts/ZRPG/Accounts/' + AccountName[ID] + '.txt',16,'Mana=100');
  233.             ModifyFileLine('scripts/ZRPG/Accounts/' + AccountName[ID] + '.txt',17,'SkillPoints=0');
  234.             ModifyFileLine('scripts/ZRPG/Accounts/' + AccountName[ID] + '.txt',18,'Ep=0');
  235.             WriteConsole(ID, 'Account succesfully created! You are logged in now!',Color);
  236.             LoggedIn[ID] := true;
  237.         end else if FileExists('scripts/ZRPG/Accounts/' + AccountName[ID] + '.txt') then WriteConsole(ID, 'Your Accountname is already in use, try another one.',Color);
  238.         except WriteConsole(ID, 'Your entered Username/Password was invalid. Please try another one.',Color);
  239.         end;
  240. end;
  241.        
  242. if LowerCase(GetPiece(Text,' ',0)) = '/login' then begin
  243.     AccountName[ID] := RegExpReplace('[/\///|/?/</>]',GetPiece(Text,' ',1),'_',true);
  244.     Password := MD5String(GetPiece(Text,' ',2));
  245.         if FileExists('scripts/ZRPG/Accounts/' + AccountName[ID] + '.txt') then
  246.             PwList := Explode(LowerCase(ReadFile('scripts/ZRPG/Accounts/' + AccountName[ID] + '.txt')),Chr(13) + Chr(10));
  247.                 for i := 0 to ArrayHigh(PwList) do if LowerCase(PwList[i]) = LowerCase(Password) then begin
  248.                     LoggedIn[ID] := true;
  249.                     GetStats('scripts/ZRPG/Accounts/' + AccountName[ID] + '.txt',ID);
  250.                     //Message
  251.                     WriteConsole(ID, 'Succesfully logged in!',Color);
  252.                 end;
  253. end;
  254.  
  255. if (LowerCase(Text) = '/save') and (LoggedIn[ID]) then begin
  256.     WriteStats('scripts/ZRPG/Accounts/' + AccountName[ID] + '.txt',ID);
  257.     WriteConsole(ID, 'Your data has been saved!',Color);
  258. end else if (LowerCase(Text) = '/save') and not (LoggedIn[ID]) then WriteConsole(ID,'Please Login to save your stats.',Color);
  259.  
  260. if (LowerCase(Text) = '/logout') and (LoggedIn[ID]) then begin
  261.     WriteStats('scripts/ZRPG/Accounts/' + AccountName[ID] + '.txt',ID);
  262.     LoggedIn[ID] := false;
  263.     WriteConsole(ID, 'Logged out! Your data has been saved.',Color);
  264. end;
  265.  
  266.  
  267.  
  268. if (Text = '/sk1') and (Skill1[ID] = 1) then begin
  269.     if Mana[ID] -50 > 0 then begin
  270.         if Skill1Cool[ID] = -1 then begin
  271.         Mana[ID] := Mana[ID] -50;
  272.         Nova(
  273.             GetPlayerStat(ID, 'X'), //X
  274.             GetPlayerStat(ID, 'Y'), //Y
  275.             10*Level[ID]/2, //Speed
  276.             60, // distance/decentralize
  277.             100, //power
  278.             ID, //owner
  279.             1, //Bullet
  280.             40 //n
  281.             );
  282.         Skill1Cool[ID] := 5;
  283.         end else if Skill1Cool[ID] > 0 then WriteConsole(ID, 'This spell is still cooling down!',Color);
  284.     end else if Mana[ID] -50 < 0 then WriteConsole(ID, 'You have not enought mana!',Color);
  285. end else if (Text = '/sk1') and (Skill1[ID] = 0) then WriteConsole(ID, 'You have not learned that spell!',Color);
  286.  
  287. if LowerCase(Text) = '/skills' then begin
  288. WriteConsole(ID,'Bullet Circle = Dmg: 100 Manacosts: 50 Cooldown: 5 seks, faster Bullets per Level. Type /learn 1 to learn this skill.',Color);
  289. end;
  290.  
  291. if LowerCase(GetPiece(Text,' ',0)) = '/learn' then begin
  292.  
  293. if (GetPiece(Text,' ',1) = IntToStr(1)) then begin
  294.     if (Skill1[ID] < 1) then begin
  295.         if (SkillPoints[ID] > 0) then begin
  296.             Skill1[ID] := 1;
  297.             SkillPoints[ID] := SkillPoints[ID] -1;
  298.             WriteConsole(ID, 'Skill Bullet Circle learned!',Color);
  299.         end else if not (SkillPoints[ID] > 0) then WriteConsole(ID, 'You have not enought skill points!',Color);
  300.     end;
  301. end;
  302. end;
  303.  
  304. if Text = '/test' then
  305. WriteConsole(0,IntToStr(500*(Level[ID] +1)),Color);
  306.  
  307. end;
  308.  
  309. procedure OnPlayerKill(Killer, Victim: byte; Weapon: String);
  310.  
  311. var
  312. a, b : integer;
  313.  
  314. begin
  315.  
  316.  
  317. a := BasicEp*(Level[Killer] +1);
  318. b := BasicEp*(Level[Killer] +1) + 40;
  319.  
  320. if GetPlayerStat(Killer,'Human') then begin
  321.     Ep[Killer] := Ep[Killer] + 20;
  322. end;
  323.         if (Ep[Killer] > a -5) and (Ep[Killer] < b) then begin
  324.             Level[Killer] := Level[Killer] + 1;
  325.             Mana[Killer] := Mana[Killer] + 50;
  326.             ManaFull[Killer] := ManaFull[Killer] + 50;
  327.             SkillPoints[Killer] := SkillPoints[Killer] + 1;
  328.             WriteConsole(Killer,'You reached' + IntToStr(Level[Killer]),Color);
  329.             WriteConsole(Killer,'You gained +50 Mana and +1 SkillPoint!',Color);
  330.    
  331. end;
  332. end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement