Author Topic: Bank system with Nick Name Registration  (Read 3130 times)

0 Members and 1 Guest are viewing this topic.

Offline sckme

  • Major(1)
  • Posts: 33
Bank system with Nick Name Registration
« on: January 02, 2010, 04:56:22 am »
Hello,

Look at this script (Buy) and Nick name Registration. My question: can script Nick Name Registration save the money, when i kill player, cap flag, and anything (script Buy)? sry fr my bad eng ;f

Code: [Select]
const
Color = $FFA07A; //Color text is shown in
MineDist = 50; //Distance a player has to be for the mine to blow
MinesCarry = 3; //Maximum amount of mines a player can carry at a time
MinesPlace = 10; //Maximum amount of mines allowed on the field per player at a time
Ground = true; //Make this false if you want mines to be placed / checked in mid air
MineMessage = true; //When a mine goes off, it displays a message to the mine owner that it blew
KillMessage = true; //When a player kills somebody, this shows how much cash they have earned and total cash
CapMessage = true; //When a player captures the flag, this shows how much cash they have eanred and total cash
// GrabCapCash = 10; Disabled until problem fixed with a bug in scripting
CapCash = 100; //Amount of cash a player gets for capturing the flag
CapAloneCheck = true; //If this is enabled, then the server will check if a player is by himself when he caps, and if he is, he earns no cash

type
mInfo = record
Exists: boolean;
Owner: byte;
X,Y: single;
end;

var
JustJoined: array[1..32] of boolean;
Spree: array[1..32] of byte;
Cash: array[1..32] of integer;
Enabled: array[1..6] of boolean;
Cost: array[1..6] of byte;
Items: array[1..32] of array[1..6] of byte;
Mines: array of mInfo;
// Grabber: array[1..2] of byte;

function AddChr(Character: char; Num: integer): string;
var
i: integer;
begin
for i := 1 to Num do Result := Result + Character;
end;

procedure PlaceMine(ID: byte);
var
i: integer;
begin
for i := 0 to GetArrayLength(Mines) do if i = GetArrayLength(Mines) then Break else if Mines[i].Exists = false then Break;
if i >= GetArrayLength(Mines) then SetArrayLength(Mines,i + 1);
Mines[i].Exists := true;
Mines[i].Owner := ID;
GetPlayerXY(ID,Mines[i].X,Mines[i].Y);
end;

function ItemIDtoName(IID: byte): string;
begin
Case IID of
1: Result := 'Zycie';
2: Result := 'Granaty';
3: Result := 'Granaty odlamkowe';
4: Result := 'Kamizelka';
5: Result := 'Mina';
6: Result := 'Predator';
end;
end;

procedure ActivateServer();
begin
Cost[1] := 30; //Zycie
Cost[2] := 45; //Granaty
Cost[3] := 60; //Granaty Odlamkowe
Cost[4] := 80; //Pancerz
Cost[5] := 100; //Miny 2 out at a time; can carry only 3
Cost[6] := 120; //Predator
Enabled[1] := true;
Enabled[2] := true;
Enabled[3] := true;
Enabled[4] := true;
Enabled[5] := true;
Enabled[6] := true;
end;

procedure AppOnIdle(Ticks: integer);
var
i,j: integer;
X,Y: single;
begin
if Enabled[6] then for i := 0 to GetArrayLength(Mines) - 1 do if Mines[i].Exists then begin
for j := 1 to 32 do if GetPlayerStat(j,'Active') = true then if (GetPlayerStat(j,'Alive') = true) and (GetPlayerStat(Mines[i].Owner,'Team') <> GetPlayerStat(j,'Team')) then begin
GetPlayerXY(j,X,Y);
if (Distance(X,Y,Mines[i].X,Mines[i].Y) <= MineDist) and ((Ground = false) or ((Ground) and (GetPlayerStat(j,'Ground') = true))) then begin
CreateBullet(X,Y,0,5,200,4,Mines[i].Owner);
CreateBullet(Mines[i].X,Mines[i].Y,0,5,200,4,Mines[i].Owner);
CreateBullet((Mines[i].X + X) / 2,(Mines[i].Y + Y) / 2,0,5,200,4,Mines[i].Owner);
CreateBullet((Mines[i].X + X) / 2,(Mines[i].Y + Y) / 2 - 20,0,5,200,4,Mines[i].Owner);
Mines[i].Exists := false;
if MineMessage then WriteConsole(Mines[i].Owner,GetPlayerStat(j,'Name') + ' has tripped in your mine.',Color);
end;
end;
end;
if Ticks mod (60 * 60 * 5) = 0 then WriteConsole(0,'Co to za kasa? Co moge kupic i jak? Wyjasnienie w /help',Color);
end;

procedure OnJoinGame(ID, Team: byte);
begin
JustJoined[ID] := true;
Cash[ID] := 0;
end;

