
tuto: Nexgen : Pour eviter les Prevent from Dying
PREVENT DAMAGE ( The server has prevented you from dying)
IL faut désactiver ces protections c'est elles qui provoque ce respawn avec ce message ( il vous evite de vous faire Tuer par
la lave, les chutes ,ou les cannons automatiques si vous êtes sous spawnProtection)
spawnProtectionTime=0
Reste a test ces 2
c'est quand un autre joueur vous tire dessus dans les parties par équipes ou le monsterhunt
teamKillDamageProtectionTime=0
teamKillPushProtectionTime=0
ICI JE MET LE CODE :
Code:
/***************************************************************************************************
*
* $DESCRIPTION Called when a pawn takes damage.
* $PARAM actualDamage The amount of damage sustained by the pawn.
* $PARAM victim Pawn that has become victim of the damage.
* $PARAM instigatedBy The pawn that has instigated the damage to the victim.
* $PARAM hitLocation Location where the damage was dealt.
* $PARAM momentum Momentum of the damage that has been dealt.
* $PARAM damageType Type of damage dealt to the victim.
* $REQUIRE victim != none
* $OVERRIDE
*
**************************************************************************************************/
function mutatorTakeDamage(out int actualDamage, Pawn victim, Pawn instigatedBy,
out vector hitLocation, out vector momentum, name damageType) {
local NexgenClient client;
local byte bPreventDamage;
local byte bResetPlayer;
local int index;
// Get client.
client = getClient(victim);
// Check if damage should be prevented.
if (client != none && damageType != suicideDamageType) {
checkPreventDamage(client, instigatedBy, damageType, actualDamage, bPreventDamage, bResetPlayer);
// Prevent the damage.
if (bool(bPreventDamage)) {
actualDamage = 0;
if (bool(bResetPlayer)) {
level.game.restartPlayer(client.player);
client.showMsg(lng.deathPreventedMsg);
}
}
// Team kill?
if (victim != instigatedBy && level.game.gameReplicationInfo.bTeamGame &&
instigatedBy != none && (instigatedBy.isA('PlayerPawn') || instigatedBy.isA('Bot')) &&
victim.playerReplicationInfo.team == instigatedBy.playerReplicationInfo.team) {
// Yes, prevent damage & protect victim.
client.tkPushProtectionTimeX = sConf.teamKillPushProtectionTime;
if (!bool(bPreventDamage) && sConf.teamKillDamageProtectionTime > 0 &&
(!level.game.isA('TeamGamePlus') || TeamGamePlus(level.game).friendlyFireScale <= 0 )) {
// Damage hasn't been prevented yet.
actualDamage = 0;
client.tkDmgProtectionTimeX = sConf.teamKillDamageProtectionTime;
// Notify players if desired.
if (sConf.broadcastTeamKillAttempts) {
broadcastMsg(lng.teamKillAttemptMsg, instigatedBy.playerReplicationInfo.playerName,
victim.playerReplicationInfo.playerName, , ,
instigatedBy.playerReplicationInfo);
}
}
}
}
// Notify plugins.
while (index < arrayCount(plugins) && plugins[index] != none) {
plugins[index].mutatorTakeDamage(actualDamage, victim, instigatedBy, hitLocation, momentum, damageType);
index++;
}
// Let other mutators do their job.
if (nextDamageMutator != none) {
nextDamageMutator.mutatorTakeDamage(actualDamage, victim, instigatedBy, hitLocation, momentum, damageType);
}
}
/***************************************************************************************************
*
* $DESCRIPTION Called when the server wants to check if a players death should be prevented.
* $PARAM victim The pawn that was killed.
* $PARAM killer The pawn that has killed the victim.
* $PARAM damageType Type of damage dealt to the victim.
* $PARAM hitLocation Location where the damage was dealt.
* $RETURN True if the players death should be prevented, false if not.
* $OVERRIDE
*
**************************************************************************************************/
function bool preventDeath(Pawn victim, Pawn killer, name damageType, vector hitLocation) {
local NexgenClient client;
local byte bPreventDamage;
local byte bResetPlayer;
local int index;
// Get client.
client = getClient(victim);
// Check if damage should be prevented.
if (client != none && damageType != suicideDamageType) {
checkPreventDamage(client, killer, damageType, 99999, bPreventDamage, bResetPlayer);
// Prevent the damage.
if (bool(bPreventDamage)) {
client.player.health = 100;
if (bool(bResetPlayer)) {
level.game.restartPlayer(client.player);
client.showMsg(lng.deathPreventedMsg);
}
return true;
}
}
// Notify plugins.
while (index < arrayCount(plugins) && plugins[index] != none) {
if (plugins[index].preventDeath(victim, killer, damageType, hitLocation)) return true;
index++;
}
// Let other mutators do their job.
if (nextMutator == none) {
return false;
} else {
return nextMutator.preventDeath(victim, killer, damageType, hitLocation);
}
}
/***************************************************************************************************
*
* $DESCRIPTION Checks whether the specified damage to the client should be prevented.
* $PARAM client The client for which the damage prevention check should be executed.
* $PARAM instigator The pawn that has instigated the damage to the victim.
* $PARAM damageType Type of damage the player has sustained.
* $PARAM damage The amount of damage sustained by the client.
* $PARAM bPreventDamage Whether the damage should be prevented or not.
* $PARAM bResetPlayer Indicates if the player should restart if the damage is prevented.
* $REQUIRE client != none
*
**************************************************************************************************/
function checkPreventDamage(NexgenClient client, Pawn instigator, name damageType, int damage,
out byte bPreventDamage, out byte bResetPlayer) {
// Check if player has switched to another team.
if (client.team != client.player.playerReplicationInfo.team) {
// Yes, don't prevent the damage.
bPreventDamage = byte(false);
bResetPlayer = byte(false);
return;
}
// Spawn protection.
if (client.spawnProtectionTimeX > 0) {
bPreventDamage = byte(true);
bResetPlayer = byte(client.player.playerReplicationInfo.hasFlag == none &&
(damageType == fallDamageType && client.player.health <= damage ||
damageType == burnDamageType ||
damageType == corrodeDamageType));
}
// Team kill damage & push protection.
if (!bool(bPreventDamage)) {
bPreventDamage = byte(client.tkDmgProtectionTimeX > 0 &&
client.player == instigator ||
client.tkPushProtectionTimeX > 0 &&
(damageType == fallDamageType ||
damageType == burnDamageType ||
damageType == corrodeDamageType ||
instigator == none));
bResetPlayer = byte(client.tkPushProtectionTimeX > 0 &&
client.player.playerReplicationInfo.hasFlag == none &&
(damageType == fallDamageType && client.player.health <= damage ||
damageType == burnDamageType ||
damageType == corrodeDamageType));
}
}