PDA

View Full Version : [CoD2] Only about 0.2 sec of my roundcam is displayed



raphael
22nd May 2023, 09:08
Hi
I am trying to make a roundcam inspired by CoDaM of CoD 1.1

(by roundcam I mean the player who killed the last in opposing team, will produce a killcam that everyone will see)

I have no errors, but after killing the last enemy, a few seconds pass, then only about 0.2 sec of the roundcam is displayed, and then the new round starts...

Can you see the error in the following code parts?


in _killcam.gsc


roundcam(goal, delay, msg, offsetTime)
{
printf("######### _killcam: roundcam \n");

self.sessionstate = "spectator";

if (isPlayer(goal))
{
self.spectatorclient = goal getEntityNumber();
}
else
{
self.spectatorclient = -1;
self spawn(goal.origin , goal.angles);
}

self.archivetime = delay + 7;
self.psoffsettime = offsetTime;

// ignore spectate permissions
self allowSpectateTeam("allies", true);
self allowSpectateTeam("axis", true);
self allowSpectateTeam("freelook", true);
self allowSpectateTeam("none", true);

// wait till the next server frame to allow code a chance to update archivetime if it needs trimming
wait 0.05;

...

self removeKillcamElements();
self.spectatorclient = -1;
self.archivetime = 0;
self.psoffsettime = 0;

self thread maps\mp\gametypes\_spectating::setSpectatePermissi ons();

level notify("roundcam_ended");
}



in sd.gsc


endRound(roundwinner, cam, offset)
{

...

if (doRoundcam)
{
level roundCam(cam, roundwinner, offset);
}
else
{
level notify("restarting");
map_restart(true);
}
}

//////////////////////////////////////////////////////////

roundCam(cam, roundwinner, offset)
{
if (!isdefined(cam) || !isdefined(roundwinner) || !isdefined(offset))
{
wait(3);
return;
}

delay = 2;
wait(delay);

...

viewers = 0;
players = getentarray("player", "classname");

for (i = 0; i < players.size; i++)
{
player = players[i];
if (isdefined(player.killcam) || (player.archivetime > 0))
{
// Already running killcam, stop it
player notify("spawned");
wait(0.05);
player.spectatorclient = -1;
player.archivetime = 0;
}
player thread maps\mp\gametypes\_killcam::roundcam(cam, delay, text, offset);
viewers++;
}

if (viewers)
{
level waittill("roundcam_ended");

level notify("restarting");
map_restart(true);
}
else
{
wait(3 - delay);
}
}

//////////////////////////////////////////////////////////

updateTeamStatus()
{

...

// if axis were alive and now they are not
if(oldvalue["axis"] && !level.exist["axis"])
{
// if axis planted the bomb, continue the round
if(level.bombplanted && level.planting_team == "axis")
return;

_announce = &"MP_AXISHAVEBEENELIMINATED";
iprintln(&"MP_AXISHAVEBEENELIMINATED");
level thread playSoundOnPlayers("mp_announcer_axiselim");

level thread endRound("allies", level.playercam, level.offsetTimeCam);

return;
}
}





I know that the roundcam func of _killcam.gsc gets called because I see the following message in my server terminal:

https://i.ibb.co/HNt31hR/log.png (https://i.ibb.co/HNt31hR/log.png)



Could you please take a look?

raphael
23rd May 2023, 00:31
Is now fixed
Couldn't explain precisely how/why, but I think the following code could



endRound(roundwinner, cam, offset)
{

...

else if(roundwinner == "axis")
{
doRoundcam = true;

game["axisscore"]++;
setTeamScore("axis", game["axisscore"]);

players = getentarray("player", "classname");
for(i = 0; i < players.size; i++)
{
lpGuid = players[i] getGuid();
if((isdefined(players[i].pers["team"])) && (players[i].pers["team"] == "axis"))
winners = (winners + ";" + lpGuid + ";" + players[i].name);
else if((isdefined(players[i].pers["team"])) && (players[i].pers["team"] == "allies"))
losers = (losers + ";" + lpGuid + ";" + players[i].name);
}
logPrint("W;axis" + winners + "\n");
logPrint("L;allies" + losers + "\n");
}

if (doRoundcam)
{
printf("######### sd: endRound: doRoundcam \n");
level roundCam(cam, roundwinner, offset);
}
else
{
wait 7;
}

...

level notify("restarting");
map_restart(true);
}

roundCam(cam, roundwinner, offset)
{
if (!isdefined(cam) || !isdefined(roundwinner) || !isdefined(offset))
{
wait(3);
return;
}

delay = 2;
wait(delay);

...

viewers = 0;
players = getentarray("player", "classname");

for (i = 0; i < players.size; i++)
{
player = players[i];
if (isdefined(player.killcam) || (player.archivetime > 0))
{
// Already running killcam, stop it
player notify("spawned");
wait(0.05);
player.spectatorclient = -1;
player.archivetime = 0;
}
player thread maps\mp\gametypes\_killcam::roundcam(cam, delay, text, offset);
viewers++;
}

if (viewers)
{
level waittill("roundcam_ended");
}
else
{
wait(3 - delay);
}
}