Pc heals when they re log
Hc_Sephiroth
Member Posts: 10
How do you prevent a pc from re logging in middle of battle to heal back to full HP. I know there's a way to do it but not sure if it's a script or a player.ini line.
0
Comments
if you CAN, have your Module OnClientExit script check PC hp and save it on the token
in the module OnClientEnter script, check the variable, damage the PC by hpmax - saved hp.. that will damage them down to whatever hps they had when they left the world
#include "pw_inc_anticheat"
void main()
{object oPC = GetExitingObject();
StorePlayerInfo(oPC);
}
onclient enter
#include "pw_inc_anticheat"
void main()
{object oPC;
oPC = GetEnteringObject();
LoadPlayerInfo(oPC);
}
include file pw_inc_anticheat
//::///////////////////////////////////////////////
//:: pw_inc_anticheat
//:: Written by EPOlson (eolson@cisco.com)
//:: Feb 2004 (for the pw scripts)
//:: Trimmed to just hit point logging: April 2008
//:://////////////////////////////////////////////
// Trimmed include file with functions that
// store HPs in local/campaign variables
// then restore them on login.
//:://////////////////////////////////////////////
const string CAMPAIGNDB = "PWHELPER";
// Local vars to store data (append player name and character name)
const string PC_INFO_HP = "Pc_Hp_"; // int
// Used to store the player's CD key in the OnClientEnter event.
// (because it will not be available during OnClientExit - player is gone)
const string PERSISTANT_PLAYER_NAME = "Player_Name_";
// store player HPs on exit
// call upon exit (client exit or area exit)
void StorePlayerInfo(object oPC);
void StorePlayerInfo(object oPC)
{
object oMod = GetModule();
string sName = GetName(oPC);
string sID = GetLocalString(oMod, PERSISTANT_PLAYER_NAME + sName) + sName;
// Log this call.
PrintString("PWH Info - StorePlayerInfo for " + sName + "{" + sID + "}");
// Record current hit points.
int nCurrentHP = GetCurrentHitPoints(oPC);
SetLocalInt(oMod, PC_INFO_HP + sID, nCurrentHP);
SetCampaignInt(CAMPAIGNDB, PC_INFO_HP + sID, nCurrentHP);
}
// restore player HPs from local vars
// call during login
void LoadPlayerInfo(object oPC);
void LoadPlayerInfo(object oPC)
{
// Only function for PCs.
if( !GetIsPC(oPC) )
return;
object oMod = GetModule();
string sID = GetPCPlayerName(oPC) + GetName(oPC);
string sPC = GetName(oPC);
// Record the player's name so it can be used in the OnClientExit event.
SetLocalString(oMod, PERSISTANT_PLAYER_NAME + sPC, GetPCPlayerName(oPC));
// Log this call.
PrintString("PWH Info - LoadPlayerInfo for " + sPC + "{" + sID + "}");
SendMessageToPC(oPC, "OOC: Restoring previous hit points.");
// Find the hit points previously stored.
int nHP = GetLocalInt(oMod, PC_INFO_HP + sID);
if ( nHP == 0 )
// Not stored locally. Try the database.
nHP = GetCampaignInt(CAMPAIGNDB, PC_INFO_HP + sID);
// If a record of previous hit points was found...
if ( nHP != 0 )
// ... remove excess hit points obtained by logging in.
ApplyEffectToObject(DURATION_TYPE_PERMANENT,
EffectDamage(GetCurrentHitPoints(oPC) - nHP, DAMAGE_TYPE_MAGICAL, DAMAGE_POWER_PLUS_FIVE),
oPC);
}