Simple Exp

From Soldat Community Wiki
Jump to: navigation, search

Script by Spkka

const
	MAXPLAYER = 16;

var
	playerExp: array [1..MAXPLAYER] of integer;
	playerLev: array [1..MAXPLAYER] of integer;
	GOOD, BAD: longint;

procedure ActivateServer();
begin
	//color of writeconsole messages
	GOOD := $EE00FF00;
	BAD := $FFFF4444;
end;

procedure OnMapChange(NewMap: string);
var
	i: byte;
begin
	//reset scores for all players onmapchange
	for i := 1 to MAXPLAYER do
	begin
		playerExp[i] := 0;
		playerLev[i] := 1;
	end
end;

procedure OnJoinTeam(ID, Team: byte);
begin
	//reset score player joining
	playerExp[ID] := 0;
	playerLev[ID] := 1;
end;

procedure OnLeaveGame(ID, Team: byte; Kicked: boolean);
begin
	//reset score player leaving
	playerExp[ID] := 0;
	playerLev[ID] := 1;
end;

function OnPlayerCommand(ID: Byte; Text: string): boolean;
begin
	//command to check your current level
	if (Copy(Text,1,7) = '/level') then 
	begin
		WriteConsole(ID, 'You got '+ inttostr(playerExp[ID]) + ' Exp',GOOD);
		WriteConsole(ID, 'You are now Level: '+ inttostr(playerLev[ID]),GOOD);
	end
  Result := false;
end;

Procedure checkPlayerlev(Killer: byte);
begin
	//check how player Exp to level
	//add more if you want more levels etc
	if (playerExp[Killer] > 800) and (playerLev[Killer] = 6) then
	begin
		WriteConsole(Killer,'You are now Level 7!',GOOD);
		WriteConsole(0,getPlayerStat(Killer, 'Name') + ' is now Level 7!',GOOD);
		playerLev[Killer] := 7;
	end

	if (playerExp[Killer] > 400) and (playerLev[Killer] = 5) then
	begin
		WriteConsole(Killer,'You are now Level 6!',GOOD);
		WriteConsole(0,getPlayerStat(Killer, 'Name') + ' is now Level 6!',GOOD);
		playerLev[Killer] := 6;
	end

	if (playerExp[Killer] > 200) and (playerLev[Killer] = 4) then
	begin
		WriteConsole(Killer,'You are now Level 5!',GOOD);
		WriteConsole(0,getPlayerStat(Killer, 'Name') + ' is now Level 5!',GOOD);
		playerLev[Killer] := 5;
	end

	if (playerExp[Killer] > 100) and (playerLev[Killer] = 3) then
	begin
		WriteConsole(Killer,'You are now Level 4!',GOOD);
		WriteConsole(0,getPlayerStat(Killer, 'Name') + ' is now Level 4!',GOOD);
		playerLev[Killer] := 4;
	end

	if (playerExp[Killer] > 50) and (playerLev[Killer] = 2) then
	begin
		WriteConsole(Killer,'You are now Level 3!',GOOD);
		WriteConsole(0,getPlayerStat(Killer, 'Name') + ' is now Level 3!',GOOD);
		playerLev[Killer] := 3;
	end

	if (playerExp[Killer] > 25) and (playerLev[Killer] = 1) then
	begin
		WriteConsole(Killer,'You are now Level 2!',GOOD);
		WriteConsole(0,getPlayerStat(Killer, 'Name') + ' is now Level 2!',GOOD);
		playerLev[Killer] := 2;
	end
end;

procedure OnPlayerKill(Killer, Victim: byte; Weapon: string);
begin
	//set score killer and victim
	//change if you want to give the killer/victim more/less points per kill
	if Victim <> Killer then
	begin
		if getPlayerStat(Killer, 'Active') = true then
		begin
			playerExp[Killer] := playerExp[Killer] + 5;
			checkPlayerlev(Killer);
		end

		if getPlayerStat(Victim, 'Active') = true then
		begin
			playerExp[Victim] := playerExp[Victim] - 5;
		end
	end

	//set score suicide
	if killer = Victim then
	begin
		if getPlayerStat(Killer, 'Active') = true then
		begin
			playerExp[Killer] := playerExp[Killer] - 5;
			checkPlayerlev(Killer);
		end
	end
end;