Skip to content

Script Help? – Edit Placeable Object Name.

dargno07dargno07 Member Posts: 10
edited January 2019 in Builders - Scripting
Hi

What i'm trying to do is create a lootable corpse on player death that gets deleted after 10 minutes. 1 random equipped item and maybe 10-30% GP from dead player gets placed on corpse. Corpse can then be looted by anyone, but would be great if script had an option (either by cd key, or player name) to link player to their corpse making corpse lootable only by whoever it belongs to.

I have it all working except for option to link player name to the object... anyone able to help me out?

Also, would it be possible to change the name of the corpse/object after it's creation?

Edit; The script is for "OnPlayerRespawn" not ondeath.

Comments

  • ProlericProleric Member Posts: 1,281
    Assuming the corpse is a placeable (not a dead creature), you can use SetDescription.

    You can then GetDescription in the OnUsed event etc to check that the player name matches before opening the inventory. If not, tell the player "this is not your corpse" and close the inventory (from memory, clearing player actions or starting a conversation will do that, or you could lock the corpse, unlocking only for the owner).
  • dargno07dargno07 Member Posts: 10
    I have some of it working, i managed to change the name of the object placeable to match player name, and made it so only the object owner can loot with a message sent... having trouble with closing the inventory though, ClearAllActions doesn't seem to work, i'll try starting a conversation.

    Thanks
  • dargno07dargno07 Member Posts: 10
    conversation works.

    now i am trying to do something else though... after 3 minutes i'd like to make the corpse lootable by everyone, not just the player it's linked to.

    to link the player name to the object i use this -

    string sPlayerName=GetPCPlayerName(oRespawner);
    SetLocalString(oCorpse, "player_name", sPlayerName);

    then i delete the string in the same OnPlayerRespawn script -

    DelayCommand(180.0,DeleteLocalString(oCorpse, "player_name"));

    this is what i have in the OnUsed event for the corpse object -

    void main()
    {
    object oPC=GetLastUsedBy();
    string sPlayerName=GetPCPlayerName(oPC);
    if(GetLocalString(OBJECT_SELF, "player_name") != sPlayerName)
    {
    //DelayCommand(1.0, FloatingTextStringOnCreature("This corpse does not belong to you.", oPC, FALSE));
    AssignCommand(oPC, ClearAllActions(TRUE));
    ActionStartConversation(oPC);
    return;
    }
    }

    so... how do i make the object lootable by everyone after 3 minutes, deleting the string doesn't work. After 3 minutes the conversation starts for the player who is linked to the object, and everyone else.

    Thank ya!
  • vonstormvonstorm Member Posts: 66
    I would try adding a local int on the corpse called expired setting it to 0, then have a small heatbeat script that sets it to 1 after allotted time.
    Then you can add

    int iExpired = GetLocalInt (OBJECT_SELF,"expired");
    if (iExpired >0) // make lootable if not check playername and fire convo

    may be a better way of doing this, but thats my 10c
  • dargno07dargno07 Member Posts: 10
    works perfect now, thanks vonstorm and proleric.
Sign In or Register to comment.