Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

New Premium Module: Tyrants of the Moonsea! Read More
Attention, new and old users! Please read the new rules of conduct for the forums, and we hope you enjoy your stay!

Pc heals when they re log

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.

Comments

  • meaglynmeaglyn Member Posts: 55
    It's usually done by restoring saved HP from persistence on client enter. It's scripted.

  • Sylvus_MoonbowSylvus_Moonbow Member Posts: 1,021
    Yeah. All you need to do is store the HP of the character logging out then reapply the damage on them logging back in when the server is restarted to make sure they continue to have the damage applied that they logged out with instead of making them fully healed when they rejoin the server to prevent them from circumventing the system and not having to rest or spend gold to do so because they know that by logging off and logging back in they will be back to full hitpoints and memorized spells so that is something you control from your end.

  • antirelicantirelic Member Posts: 20
    Just force them to jump to the module start location on client enter. Sure, they avoid death but lose progress.

    raz651
  • Hc_SephirothHc_Sephiroth Member Posts: 10
    edited May 2018
    raz651 said:
    Can't seem to figure it out. Shows that player has the damage before login but then has full hp on joining game. The campaign/module string could be what I'm not understanding.

  • MermutMermut Member Posts: 38
    What are you using for persistence? NWNx? tokens? something else?

  • Hc_SephirothHc_Sephiroth Member Posts: 10
    Mermut said:

    What are you using for persistence? NWNx? tokens? something else?

    Tokens. Why, does a extra string need to be added?

  • MermutMermut Member Posts: 38
    I'm not sure if you can manipulate a character's inventory in the module OnExit script
    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

  • Knight_ShieldKnight_Shield Member Posts: 39
    onclient leave

    #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 ([email protected])
    //:: 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);
    }

Sign In or Register to comment.