hi i need help
how i can
this login script:
function ysplit(const source: string; const delimiter: string; const limit: shortint): TStringArray;
var
i, x, d: integer;
s: string;
res: TStringArray;
begin
d := Length(delimiter);
x := 0;
i := 1;
SetArrayLength(res, 1);
while i <= Length(source) do begin
s := Copy(source, i, d);
if (s = delimiter) and ((limit < 0) or (limit > x + 1)) then begin
inc(i, d);
inc(x, 1);
SetArrayLength(res, x + 1);
end
else begin
res[x] := res[x] + Copy(s, 1, 1);
inc(i, 1);
end;
end;
Result := res;
end;
type
LoginInfo = record
username: string;
password: string;
end;
var
logins: array of LoginInfo;
loop: integer;
procedure ActivateServerUserData();
var
login_entries, login_entry: array of string;
begin
login_entries := ysplit(ReadFile('UserData.txt'), #13#10, -3);
for loop := 0 to GetArrayLength(login_entries) - 3 do begin
if login_entries[loop] = '' then
continue;
login_entry := ysplit(login_entries[loop], #0, -3);
SetArrayLength(logins, loop + 1);
logins[loop].username := login_entry[0];
logins[loop].password := login_entry[1];
end;
end;
//ACTIVATE SERVER
procedure ActivateServer();
begin
firstblood := 1;
ActivateServerUserData();
end;
function OnPlayerCommand(ID: Byte; Text: string): boolean;
var
password: string;
oldpassword, newpassword: string;
found: boolean;
i: integer;
begin
if Copy(Text, 1, 7) = '/login ' then
begin
password := Copy(Text, 8, Length(Text) - 7);
found := false;
for loop := 0 to GetArrayLength(logins) - 2 do begin
if logins[loop].username = IDToName(ID) then begin
if logins[loop].password = password then
WriteConsole(ID, 'Login successful. Profile Loaded!', $FFFF0000)
else
WriteConsole(ID, 'Invalid password. Please try again', $FFFF0000);
found := true;
break;
end;
end;
if found = false then
WriteConsole(ID, 'That username does not exist.', $FFFF0000);
if found = true then
for i := 1 to 32 do
logged[ID] := 1;
for i := 1 to 32 do
if (Spot > -1 ) and (Copy(Text, 1, 8) = '/change ') and (logged[ID] = 1) then
begin
password := Text;
delete(password,1,8);
oldpassword := (GetPiece(password,' ',0));
SayToPlayer(ID,oldpassword);
newpassword := (GetPiece(password,' ',1));
SayToPlayer(ID,newpassword);
found := false;
end;
for loop := 0 to GetArrayLength(logins) - 1 do begin
if logins[loop].username = IDToName(ID) then begin
if logins[loop].password = oldpassword then begin
WriteFile('UserData.txt',GetPlayerStat(ID,'name') + #0 + newpassword);
ActivateServerUserData();
WriteConsole(ID, 'Password changed!', $FFFF0000);
end else
WriteConsole(ID, 'Invalid password. Please try again', $FFFF0000);
found := true;
break;
end;
end;
if found = false then
WriteConsole(ID, 'That username does not exist', $FFFF0000);
end;
for i := 1 to 32 do
if (Spot > -1 ) and (Copy(Text, 1, 8) = '/change ') and (logged[ID] = 0) then
begin
SayToPlayer(i,'Login first!');
end;
if (Spot > -1 ) and (Copy(Text,1,10) = '/register ') then
begin
SayToPlayer(ID,'NickName Already Registered');
end;
if (Spot = -1 ) and (Copy(Text,1,10) = '/register ') then
begin
password := Text;
delete(password,1,10);
WriteLnFile('UserData.txt',GetPlayerStat(ID,'name') + #0 + password);
SayToPlayer(ID,'Registering Complete');
ActivateServerUserData();
end;
Result := false;
end;
procedure OnJoinTeam(ID, Team: byte);
var
i: byte;
p: integer;
File: TStringArray;
begin
File := YSplit(ReadFile('UserData.txt'),chr(10) + chr(13), -1);
Spot := -1;
p := 0;
while (p <> Spot) and (p <= ArrayHigh(File)) do begin
if Copy(File[p],1,Length(IDtoName(ID))) = IDtoName(ID) then Spot := p;
p := p + 1;
end;
if Spot = -1 then
begin
SayToPlayer(ID,'Your NickName Does Not Exist!');
SayToPlayer(ID,'Please Enter Your Password!');
SayToPlayer(ID,'Type /register ''Your Password Here''');
end;
if Spot > -1 then
begin
SayToPlayer(ID,'Welcome Back '+(GetPlayerStat(ID,'name')));
SayToPlayer(ID,'Please Type /login ''Your Password Here''');
SayToPlayer(ID,'To change password type /change ''Old Password'' ''New Password''');
end;
SetWeaponActive(i,7,false);
SetWeaponActive(i,10,false);
statguns[ ID ] := 0;
end;
combine with this leveling/ep script:
const
//Teams
ALPHA = 1;
BRAVO = 2;
CHARLIE = 3;
DELTA = 4;
SPECTATOR = 5;
HP_PER_LEVEL = 200;
MAX_LVL = 10;
EP_PER_LEVEL = 100;
//Game Modes
DEATHMATCH = 0;
POINTMATCH = 1;
TEAMMATCH = 2;
CTF = 3;
RAMBO = 4;
INF = 5;
HTF = 6;
SERVER = 255;
type tplayer = record
name: string;
ep,level,maxhp: integer;
end;
var soldier: array[1..32] of tplayer;
function GetEP(Killer,Victim:string): integer;
var KID,VID,multiplier,lvldif,EP: integer;
begin
KID:=NametoID(Killer);
VID:=NametoID(Victim);
lvldif:=soldier[VID].level-soldier[KID].level;
multiplier:=100 + 10 * lvldif;
If multiplier<40 then
multiplier:=40;
EP:=1000 + (soldier[VID].level * EP_PER_LEVEL * multiplier DIV 100);
Result:=EP;
end;
function MaxEP(ID: integer): integer;
begin
Result:=2200 + (soldier[ID].level * 2000) + (soldier[ID].level * soldier[ID].level * 200);
end;
{procedure Heal(ID,percent,absolute: intteger);
begin
DoDamage(ID,(-1) * soldier.[ID].maxhp * percentage DIV 100 - absolute);
end;}
procedure GainLvl(ID: integer);
begin
soldier[ID].level:=soldier[ID].level+1;
Command('say ' + IDtoName(ID) + ' reached Level ' + inttostr(soldier[ID].level));
soldier[ID].maxhp:=4000 + HP_PER_LEVEL * soldier[ID].level;
//Heal(ID,100,0);
end;
procedure ActivateServer();
begin
end;
procedure AppOnIdle(Ticks: integer);
begin
end;
procedure OnCommand(ID: integer;Text: string);
begin
end;
function OnRequestGame(IP: string;State: integer):integer;
begin
Result := State;
end;
procedure OnJoinGame(IP, Nickname: string;Team: byte);
begin
end;
procedure OnJoinTeam(IP, Nickname: string;Team: byte);
var i,JID,temp: integer;
begin
temp:=0;
JID:=IPtoID(IP);
soldier[JID].level:=1;
If NumPlayers > 1 then
begin
for i:=1 to 32 do
If soldier[i].level > temp then
temp:=soldier[i].level;
soldier[JID].level:=temp;
end;
soldier[JID].ep:=0;
soldier[JID].maxhp:=4000;
soldier[JID].name:=Nickname;
end;
procedure OnLeaveGame(IP, Nickname: string;Team: byte);
begin
end;
procedure OnFlagGrab(ID: integer;TeamFlag: byte;GrabbedInBase: boolean);
begin
end;
procedure OnFlagReturn(ID: integer;TeamFlag: byte);
begin
end;
procedure OnFlagScore(ID: integer;TeamFlag: byte);
begin
end;
procedure OnPlayerKill(Killer,Victim,Weapon: string);
var EP,KID,VID: integer;
begin
KID:=NametoID(Killer);
VID:=NametoID(Victim);
If KID=VID then
begin
If soldier[KID].ep > 1000 + soldier[KID].level * EP_PER_LEVEL then
soldier[KID].ep:=soldier[KID].ep - (1000 + soldier[KID].level * EP_PER_LEVEL)
else
soldier[KID].ep:=0;
end
else
begin
EP:=GetEP(Killer,Victim);
soldier[KID].ep:=soldier[KID].ep + EP;
If soldier[KID].ep >= MaxEP(KID) then
begin
If soldier[KID].level >= MAX_LVL then
else
GainLvl(KID);
end;
end;
end;
procedure OnPlayerRespawn(ID: integer);
begin
end;
procedure OnPlayerSpeak(Name,Text: string);
begin
end;
procedure OnAdminConnect(IP: string);
begin
end;
procedure OnAdminDisconnect(IP: string);
begin
end;
procedure OnAdminMessage(IP, Msg: string);
begin
end;
need a answer