Quote:
Originally Posted by 8guawong
What are you doing in the callback?
|
Basically I'm just checking for how long and how far a player has been separated from their teammates. Once the player reaches the distance limit that is set by a cvar, a special infected is spawned behind them to "punish" them.
Spoiler
PHP Code:
public Action tAutoTimerUpdatePlayer(Handle timer, any data)
{
if(!cvPunishTankAlive.BoolValue)
vCountTanks();
if(!cvEnablePlugin.BoolValue || !cvPunishEnable.BoolValue || !cvPunishAutoMode.BoolValue || cvPunishDistanceLimit.IntValue == 0 || iNumTanks3 || !bIsNotConsole() || !bIsSystemValid())
return Plugin_Continue;
float flPlayerPos[3];
float flPos[3];
GetClientEyePosition(iPlayerIndex, flPlayerPos);
int iPlayerCount = 0;
int iBotCount = 0;
int iClosestCompanionCount = 1;
int iCompanionCount = 1;
for(int iPlayer = 1; iPlayer <= MaxClients; iPlayer++)
{
if(IsClientInGame(iPlayer) && GetClientTeam(iPlayer) == 2 && IsPlayerAlive(iPlayer))
{
if(IsFakeClient(iPlayer))
iBotCount++;
else
iPlayerCount++;
if(iPlayer == iPlayerIndex)
continue;
GetClientEyePosition(iPlayer, flPos);
if(GetVectorDistance(flPos, flPlayerPos) < cvPunishDistanceLimit.FloatValue)
iCompanionCount++;
if(GetVectorDistance(flPos, flPlayerPos) <= 500.0)
iClosestCompanionCount++;
}
}
iPlayerCompanionCount[iPlayerIndex] = iCompanionCount;
iPlayerClosestCompanionCount[iPlayerIndex] = iClosestCompanionCount;
if(iCompanionCount > 1 && iBotCount + iPlayerCount > 1)
{
flPlayerAloneStartTime[iPlayerIndex] = GetEngineTime();
bMsg[iPlayerIndex] = true;
}
else
{
if(bMsg[iPlayerIndex] && bIsValidClient(iPlayerIndex))
PrintHintText(iPlayerIndex, "[ASS] %t", "SpecialWarn");
bMsg[iPlayerIndex] = false;
}
if((iBotCount + iPlayerCount > 1 && GetEngineTime() - flPlayerAloneStartTime[iPlayerIndex] > 1.0) && (flPlayerSpawnTime[iPlayerIndex] + flPlayerSpawnInterval[iPlayerIndex] < GetEngineTime()))
{
CreateTimer(0.1, tTimerPunishSpeedrunners, iPlayerIndex, TIMER_FLAG_NO_MAPCHANGE);
flPlayerSpawnTime[iPlayerIndex] = GetEngineTime();
if(cvPunishMinSeconds.IntValue != 0 && cvPunishMaxSeconds.IntValue != 0)
flPlayerSpawnInterval[iPlayerIndex] = GetRandomFloat(cvPunishMinSeconds.FloatValue, cvPunishMaxSeconds.FloatValue);
}
return Plugin_Continue;
}
Though, the callback isn't the problem. I'm just wondering why setting the cvar value to 0.1 and using ConVar.FloatValue to retrieve it returns 0. I thought it'd be the same as manually setting the timer to 0.1.
I suppose when doing ConVar.BoolValue it works as follows: 0.9 (any number with 0 as the whole number rounds off to 0) ~= 0 = false, 1.1 (anything with 1 as the whole number rounds off to 1) ~= 1 = true (if true, that value will be used as the bool value).
And for ConVar.FloatValue, it seems to work as follows: 0.9 (any number with 0 as the whole number rounds off to 0) ~= 0 = false, 5.5 (1 or any value greater than 1) ~= 1 = true (if true, that value will be used as the float value).
__________________