procedure OnJoinTeam(ID, Team: byte);
begin
// if Grabber[iif(Team = 1,2,1)] = ID then Grabber[iif(Team = 1,2,1)] := 0;
if JustJoined[ID] then begin
WriteConsole(0,'Co to jest za kasa? Co moge kupic i jak? Wyjasnienie w /help',Color);
JustJoined[ID] := false;
end;
end;

procedure OnLeaveGame(ID, Team: byte; Kicked: boolean);
var
i: byte;
begin
// if Grabber[Team] = ID then Grabber[Team] := 0;
i := 1;
while Cash[ID] > 0 do begin
Cash[ID] := Cash[ID] - 1;
Cash[i] := Cash[i] + 1;
if i = 32 then i := 1 else i := i + 1;
end;
end;

procedure OnFlagGrab(ID, TeamFlag: byte; GrabbedInBase: boolean);
begin
// if GrabbedInBase then Grabber[StrtoInt(iif(TeamFlag = 1,'2','1'))] := ID;
end;

procedure OnFlagReturn(ID, TeamFlag: byte);
begin
// Grabber[TeamFlag] := 0;
end;

procedure OnFlagScore(ID, TeamFlag: byte);
begin
{if ID = Grabber[TeamFlag] then begin
Cash[ID] := Cash[ID] + GrabCapCash;
if CapMessage then WriteConsole(ID,'Zdobyles $' + InttoStr(GrabCapCash) + ' for capturing the flag. ($' + InttoStr(Cash[ID]) + ')',Color);
end else }if iif(TeamFlag = 1,AlphaPlayers,BravoPlayers) <> 0 then begin
Cash[ID] := Cash[ID] + CapCash;
if CapMessage then WriteConsole(ID,'Zdobyles $' + InttoStr(CapCash) + ' za nabicie punktu flagą. ($' + InttoStr(Cash[ID]) + ')',Color);
end else WriteConsole(ID,'You have captured the flag while alone. No money nor points for you!',Color);
//Grabber[TeamFlag] := 0;
end;

