Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const
- Color = $E56600;
- BasicEp = 500;
- PPL = 20;
- var
- LoggedIn : array[1..32] of boolean;
- PwList : tstringarray;
- //Integer arrays
- Ep,
- Level,
- Mana,
- ManaFull,
- SkillPoints,
- Skill1,
- Skill2,
- Skill3,
- Skill4,
- Skill5,
- Skill6,
- Skill7,
- Skill8,
- Skill9,
- Skill10, Skill1Cool : array[1..32] of integer;
- AccountName : array[1..32] of string;
- GlobalID : integer;
- function Implode(const AryStr: array of string; const Delimiter: string): string;
- var
- i: word;
- begin
- Result := '';
- if (GetArrayLength(AryStr) > 0) then begin
- for i := 0 to GetArrayLength(AryStr) - 1 do
- Result := Result + AryStr[i] + Delimiter;
- Delete(Result, Length(Result) - Length(Delimiter) + 1, Length(Delimiter));
- end;
- end;
- function Explode(Source: string; const Delimiter: string): array of string;
- var
- Position, DelLength, ResLength: integer;
- begin
- DelLength := Length(Delimiter);
- Source := Source + Delimiter;
- repeat
- Position := Pos(Delimiter, Source);
- SetArrayLength(Result, ResLength + 1);
- Result[ResLength] := Copy(Source, 1, Position - 1);
- ResLength := ResLength + 1;
- Delete(Source, 1, Position + DelLength - 1);
- until (Position = 0);
- SetArrayLength(Result, ResLength - 1);
- end;
- procedure ModifyFileLine(const Filename: string; const Line: word; const Content: string);
- var
- FileAryStr : array of string;
- FileSource : string;
- begin
- FileSource := ReadFile(Filename);
- FileAryStr := Explode(FileSource, #13#10);
- FileAryStr[Line] := Content;
- FileSource := Implode(FileAryStr, #13#10);
- WriteFile(Filename, FileSource);
- end;
- function deg2rad(deg: single): single;
- begin
- result:=deg/(180/pi);
- end;
- procedure Nova(X,Y,speed,decentralize,power: single; ID,style: byte; n: integer);
- var i: integer;
- begin
- for i:=0 to n do
- 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);
- end;
- procedure GetStats(const FileName: string; const ID: byte);
- var
- FileSource, Content : string;
- FileAryStr : array of string;
- begin
- FileSource := ReadFile(FileName);
- FileAryStr := Explode(FileSource, #13#10);
- //Level
- Content := FileAryStr[15];
- Level[ID] := StrToInt(Copy(Content,7,length(Content)));
- //Mana
- Content := FileAryStr[16];
- Mana[ID] := StrToInt(Copy(Content,6,length(Content)));
- ManaFull[ID] := Mana[ID];
- //SkillPoints
- Content := FileAryStr[17];
- SkillPoints[ID] := StrToInt(Copy(Content,13,length(Content)));
- //Ep
- Content := FileAryStr[18];
- Ep[ID] := StrToInt(Copy(Content,4,length(Content)));
- //Skills
- Content := FileAryStr[4];
- Skill1[ID] := StrToInt(Copy(Content,8,length(Content)));
- Content := FileAryStr[5];
- Skill2[ID] := StrToInt(Copy(Content,8,length(Content)));
- Content := FileAryStr[6];
- Skill3[ID] := StrToInt(Copy(Content,8,length(Content)));
- Content := FileAryStr[7];
- Skill4[ID] := StrToInt(Copy(Content,8,length(Content)));
- Content := FileAryStr[8];
- Skill5[ID] := StrToInt(Copy(Content,8,length(Content)));
- Content := FileAryStr[9];
- Skill6[ID] := StrToInt(Copy(Content,8,length(Content)));
- Content := FileAryStr[10];
- Skill7[ID] := StrToInt(Copy(Content,8,length(Content)));
- Content := FileAryStr[11];
- Skill8[ID] := StrToInt(Copy(Content,8,length(Content)));
- Content := FileAryStr[12];
- Skill9[ID] := StrToInt(Copy(Content,8,length(Content)));
- Content := FileAryStr[13];
- Skill10[ID] := StrToInt(Copy(Content,9,length(Content)));
- end;
- procedure WriteStats(const FileName: string; const ID: byte);
- begin
- ModifyFileLine(FileName,4,'Skill1=' + IntToStr(Skill1[ID]));
- ModifyFileLine(FileName,5,'Skill2=' + IntToStr(Skill2[ID]));
- ModifyFileLine(FileName,6,'Skill3=' + IntToStr(Skill3[ID]));
- ModifyFileLine(FileName,7,'Skill4=' + IntToStr(Skill4[ID]));
- ModifyFileLine(FileName,8,'Skill5=' + IntToStr(Skill5[ID]));
- ModifyFileLine(FileName,9,'Skill6=' + IntToStr(Skill6[ID]));
- ModifyFileLine(FileName,10,'Skill7=' + IntToStr(Skill7[ID]));
- ModifyFileLine(FileName,11,'Skill8=' + IntToStr(Skill8[ID]));
- ModifyFileLine(FileName,12,'Skill9=' + IntToStr(Skill8[ID]));
- ModifyFileLine(FileName,13,'Skill10=' + IntToStr(Skill10[ID]));
- ModifyFileLine(FileName,15,'Level=' + IntToStr(Level[ID]));
- ModifyFileLine(FileName,16,'Mana=' + IntToStr(Mana[ID]));
- ModifyFileLine(FileName,17,'SkillPoints=' + IntToStr(SkillPoints[ID]));
- ModifyFileLine(FileName,18,'Ep=' + IntToStr(Ep[ID]));
- end;
- procedure OnLeaveGame(ID, Team: byte;Kicked: boolean);
- begin
- if LoggedIn[ID] then
- WriteStats('scripts/ZRPG/Accounts/' + AccountName[ID] + '.txt',ID);
- end;
- procedure AppOnIdle(Ticks: integer);
- var
- i : integer;
- begin
- for i := 1 to 32 do
- 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);
- for i := 1 to 32 do
- if Mana[i] < ManaFull[i] then begin
- for i := 1 to 32 do
- Mana[i] := Mana[i] + 1;
- end;
- for i := 1 to 32 do
- if Skill1Cool[i] > -1 then begin
- for i := 1 to 32 do
- Skill1Cool[i] := Skill1Cool[i] -1;
- end;
- for i := 1 to 32 do
- if Skill1Cool[i] = 0 then WriteConsole(i, 'The Skill Knife Wave have just cooled down!',Color);
- end;
- procedure OnJoinGame(ID, Team: byte);
- begin
- Level[ID] := 0;
- Ep[ID] := 0;
- ManaFull[ID] := 100;
- Mana[ID] := 100;
- Skill1[ID] := 0;
- Skill2[ID] := 0;
- Skill3[ID] := 0;
- Skill4[ID] := 0;
- Skill5[ID] := 0;
- Skill6[ID] := 0;
- Skill7[ID] := 0
- Skill8[ID] := 0
- Skill9[ID] := 0;
- Skill10[ID] := 0;
- end;
- function OnPlayerCommand(ID: Byte; Text: string): boolean;
- var
- Password : string;
- i : integer;
- begin
- if LowerCase(GetPiece(Text,' ',0)) = '/create' then begin
- AccountName[ID] := RegExpReplace('[/\///|/?/</>]',GetPiece(Text,' ',1),'_',true);
- Password := GetPiece(Text,' ',2);
- try
- if not FileExists('scripts/ZRPG/Accounts/' + AccountName[ID] + '.txt') then
- begin
- WriteFile('scripts/ZRPG/Accounts/' + AccountName[ID] + '.txt','--AccData--');
- ModifyFileLine('scripts/ZRPG/Accounts/' + AccountName[ID] + '.txt',1,AccountName[ID]);
- ModifyFileLine('scripts/ZRPG/Accounts/' + AccountName[ID] + '.txt',2,MD5String(Password));
- ModifyFileLine('scripts/ZRPG/Accounts/' + AccountName[ID] + '.txt',3,'--Skills--');
- ModifyFileLine('scripts/ZRPG/Accounts/' + AccountName[ID] + '.txt',4,'Skill1=0');
- ModifyFileLine('scripts/ZRPG/Accounts/' + AccountName[ID] + '.txt',5,'Skill2=0');
- ModifyFileLine('scripts/ZRPG/Accounts/' + AccountName[ID] + '.txt',6,'Skill3=0');
- ModifyFileLine('scripts/ZRPG/Accounts/' + AccountName[ID] + '.txt',7,'Skill4=0');
- ModifyFileLine('scripts/ZRPG/Accounts/' + AccountName[ID] + '.txt',8,'Skill5=0');
- ModifyFileLine('scripts/ZRPG/Accounts/' + AccountName[ID] + '.txt',9,'Skill6=0');
- ModifyFileLine('scripts/ZRPG/Accounts/' + AccountName[ID] + '.txt',10,'Skill7=0');
- ModifyFileLine('scripts/ZRPG/Accounts/' + AccountName[ID] + '.txt',11,'Skill8=0');
- ModifyFileLine('scripts/ZRPG/Accounts/' + AccountName[ID] + '.txt',12,'Skill9=0');
- ModifyFileLine('scripts/ZRPG/Accounts/' + AccountName[ID] + '.txt',13,'Skill10=0');
- ModifyFileLine('scripts/ZRPG/Accounts/' + AccountName[ID] + '.txt',14,'--LVL--');
- ModifyFileLine('scripts/ZRPG/Accounts/' + AccountName[ID] + '.txt',15,'Level=0');
- ModifyFileLine('scripts/ZRPG/Accounts/' + AccountName[ID] + '.txt',16,'Mana=100');
- ModifyFileLine('scripts/ZRPG/Accounts/' + AccountName[ID] + '.txt',17,'SkillPoints=0');
- ModifyFileLine('scripts/ZRPG/Accounts/' + AccountName[ID] + '.txt',18,'Ep=0');
- WriteConsole(ID, 'Account succesfully created! You are logged in now!',Color);
- LoggedIn[ID] := true;
- end else if FileExists('scripts/ZRPG/Accounts/' + AccountName[ID] + '.txt') then WriteConsole(ID, 'Your Accountname is already in use, try another one.',Color);
- except WriteConsole(ID, 'Your entered Username/Password was invalid. Please try another one.',Color);
- end;
- end;
- if LowerCase(GetPiece(Text,' ',0)) = '/login' then begin
- AccountName[ID] := RegExpReplace('[/\///|/?/</>]',GetPiece(Text,' ',1),'_',true);
- Password := MD5String(GetPiece(Text,' ',2));
- if FileExists('scripts/ZRPG/Accounts/' + AccountName[ID] + '.txt') then
- PwList := Explode(LowerCase(ReadFile('scripts/ZRPG/Accounts/' + AccountName[ID] + '.txt')),Chr(13) + Chr(10));
- for i := 0 to ArrayHigh(PwList) do if LowerCase(PwList[i]) = LowerCase(Password) then begin
- LoggedIn[ID] := true;
- GetStats('scripts/ZRPG/Accounts/' + AccountName[ID] + '.txt',ID);
- //Message
- WriteConsole(ID, 'Succesfully logged in!',Color);
- end;
- end;
- if (LowerCase(Text) = '/save') and (LoggedIn[ID]) then begin
- WriteStats('scripts/ZRPG/Accounts/' + AccountName[ID] + '.txt',ID);
- WriteConsole(ID, 'Your data has been saved!',Color);
- end else if (LowerCase(Text) = '/save') and not (LoggedIn[ID]) then WriteConsole(ID,'Please Login to save your stats.',Color);
- if (LowerCase(Text) = '/logout') and (LoggedIn[ID]) then begin
- WriteStats('scripts/ZRPG/Accounts/' + AccountName[ID] + '.txt',ID);
- LoggedIn[ID] := false;
- WriteConsole(ID, 'Logged out! Your data has been saved.',Color);
- end;
- if (Text = '/sk1') and (Skill1[ID] = 1) then begin
- if Mana[ID] -50 > 0 then begin
- if Skill1Cool[ID] = -1 then begin
- Mana[ID] := Mana[ID] -50;
- Nova(
- GetPlayerStat(ID, 'X'), //X
- GetPlayerStat(ID, 'Y'), //Y
- 10*Level[ID]/2, //Speed
- 60, // distance/decentralize
- 100, //power
- ID, //owner
- 1, //Bullet
- 40 //n
- );
- Skill1Cool[ID] := 5;
- end else if Skill1Cool[ID] > 0 then WriteConsole(ID, 'This spell is still cooling down!',Color);
- end else if Mana[ID] -50 < 0 then WriteConsole(ID, 'You have not enought mana!',Color);
- end else if (Text = '/sk1') and (Skill1[ID] = 0) then WriteConsole(ID, 'You have not learned that spell!',Color);
- if LowerCase(Text) = '/skills' then begin
- WriteConsole(ID,'Bullet Circle = Dmg: 100 Manacosts: 50 Cooldown: 5 seks, faster Bullets per Level. Type /learn 1 to learn this skill.',Color);
- end;
- if LowerCase(GetPiece(Text,' ',0)) = '/learn' then begin
- if (GetPiece(Text,' ',1) = IntToStr(1)) then begin
- if (Skill1[ID] < 1) then begin
- if (SkillPoints[ID] > 0) then begin
- Skill1[ID] := 1;
- SkillPoints[ID] := SkillPoints[ID] -1;
- WriteConsole(ID, 'Skill Bullet Circle learned!',Color);
- end else if not (SkillPoints[ID] > 0) then WriteConsole(ID, 'You have not enought skill points!',Color);
- end;
- end;
- end;
- if Text = '/test' then
- WriteConsole(0,IntToStr(500*(Level[ID] +1)),Color);
- end;
- procedure OnPlayerKill(Killer, Victim: byte; Weapon: String);
- var
- a, b : integer;
- begin
- a := BasicEp*(Level[Killer] +1);
- b := BasicEp*(Level[Killer] +1) + 40;
- if GetPlayerStat(Killer,'Human') then begin
- Ep[Killer] := Ep[Killer] + 20;
- end;
- if (Ep[Killer] > a -5) and (Ep[Killer] < b) then begin
- Level[Killer] := Level[Killer] + 1;
- Mana[Killer] := Mana[Killer] + 50;
- ManaFull[Killer] := ManaFull[Killer] + 50;
- SkillPoints[Killer] := SkillPoints[Killer] + 1;
- WriteConsole(Killer,'You reached' + IntToStr(Level[Killer]),Color);
- WriteConsole(Killer,'You gained +50 Mana and +1 SkillPoint!',Color);
- end;
- end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement