Skip to content

How do I give an incoming player an item, but not every time they log off and back in?

What I'm trying to do is give a new, incoming player a Recall Stone. But, if they log off and log back in, I don't want them to get another of the same item. I am not good at scripting, so help would be great. Thanks!

Comments

  • FreshLemonBunFreshLemonBun Member Posts: 909
    Something like this I imagine.
    object oPC = GetEnteringObject(); //get the player
    string sTag = "recall_stone"; //get item tag
    string sResRef = "item_stone_05"; //blueprint reference
    if (GetIsPC(oPC) == TRUE && GetIsObjectValid(GetItemPossessedBy(oPC, sTag)) == FALSE)
    {
    	CreateItemOnObject(sResRef, oPC, 1, sTag);
    }
    
  • DrSaturnDrSaturn Member Posts: 5
    You may want to store a local variable on the PC to tell if they have already received the item. The code above will give them an item if they enter without one. It depends on what you want to achieve here.
    object oPC = GetEnteringObject(); 
    string sTag = "my_tag";
    string sResRef = "item_res_ref";
    
    if(GetLocalInt(oPC, "HAS_HAD_GIFT")){
      SetLocalInt(oPC, "HAS_HAD_GIFT", TRUE);
      CreateItemOnObject(sResRef, oPC, 1, sTag);
    }
    
    

    And you may want to do the GetIsPC check as above.
  • Ugly_DuckUgly_Duck Member Posts: 182
    Where do I put that code ??
  • meaglynmeaglyn Member Posts: 151
    You could put it in the oncliententer event. But... the PC may not be fully ready at that point and may not be in an area so it depends.
    Many people use a special starting area, which the PC gets teleported out of immediately. You could put in the onEnter event for that area. Or you could paint a trigger around your starting location and put it in the trigger onenter event.

Sign In or Register to comment.