0 Members and 2 Guests are viewing this topic.
procedure OnJoinTeam(ID, Team: byte);beginif (FileExists('scripts/money/player/'+inttostr(GetPlayerStat(ID,'Name'))+'.txt')) then beginmoney[ID] := WriteLn(ReadFile('scripts/money/player/'+inttostr(GetPlayerStat(ID,'Name'))+'.txt')) -50; end;end;
procedure OnJoinGame(ID, Team: byte);var fname: string;beginfname := 'scripts/money/player/' + getplayerstat(ID,'name') + '.txt');if fileexists(fname) then begin money[ID] := strtoint(readfile(fname)) - 50; endend
function BadCharByNum(Num: integer): string;beginresult := '';case num of 0: result := '\'; 1: result := '/'; 2: result := ':'; 3: result := '*'; 4: result := '?'; 5: result := '"'; 6: result := '<'; 7: result := '>'; 8: result := '|'; end;end;function SafeName(Name: string): string;var still: boolean; i,temp: integer;beginresult := name;still := true;while(still=true) do begin still := false; for i := 0 to 8 do begin if containsstring(name,badcharbynum(i)) then begin temp := pos(badcharbynum(i),name); delete(name,temp,1); still := true; end; end; end;result := name;end;
Hacktank, that will delete only 1 bad char of a type. Anyway, what if player's nick is *** and other player's nick is ///?
function FilterFilename(const 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='|') then result := result + '_' else result := result + c; end; result := LowerCase(result);end;
Pasted from Fistbox:Quotefunction FilterFilename(const 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='|') then result := result + '_' else result := result + c; end; result := LowerCase(result);end;
Still doesn't solve the problem of nick made of invalid chars.
procedure OnJoinGame(ID, Team: byte);var fname: string;beginfname := 'scripts/ws/playermoney/' + getplayerstat(ID,'name') + '.txt';if fileexists(fname) then begin money[ID] := strtoint(readfile(fname)); writeConsole(ID, 'Your Money is: $' + inttostr(money[ID]), RGB(0,255,255)); end elsebegin money[ID] := 50; writeConsole(ID, 'Your Money is: $' + inttostr(money[ID]), RGB(0,255,255)); end;end;
function GetMoney(ID: byte): integer;var money: string;begin money:= ReadFile('scripts/ws/playermoney/' + getplayerstat(ID,'name') + '.txt'); Result:= StrToInt(Copy(money, 0, length(money) - 2));end;
What for? Can't you copy&paste code?