function OnPlayerCommand(ID: Byte; Text: string): boolean;
var
MineSet: boolean;
i,Item,Total,Who: byte;
Amount: integer;
LText: string;
begin
Result := false;
LText := LowerCase(Text);
if LText = '/items' then begin
WriteConsole(ID,'ID Nazwa operacji Poszczegolne koszta',Color);
for i := 1 to 6 do if Enabled[i] then WriteConsole(ID,InttoStr(i) + ': ' + ItemIDtoName(i) + AddChr(' ',17 - Length(ItemIDtoName(i))) + '$' + InttoStr(Cost[i]),Color);
end if LText = '/cash' then WriteConsole(ID,'Aktualnie posiadasz $' + InttoStr(Cash[ID]) + '.',Color) else if GetPiece(LText,' ',0) = '/buy' then begin
try
Item := StrtoInt(Copy(LText,6,Length(LText)));
except
end;
if (Item >= 1) and (Item <= 6) then begin
if Enabled[Item] then begin
if (Item <> 5) or ((Item = 5) and (Items[ID][5] < MinesCarry)) then begin
if Cash[ID] >= Cost[Item] then begin
Items[ID][Item] := Items[ID][Item] + 1;
Cash[ID] := Cash[ID] - Cost[Item];
WriteConsole(ID,'Kupiles bonus! Aby go uzyc wpisz w cmd ''/use ' + InttoStr(Item) + '''.',Color);
end else WriteConsole(ID,'Masz za malo pieniedzy. ($' + InttoStr(Cash[ID]) + ' / $' + InttoStr(Cost[Item]) + ')',Color);
end else WriteConsole(ID,'Masz limit ' + InttoStr(MinesCarry) + ' mines at a time.',Color);
end else WriteConsole(Id,'Ta opca zostala zdezaktywoana.',Color);
end else WriteConsole(ID,'Zly numer operacji.',Color);
end else if GetPiece(LText,' ',0) = '/use' then begin
try
Item := StrtoInt(Copy(LText,6,Length(LText)));
except
end;
if (Item >= 1) and (Item <= 6) then begin
if Enabled[Item] then begin
if Items[ID][Item] > 0 then begin
Case Item of
1: DoDamage(ID,GetPlayerStat(ID,'Health') - iif(Command('/realistic') = '1',65,150));
2: GiveBonus(ID,4);
3: GiveBonus(ID,5);
4: GiveBonus(ID,3);
5: begin
if ((Ground = false) or ((Ground) and (GetPlayerStat(ID,'Ground') = true))) then begin
if GetArrayLength(Mines) <> 0 then for i := 0 to GetArrayLength(Mines) - 1 do if (Mines[i].Exists) and (Mines[i].Owner = ID) then Total := Total + 1;
if Total <= MinesPlace then begin
PlaceMine(ID);
MineSet := true;
end else WriteConsole(ID,'Masz limit dwoch min.',Color);
end else WriteConsole(ID,'Musisz stac na ziemi zeby podlozyc mine.',Color);
end;
6: GiveBonus(ID,1);
end;
if (Item <> 5) or (MineSet) then begin
Items[ID][Item] := Items[ID][Item] - 1;
WriteConsole(ID,ItemIDtoName(Item) + ' aktywowana! (' + InttoStr(Items[ID][Item]) + ' remaining)',Color);
end;
end else WriteConsole(ID,'Nie posiadasz takiego itemu.',Color);
end else WriteConsole(ID,'This item has been disabled.',Color);
end else WriteConsole(ID,'Invalid ID input.',Color);
end else if LText = '/help' then begin
WriteConsole(ID,' SKLEP',Color);
WriteConsole(ID,'Kase dostajemy za zabitego gracza, badz nabicie punktu flagą.',Color);
WriteConsole(ID,'Są trzy bonusy ktore mozesz kupic:',Color);
WriteConsole(ID,'Kamizelka, Miny, Predator.',Color);
WriteConsole(ID,'Wpisz /items w cmd zeby zobaczyc ceny',Color);
WriteConsole(ID,'potem wpisz /buy ID zeby wykupic bonus ',Color);
WriteConsole(ID,'Zeby aktywowac bonus wpisz /use ID',Color);
WriteConsole(ID,'ID to numer bonusu widoczny po lewej stronie',Color);
end else if LText = '/commands' then begin
WriteConsole(ID,' Curt''s Buying',Color);
WriteConsole(ID,'/items View item prices',Color);
WriteConsole(ID,'/cash Shows your current amount of cash',Color);
WriteConsole(ID,'/buy # Buying item ID #',Color);
WriteConsole(ID,'/use # Using item ID #',Color);
WriteConsole(ID,'/help Help with using the script',Color);
WriteConsole(ID,'/commands Brings this menu up',Color);
end else if GetPiece(LText,' ',0) = '/give' then begin
try
Who := StrtoInt(GetPiece(LText,' ',1));
Amount := StrtoInt(GetPiece(LText,' ',2));
except
WriteConsole(ID,'Error...',Color);
end;
if (Who >= 1) and (Who <= 32) then begin
if GetPlayerStat(Who,'Active') = true then begin
if Amount > 0 then begin
if GetPlayerStat(ID,'Team') = GetPlayerStat(Who,'Team') then begin
if Cash[ID] >= Amount then begin
WriteConsole(ID,'You have given ' + GetPlayerStat(Who,'Name') + ' $' + InttoStr(Amount) + '.',Color);
WriteConsole(Who,GetPlayerStat(ID,'Name') + ' has given you $' + InttoStr(Amount) + '.',Color);
Cash[Who] := Cash[Who] + Amount;
end else WriteConsole(ID,'Masz za malo piniedzy zeby to kupic.',Color);
end else WriteConsole(ID,'You may only give cash to an friendly player.',Color);
end else if Amount < 0 then WriteConsole(ID,'You cannot steal cash from somebody...',Color) else WriteConsole(ID,'This will have no effect.',Color);
end else WriteConsole(ID,'Invalid ID.',Color);
end else WriteConsole(ID,'Invalid ID.',Color);
end;
end;

procedure OnPlayerKill(Killer, Victim: byte; Weapon: string);
var
Teamed: boolean;
begin
if (GameStyle = 0) or (GameStyle = 1) or (GameStyle = 4) then Teamed := false else Teamed := true;
if Teamed then begin
if GetPlayerStat(Killer,'Team') <> GetPlayerStat(Victim,'Team') then begin
if Killer <> Victim then begin
Cash[Killer] := Cash[Killer] + 3 + Spree[Killer] + Spree[Victim];
if KillMessage then WriteConsole(Killer,'Zabiles gracza ' + GetPlayerStat(Victim,'Name') + ' za $' + InttoStr(3 + Spree[Killer] + Spree[Victim]) + '. ($' + InttoStr(Cash[Killer]) + ')',Color);
Spree[Killer] := Spree[Killer] + 1;
end;
Spree[Victim] := 0;
end else if Killer = Victim then Spree[Victim] := 0;
end else begin
Cash[Killer] := Cash[Killer] + 2 + Spree[Killer];
if Killer <> Victim then Spree[Killer] := Spree[Killer] + 1;
Spree[Victim] := 0;
end;
end;

And this script Nick Name Registration

Code: [Select]
const
//TEAMS
ALPHA = 1;
BRAVO = 2;
CHARLIE = 3;
DELTA = 4;
SPECTATOR = 5;
//GAME MODES
DEATHMATCH = 0;
POINTMATCH = 1;
TEAMMATCH = 2;
CTF = 3;
RAMBO = 4;
INF = 5;
HTF = 6;
//WEAPONS
DEAGLES = 1;
HKMP5 = 2;
AK74 = 3;
STEYR = 4;
SPAS = 5;
RUGER = 6;
M79 = 7;
BARRET = 8;
MINIMI = 9;
MINIGUN = 10;
FLAMER = 11;
BOW = 12;
FLAMEBOW = 13;
SOCOM = 0;
KNIFE = 14;
CHAINSAW = 15;
LAW = 16;
MAXTEAMS = 5;
MAXPLAYER = 16;

//VARIABLES
var
ingameKills, ingameDeaths, ingameSelfkills: array [1..MAXPLAYER] of integer;
nickname_Password, nickname_IP: array [1..MAXPLAYER] of string;
nickname_Name, nickname_Kills, nickname_Deaths, nickname_Selfkills: array [1..MAXPLAYER] of string;
oldPassword, newPassword: array [1..MAXPLAYER] of string;
nickStatus: array [1..MAXPLAYER] of integer;
GOOD: longint;
BAD: longint;
kdKills, kdDeaths: array [1..MAXPLAYER] of integer;
kdRatio: array [1..MAXPLAYER] of single;

//ARRAYHIGH
function arrayHi( tester: TStringArray ): integer;
begin
result := GetArrayLength( tester ) - 1;
end;

//XSPLIT
function xsplit(const source: string; const delimiter: string):TStringArray;
var
i,x,d:integer;
s:string;
begin
d:=length(delimiter);
x:=0;
i:=1;
SetArrayLength(Result,1);
while(i<=length(source)) do begin
s:=Copy(source,i,d);
if(s=delimiter) then begin
i:=i+d;
inc(x,1);
SetArrayLength(result,x+1);
end else begin
result[x]:= result[x]+copy(s,1,1);
inc(i,1);
end;
end;
if Result[ArrayHi(Result)]='' then SetArrayLength(result,x);
end;

//ACTIVATESERVER
procedure ActivateServer();
var
b: byte;
begin
//change these if you want a other colours for GOOD/BAD writeconsole messages
GOOD := $EE00FF00;
BAD:= $FFFF4444;

//set all ID's logged out
for b := 1 to MAXPLAYER do
begin
nickStatus[b] := 0;
IngameKills[b] := 0;
IngameDeaths[b] := 0;
IngameSelfkills[b] := 0;
nickname_Name[b] := '';
nickname_Password[b] := '';
nickname_IP[b] := '';
nickname_Kills[b] := '';
nickname_Deaths[b] := '';
nickname_Selfkills[b] := '';
kdKills[b] := 0;
kdDeaths[b] := 0;
kdRatio[b] := 0;
oldPassword[b] := '';
newPassword[b] := '';
end
end;

//APPONIDLE
procedure AppOnIdle(Ticks: integer);
begin
end;

//FILTERFILENAME
function filterFilename(filename: string):string;
var
i,len: byte;
c: string;
begin
len := length(filename);
result := '';

for i := 1 to len do
begin
c := copy(filename,i,1);
if (c=chr(92)) or (c='/') or (c='\') or (c=':') or (c='*') or (c='?') or (c='"') or (c='<') or (c='>') or (c='|') or (c='.') then
result := result + '_'
else
result := result + c;
end
end;

//LOADNICKNAME
function loadNickname(nick: string; ID: byte): string;
var
temparray: TStringArray;
fileData,fileName: string;
begin
//filter player name
fileName := filterFileName( nick );

//check if player profile exists and load profile in string
if FileExists('stats/nickreg/'+filename+'.txt') = true then
begin
filedata := ReadFile('stats/nickreg/'+filename+'.txt')

//split all profile into a array
temparray := xsplit(filedata,chr(13)+chr(10));
nickname_Name[ID] := temparray[0];
nickname_Password[ID] := temparray[1];
nickname_IP[ID] := temparray[2];
nickname_Kills[ID] := temparray[3];
nickname_Deaths[ID] := temparray[4];
nickname_Selfkills[ID] := temparray[5];
result := nickname_Password[ID];
end else
begin
//if file does't exist then ask player to create profile and set all his ID info empty
WriteConsole(ID,'/create password - free account!!',GOOD);
nickStatus[ID] := 0;
nickname_Name[ID] := '';
nickname_Password[ID] := '';
nickname_Ip[ID] := '';
result := '';
end
end;

//SAVE NICKNAME
procedure SaveNickname(name,password,ip: string; NewKills,NewDeaths,NewSelfkills: integer; currentDate:string; ID: byte);
var
filename,outdata: string;
begin
//filter player name
filename := FilterFilename(name);

//check is nickname doens't already exist
if FileExists('stats/nickreg/'+filename+'.txt') = true then
begin
WriteConsole( ID, 'Nickname already exists!', BAD );
end else
begin
currentDate := FormatDate('dd:mm:yy');

//set data to write
outdata := name+chr(13)+chr(10)+
password+chr(13)+chr(10)+
ip+chr(13)+chr(10)+
inttostr(NewKills)+chr(13)+chr(10)+
inttostr(NewDeaths)+chr(13)+chr(10)+
inttostr(NewSelfkills)+chr(13)+chr(10)+
currentDate+chr(13)+chr(10);

//write new profile
WriteFile('stats/nickreg/'+filename+'.txt',outdata);
end
end;

//UPDATE NICKNAME
procedure UpdateNickname(nick: string; ID: byte);
var
temparray: TStringArray;
OldKills,OldDeaths,OldSelfkills: integer;
NewKills,NewDeaths,NewSelfkills: integer;
outdata: string;
fileName, fileData: string;
ip, currentDate: string;
begin
filename := FilterFilename(nick);
if getPlayerStat( ID, 'Active' ) then
begin
//if nickname exists
filedata := ReadFile('stats/nickreg/'+filename+'.txt');

//check if player is logged in to update new stats
if nickStatus[ID] = 1 then
begin
//check if file wasn't empty
if filedata <> '' then
begin
//split data
temparray := xsplit(filedata,chr(13)+chr(10));
Nickname_IP[ID] := temparray[2];
Nickname_Kills[ID] := temparray[3];
Nickname_Deaths[ID] := temparray[4];
Nickname_Selfkills[ID] := temparray[5];

//get old kills/deaths/selfkills from data
OldKills := strtoint(Nickname_Kills[ID]);
OldDeaths := strtoint(Nickname_Deaths[ID]);
OldSelfkills := strtoint(Nickname_Selfkills[ID]);

//count new kills/deats/selfkills
NewKills := OldKills + IngameKills[ID];
NewDeaths := OldDeaths + IngameDeaths[ID];
NewSelfkills := OldSelfkills + IngameSelfkills[ID];

//get player ip and currentdate
ip := getPlayerStat( ID, 'ip');
currentDate := FormatDate('dd:mm:yy');

//set data to write
outdata := nickname_Name[ID]+chr(13)+chr(10)+
Nickname_Password[ID]+chr(13)+chr(10)+
ip+chr(13)+chr(10)+
inttostr(NewKills)+chr(13)+chr(10)+
inttostr(NewDeaths)+chr(13)+chr(10)+
inttostr(NewSelfkills)+chr(13)+chr(10)+
currentDate+chr(13)+chr(10);

//update the player profile
WriteFile('stats/nickreg/'+filterFileName(nickname_Name[ID])+'.txt',outdata);
end else
begin
//if data inside profile was empty clear the name, pass and ip
Nickname_Name[ID] := '';
Nickname_Password[ID] := '';
Nickname_IP[ID] := '';
end
end else
begin
Writeln('Player did not login for stats!');
end
end
end;

//ONCOMMAND
function OnCommand(ID: Byte; Text: string): boolean;
begin
Result := false;
end;

//ONPLAYERCOMMAND
function OnPlayerCommand(ID: Byte; Text: string): boolean;
var
inputNick, tempNick, InputPassword, InputPasswordLogin, nick: string;
currentDate: string;
begin
//displays player stats
if (Copy(Text,1,6) = '/stats') then
begin
if GetPlayerStat(ID, 'Active') = true then
begin
nick := GetPlayerStat(ID,'name');

//check if player already got profile or not
if FileExists('stats/nickreg/'+filterFileName(nick)+'.txt') = true then
begin
//load player profile
LoadNickname(FilterFilename(GetPlayerStat(ID,'name')),ID);

//display stats
WriteConsole(ID,'Kills: ' +nickName_Kills[ID],GOOD);
WriteConsole(ID,'Deaths: ' +nickName_Deaths[ID],GOOD);
WriteConsole(ID,'SelfKills: '+nickName_SelfKills[ID],GOOD);

//check if player has more then 0 deaths otherwise its divide by zero
if strtoint(nickName_Deaths[ID]) > 0 then
begin
kdKills[ID] := strtoint(nickName_Kills[ID]);
kdDeaths[ID] := strtoint(nickName_Deaths[ID]);
kdRatio[ID] := kdKills[ID] / kdDeaths[ID];
WriteConsole(ID,'K/D Ratio: '+floattostr(roundto(kdRatio[ID],2)),GOOD);
end
end else
begin
WriteConsole(ID,'Nie masz konta na serwerze jeszcze!',BAD);
end
end
end

//create new account
if (Copy(Text,1,8) = '/create ') then
begin
//check if player isn't logged in already
if nickStatus[ID] = 0 then
begin
//check if player is active
if GetPlayerStat(ID, 'Active') = true then
begin
//get player nick
nick := GetPlayerStat(ID,'name');

//check if player already got profile or not
if FileExists('stats/nickreg/'+filterFileName(nick)+'.txt') = false then
begin
//get his password from text
InputPassword := Text;
delete(InputPassword,1,8);

//if input isn't empty
if InputPassword <> '' then
begin
//check password length
if length(inputPassword) < 17 then
begin
//Get the current date
currentDate := FormatDate('hh:nn:ss am/pm');

//Save player account into file
SaveNickname(GetPlayerStat(ID,'name'),InputPassword,GetPlayerStat(ID,'ip'),0,0,0,currentDate, ID);
WriteConsole(ID,'Nickname ' + GetPlayerStat(ID,'name') + ' successfully registered!',GOOD);
WriteConsole(ID,'Nickname ' + GetPlayerStat(ID,'name') + ' now logged in!',GOOD);
WriteConsole(ID,'Your password is ' + InputPassword + ' - do not forget it!',GOOD);
WriteLn('NickReg: ' + GetPlayerStat(ID,'name') + ' registered from ' + GetPlayerStat(ID,'ip'));
//login player that registered
nickStatus[ID] := 1;
end else
begin
WriteConsole(ID,'Max length password is 16 characters!',BAD);
end
end else
begin
WriteConsole(ID,'No password found. Please try again.',BAD);
end
end else
begin
WriteConsole(ID,'You are already a registered user!',BAD);
end
end
end
end

//change password
if (Copy(Text,1,12) = '/changepass ') then
begin
//check if player is logged in
if nickStatus[ID] = 1 then
begin
//check if player is active
if GetPlayerStat(ID, 'Active') = true then
begin
//get player nick
nick := GetPlayerStat(ID,'name');

//check if player already got profile or not
if FileExists('stats/nickreg/'+filterFileName(nick)+'.txt') = true then
begin
//get his password from text
InputPassword := Text;
delete(InputPassword,1,12);

//set old and new password
oldPassword[ID] := GetPiece(InputPassword,' ',0);
newPassword[ID] := GetPiece(InputPassword,' ',1);

//check if old password match
if oldPassword[ID] = nickName_Password[ID] then
begin
//check length of his newpassword
if length(newPassword[ID]) < 17 then
begin
//set new password to ID
nickName_Password[ID] := newPassWord[ID];

//save new password to profile
UpdateNickname(GetPlayerStat(ID,'name'),ID);
WriteConsole(ID,'Password changed to: '+newPassword[ID],GOOD);
end else
begin
WriteConsole(ID,'Max length password is 16 characters!',BAD);
end
end else
begin
WriteConsole(ID,'Wrong password!',BAD);
end
end else
begin
WriteConsole(ID,'No profile found!',BAD);
end
end
end else
begin
WriteConsole(ID,'Please login first!',BAD);
end
end

//change nickname
if (Copy(Text,1,12) = '/changenick ') then
begin
//check if player is logged in
if nickStatus[ID] = 1 then
begin
//check if player is active
if GetPlayerStat(ID, 'Active') = true then
begin
//get player nick
nick := GetPlayerStat(ID,'name');

//check if player already got profile or not
if FileExists('stats/nickreg/'+filterFileName(nick)+'.txt') = true then
begin
//get his password and nick from text
InputNick := Text;
delete(InputNick,1,12);

//check if password is right
if nickName_Password[ID] = GetPiece(InputNick,' ',0) then
begin
//check length of his new nickname
if length(GetPiece(InputNick,' ',1)) < 25 then
begin
//set new nickname to ID and check if that nick already exists
tempNick := GetPiece(InputNick,' ',1);

if FileExists('stats/nickreg/'+filterFileName(tempNick)+'.txt') = false then
begin
//set new nickname to ID
nickName_Name[ID] := GetPiece(InputNick,' ',1);

//save new password to profile
UpdateNickname(GetPlayerStat(ID,'name'),ID);
WriteConsole(ID,'NickName changed to: '+nickName_Name[ID],GOOD);
WriteConsole(ID,'Please rejoin the server with your new nick to load your new profile',GOOD);
end else
begin
WriteConsole(ID,'That nickname is already taken!',BAD);
end
end else
begin
WriteConsole(ID,'Nickname is over 24 characters, please pick another',BAD);
end
end else
begin
WriteConsole(ID,'Wrong Password!',BAD);
end
end else
begin
WriteConsole(ID,'No profile found!',BAD);
end
end
end else
begin
WriteConsole(ID,'Please login first!',BAD);
end
end

//login
if (Copy(Text,1,7) = '/login ') then
begin
//check if player isn't logged in yet
if (nickStatus[ID] = 0) then
begin
//if player is active
if GetPlayerStat(ID, 'Active')= true then
begin
//get player nick
nick := getPlayerStat(ID, 'Name' );

if FileExists('stats/nickreg/'+filterFileName(nick)+'.txt') = true then
begin
//get password from text
InputPasswordLogin := Text;
delete(InputPasswordLogin,1,7);

//Check password login
if InputPasswordLogin = Nickname_Password[ID] then
begin
//login the player and set tasktimer
nickStatus[ID] := 1;
WriteConsole(ID,'You are now logged in!',GOOD);
end else
begin
WriteConsole(ID,'Wrong password!',BAD);
end
end else
begin
WriteConsole(ID,'No profile found!',BAD);
end
end
end else
begin
WriteConsole(ID,'Jestes zalogowany!',BAD);
end
end

//Logout
if (Copy(Text,1,7) = '/logout') then
begin
//check is player is logged in
if (nickStatus[ID] = 1) then
begin
WriteConsole(ID,'Wylogowales sie!',GOOD);
WriteConsole(ID,'Wpisz /login ''password'' zeby sie zalogowac.',GOOD);

//set player status to logged out
nickStatus[ID] := 0;
end else
begin
WriteConsole(ID,'Wlasnie sie wylogowales!',BAD);
end
end
Result := false;
end;

//ONPLAYERSPEAK
procedure OnPlayerSpeak(ID: byte; Text: string);
begin
if (copy(Text,1,9) = '!commands') then
begin
WriteConsole(ID,'Commands are: /login, /logout, /changepass, /changenick, /stats',GOOD);
WriteConsole(ID,'!login for example will display info how to login',GOOD);
end

if (copy(Text,1,6) = '!login') then
begin
WriteConsole(ID,'Type /login ''your password'' to login',GOOD);
end

if (copy(Text,1,7) = '!logout') then
begin
WriteConsole(ID,'Type /logout ''your password'' to logout',GOOD);
end

if (copy(Text,1,11) = '!changepass') then
begin
WriteConsole(ID,'Type /changepass ''old password'' ''new password'' to set a new password',GOOD);
end

if (copy(Text,1,11) = '!changenick') then
begin
WriteConsole(ID,'Type /changenick ''your password'' ''new nickname'' to set a new nickname',GOOD);
end

if (copy(Text,1,6) = '!stats') then
begin
WriteConsole(ID,'Type /stats to view your current stats',GOOD);
end
end;

//JOINTEAM
procedure OnJoinTeam(ID, Team: byte);
begin
//check if player is active
if getPlayerStat( ID, 'Active' ) = true then
begin
//kick player if nickname is above 24 characters
if length(getPlayerStat( ID, 'name' )) > 24 then
begin
WriteConsole(ID,'...your name is over 24 characters, please change it.',BAD);
KickPlayer(ID);
end

//load player profile
LoadNickname(FilterFilename(GetPlayerStat(ID,'name')),ID);

//check if the ip's match
if nickname_IP[ID] <> '' then
begin
if (getPlayerStat( ID, 'ip' )) = nickname_IP[ID] then
begin
//login the player and set tasktimer
nickStatus[ID] := 1;
WriteConsole(ID,'Twoj profil zaktualizowany! Welcome!',GOOD);
WriteConsole(ID,'Statystyki wlaczone!!',GOOD);
WriteConsole(ID,'Wpisz /stats zeby sprawdzic statystyki!',GOOD);
end else
begin
nickStatus[ID] := 0;
WriteConsole(ID,'IP changed. Type /login ''password'' to login!',GOOD);
end
end
end
end;

//ONLEAVEGAME
procedure OnLeaveGame(ID, Team: byte; Kicked: boolean);
begin
//check if player is logged in
if (nickStatus[ID] = 1) then
begin
//update his stats before he left
UpdateNickname(GetPlayerStat(ID,'name'),ID);
end

//unset all player variables
nickStatus[ID] := 0;
IngameKills[ID] := 0;
IngameDeaths[ID] := 0;
IngameSelfkills[ID] := 0;
nickname_Name[ID] := '';
nickname_Password[ID] := '';
nickname_IP[ID] := '';
nickname_Kills[ID] := '';
nickname_Deaths[ID] := '';
nickname_Selfkills[ID] := '';
kdKills[ID] := 0;
kdDeaths[ID] := 0;
kdRatio[ID] := 0;
oldPassword[ID] := '';
newPassword[ID] := '';
end;

//ONPLAYERKILL
procedure OnPlayerKill(Killer, Victim: byte; Weapon: string);
begin
//if player is suicidal
if (Killer = Victim) then
begin
//check if player is logged in
if nickStatus[Killer] = 1 then
begin
//increase selfkills with 1
IngameSelfkills[killer] := IngameSelfkills[killer] +1;
end
end

//if player isn't the victim
if (killer <> victim) then
begin
//check is killer is logged in
if nickStatus[Killer] = 1 then
begin
//increase kills of killer with 1
IngameKills[killer] := IngameKills[killer] +1;
end

//check is victim is logged in
if nickStatus[victim] = 1 then
begin
//increase deaths of victim with 1
IngameDeaths[victim] := IngameDeaths[victim] +1;
end
end
end;

//ONFLAGSCORE
procedure OnFlagScore(ID, TeamFlag: byte);
begin
end;

//MAPCHANGE
procedure OnMapChange(NewMap: string);
var
i: byte;
begin
//reset kills,deaths,selfkills
for i := 1 to MAXPLAYER do
begin
//check if player is logged in
if (nickStatus[i] = 1) then
begin
//update his stats before map changes
UpdateNickname(GetPlayerStat(i,'name'),i);
IngameKills[i] := 0;
IngameDeaths[i] := 0;
IngameSelfkills[i] := 0;
end
end
end;

BB and thx


edit ou shit wrong forum :D
« Last Edit: January 02, 2010, 05:19:51 am by sckme »

Offline Hacktank

  • Camper
  • ***
  • Posts: 462
  • Soldat Scripter
    • HTZRPG
Re: Bank system with Nick Name Registration
« Reply #1 on: January 02, 2010, 06:57:22 am »
You could modify a store script with a saving system, yes. I may add one of my store script if i get around it it later.


Offline sckme

  • Major(1)
  • Posts: 33
Re: Bank system with Nick Name Registration
« Reply #2 on: January 04, 2010, 05:28:52 am »
ref

Offline sckme

  • Major(1)
  • Posts: 33
Re: Bank system with Nick Name Registration
« Reply #3 on: February 17, 2010, 12:17:15 pm »
ref??? can somebody help me?

Offline sckme

  • Major(1)
  • Posts: 33
Re: Bank system with Nick Name Registration
« Reply #4 on: March 01, 2010, 07:46:30 am »
REF? OMG!!!!!! HELP 111ONEONE

Offline Gizd

  • Flagrunner
  • ****
  • Posts: 586
  • (Re)tired
    • Eat-this! community site
Re: Bank system with Nick Name Registration
« Reply #5 on: March 01, 2010, 09:43:13 am »
My question: can script Nick Name Registration save the money, when i kill player, cap flag, and anything (script Buy)?
Yes.

Offline echo_trail

  • Global Moderator
  • Rainbow Warrior
  • *****
  • Posts: 2222
  • ménage-à-trois
    • my last.fm
Re: Bank system with Nick Name Registration
« Reply #6 on: March 01, 2010, 12:07:27 pm »
REF? OMG!!!!!! HELP 111ONEONE

Warned for spam. Cheers.
I fucking miss all you cunts!

Offline sckme

  • Major(1)
  • Posts: 33
Re: Bank system with Nick Name Registration
« Reply #7 on: March 02, 2010, 07:39:00 am »
omg what? can somebody write this scirpt? omg

Offline sckme

  • Major(1)
  • Posts: 33
Re: Bank system with Nick Name Registration
« Reply #8 on: March 20, 2010, 06:49:44 am »
pliz help

Offline mich1103

  • Flagrunner
  • ****
  • Posts: 557
  • Did you say chocolate ? O.o
    • ZoMbIe-DeStRoYeR pk server
Re: Bank system with Nick Name Registration
« Reply #9 on: March 20, 2010, 07:06:36 am »
Learn scripting by yourself !
Is what Swompie,croat1gamer and other said to me each time i want help for     script !!

ps: Don't Worry, Be happy

Offline sckme

  • Major(1)
  • Posts: 33
Re: Bank system with Nick Name Registration
« Reply #10 on: March 20, 2010, 07:31:14 am »
Learn scripting by yourself !
Is what Swompie,croat1gamer and other said to me each time i want help for     script !!

ps: Don't Worry, Be happy

gtfo.

Offline y0uRd34th

  • Camper
  • ***
  • Posts: 325
  • [i]Look Signature![/i]
Re: Bank system with Nick Name Registration
« Reply #11 on: March 20, 2010, 08:56:24 am »
Like you see no one is willing to help you. Combining large scripts isn't always that easy than people think. Now go learn soldat scripting, it is'nt hard. If you got questions make one topic and ask all of them there.

Offline LORD KILLA

  • Camper
  • ***
  • Posts: 254
  • Happie
Re: Bank system with Nick Name Registration
« Reply #12 on: March 22, 2010, 07:52:42 am »
Learn scripting by yourself !
Is what Swompie,croat1gamer and other said to me each time i want help for     script !!

ps: Don't Worry, Be happy

gtfo.

Ban maybe?
This isn't a forum for headless guys, you know. (or at least warn)

And Swampie: This