0 Members and 1 Guest are viewing this topic.
const scorefile= 'roulettescores.ini';type pnames= array[1..32] of string; pscores= array[1..32] of integer; gscores= array[1..4] of integer;var playernames: pnames; playerscores: pscores; globalscores: gscores; recordholder: string; latestdeath: string; scores: string; activated: boolean; resetscores: boolean; scoresarray: TStringArray;function powerOf(a:integer;b:integer):integer;var t,i: integer;begin t:=1; for i:=1 to b do begin t:=t*a; end; result:= t;end;function rand(limit: integer):integer;begin result:= powerOf(strtoint(formatdate('zz')),3) mod limit;end;function loadscores():boolean;var count: integer;begin globalscores[1]:= strtoint(ReadINI(scorefile,'global','record','0')); globalscores[2]:= strtoint(ReadINI(scorefile,'global','spins','0')); globalscores[3]:= strtoint(ReadINI(scorefile,'global','deaths','0')); globalscores[4]:= strtoint(ReadINI(scorefile,'global','percentage','0')); recordholder:= ReadINI(scorefile,'global','recordholder',''); latestdeath:= ReadINI(scorefile,'global','latestdeath',''); for count:= 1 to NumPlayers do begin playernames[count]:= IDToName(count); playerscores[count]:= strtoint(ReadINI(scorefile,'players',IDToName(count),'0')); end; result:= true;end;function checkname(name: string):boolean;var count: integer;begin for count:= 1 to ArrayHigh(playernames) do begin if (ContainsString(playernames[count],name) and (Length(playernames[count])=Length(name))) then begin result:= true; end; end;end;function savescores():boolean;var count: integer; nl,tempstring: string; temparray: TStringArray;begin nl:= chr(13)+chr(10); for count:= 0 to 7 do case count of 0: scores:= '[global]' +nl; 1: scores:= scores +'record=' +inttostr(globalscores[count]) +nl; 2: scores:= scores +'spins=' +inttostr(globalscores[count]) +nl; 3: scores:= scores +'deaths=' +inttostr(globalscores[count]) +nl; 4: scores:= scores +'percentage=' +inttostr(globalscores[count]) +nl; 5: scores:= scores +'recordholder=' +recordholder +nl; 6: scores:= scores +'latestdeath=' +latestdeath +nl; 7: scores:= scores +'[players]' +nl; end; for count:= 1 to NumPlayers do scores:= scores +playernames[count] +'=' +inttostr(playerscores[count]) +nl; scoresarray:= split(ReadFile(scorefile),nl); if (ArrayHigh(scoresarray)>7) then for count:= 8 to ArrayHigh(scoresarray) do begin tempstring:= scoresarray[count]; temparray:= split(tempstring,'='); tempstring:= temparray[0]; if (not(checkname(tempstring))) then begin scores:= scores +scoresarray[count]; end; end; WriteFile(scorefile,scores); result:= true;end;function spin(name: string;bullets: byte):boolean;var randnum: integer;begin loadscores(); randnum:= (rand(6) +1); globalscores[2]:= globalscores[2] +1; if (bullets>=randnum) then begin Command('/say '+name+' picks up the gun, spins the chamber, and pulls the trigger...'); if (bullets=6) then Command('/say Well aren''t you cute, hoping that''d work'); Command('/say BANG!!!! SPLAT!! ('+inttostr(playerscores[NameToID(name)])+' points)'); Command('/kill '+inttostr(NameToID(name))); playerscores[NameToID(name)]:= 0; globalscores[3]:= globalscores[3] +1; latestdeath:= name; end; if (bullets<randnum) then begin Command('/say '+name+' picks up the gun, spins the chamber, and pulls the trigger...'); Command('/say CLICK'); playerscores[NameToID(name)]:= playerscores[NameToID(name)] +(bullets*bullets); end; globalscores[4]:= (100* globalscores[3]/ globalscores[2]); if (globalscores[1]< playerscores[NameToID(name)]) then begin globalscores[1]:= playerscores[NameToID(name)]; recordholder:= playernames[NameToID(name)]; Command('/say New record by '+playernames[NameToID(name)]+': '+inttostr(globalscores[1])+' spins in a row!'); end; savescores(); result:= true;end;function showscores(name: string):boolean;begin Command('/say Record holder: '+recordholder+' with '+inttostr(globalscores[1])+' points'); Command('/say Total spins: '+inttostr(globalscores[2])+' Total deaths: '+inttostr(globalscores[3])); Command('/say Death percentage: '+inttostr(globalscores[4])+'% Latest death: '+latestdeath); result:= true;end;procedure OnJoinTeam(IP, Nickname: string;Team: byte);begin playernames[NameToID(Nickname)]:= Nickname; playerscores[NameToID(Nickname)]:= 0;end;procedure OnPlayerSpeak(Name,Text: string);var count: integer; remote: string; remotearray: TStringArray;begin if (activated=true) then begin if ((Text='!spin') or (Text='!spin 1')) then spin(Name,1) else if (Text='!spin 2') then spin(Name,2) else if (Text='!spin 3') then spin(Name,3) else if (Text='!spin 4') then spin(Name,4) else if (Text='!spin 5') then spin(Name,5) else if (Text='!spin 6') then spin(Name,6); if (Text='!scores') then showscores(Name); end else if (Text='!spin') then Command('/say The roulette game is deactivated, an admin can activate it with "!spin on"'); if (Text='!spin on') then begin remote:= ReadFile('remote.txt'); remotearray:= split(remote,chr(13)+chr(10)); for count:= 0 to ArrayHigh(remotearray) do if ((IPToID(remotearray[count])=NameToID(Name)) and (NameToID(Name)<>32)) then begin Command('/say '+Name+' activated the russian roulette game') activated:= true; end; end; if (Text='!spin off') then begin remote:= ReadFile('remote.txt'); remotearray:= split(remote,chr(13)+chr(10)); for count:= 0 to ArrayHigh(remotearray) do if ((IPToID(remotearray[count])=NameToID(Name)) and (NameToID(Name)<>32)) then begin Command('/say '+Name+' deactivated the russian roulette game') activated:= false; end; end; if (Text='!spin reset') then begin remote:= ReadFile('remote.txt'); remotearray:= split(remote,chr(13)+chr(10)); for count:= 0 to ArrayHigh(remotearray) do begin if ((IPToID(remotearray[count])=NameToID(Name)) and (NameToID(Name)<>32)) then begin if (resetscores=false) then begin Command('/say '+Name+', are you sure you want to reset the russian roulette scores?'); Command('/say Type "!spin reset" again to reset them'); resetscores:= true; end else if (resetscores=true) then begin WriteFile(scorefile,'[global]'+chr(13)+chr(10)+'[players]'+chr(13)+chr(10)); Command('/say Scores reset by '+Name); resetscores:= false; end; end; end; end;end;
[global][players]
for count:= 1 to NumPlayers do beginend;
You type !spin, and if a randum number is X, you die, and if its not, you're alive and get points.
Thanks to cooz for his excellent random script which made this possible! I'd applaud you but I haven't posted enough.Â
ahhh...ok that fixed networkcore.pas, but now there's a error in roulette.pas Compiling Script roulette.pas... [Error] (302:1): Duplicate identifier ''