--- a/hedgewars/uScript.pas Tue Jun 04 00:10:48 2013 +0300
+++ b/hedgewars/uScript.pas Thu Jun 06 03:35:59 2013 +0300
@@ -1288,15 +1288,37 @@
function lc_sendstat(L : Plua_State) : LongInt; Cdecl;
var statInfo : TStatInfoType;
+var i : LongInt;
begin
+ //TODO print better error messages
statInfo := TStatInfoType(GetEnumValue(TypeInfo(TStatInfoType),lua_tostring(L, 1)));
- if lua_gettop(L) <> 2 then
+ if (lua_gettop(L) <> 2) and (statInfo <> siPlayerKills) then
begin
LuaError('Lua: Wrong number of parameters passed to SendStat!');
end
+ else if (lua_gettop(L) <> 3) and (statInfo = siPlayerKills) then
+ begin
+ LuaError('Lua: Wrong number of parameters passed to SendStat!');
+ end
else
begin
- SendStat(statInfo,lua_tostring(L, 2));
+ if(statInfo = siPlayerKills) then
+ begin
+ // 3: team name
+ for i:= 0 to Pred(TeamsCount) do
+ begin
+ with TeamsArray[i]^ do
+ begin
+ if TeamName = lua_tostring(L, 3) then
+ SendStat(siPlayerKills, uUtils.IntToStr(Clan^.Color) + ' ' +
+ lua_tostring(L, 2) + ' ' + TeamName);
+ end;
+ end;
+ end
+ else
+ begin
+ SendStat(statInfo,lua_tostring(L, 2));
+ end;
end;
lc_sendstat:= 0
end;