The following warnings occurred:
Warning [2] count(): Parameter must be an array or an object that implements Countable - Line: 906 - File: showthread.php PHP 7.2.24-0ubuntu0.18.04.17 (Linux)
File Line Function
/showthread.php 906 errorHandler->error



Facebook Twitter YouTube Frictional Games | Forum | Privacy Policy | Dev Blog | Dev Wiki | Support | Gametee


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Something Wrong with AddUseItemCallback?
AGP Offline
Senior Member

Posts: 448
Threads: 45
Joined: Dec 2012
Reputation: 23
#1
Something Wrong with AddUseItemCallback?

Honestly, I've been at this for hours and am at my wit's end.

I've checked and double-checked the names inside the level editor and in the hps. I've turned things off and on, restarted the game, I've no idea what's happening.

I found the script through some forum diving, and since in my mod there are three randomly spawning buckets, I had to change the name of the bucket used.

Where it had worked before with the original bucket, it now does nothing. I even tried putting back in the original bucket and turning off the other three, and STILL nothing.

I've tried doing them all separate callbacks and doing them all condensed with the integer, but still nothing is working.

Does anyone see anything that I'm missing?

void OnStart()
{
    string bucket = "bucket_"+RandInt(1, 3);
    string paint = "paint_"+RandInt(1, 3);
    string knife = "knife_"+RandInt(1, 3);
    SetEntityActive(bucket, true);
    SetEntityActive(paint, true);
    SetEntityActive(knife, true);
    
    for(int i=1;i<=2;i++)
    {
        InteractConnectPropWithRope("", "crank_wheel_1", "RopeArea_"+i, false, 1,1,1, false, 0);
    }
    
    SetLocalVarInt("RopeInArea", 0);
    SetLocalVarInt("BucketFilled", 0);

    for(int i = 1; i <= 4; i++)
    {
        AddUseItemCallback("ThisCrapNotWorking", "bucket_"+i, "RopeInteractArea_1", "UseBucketOnRope", false);
    }
    
    ///AddUseItemCallback("ThisCrapNotWorking", "bucket_1", "RopeInteractArea_1", "UseBucketOnRope", false);                                 <---
    ///AddUseItemCallback("ThisCrapNotWorking", "bucket_2", "RopeInteractArea_1", "UseBucketOnRope", false);                                <---
    ///AddUseItemCallback("ThisCrapNotWorking", "bucket_3", "RopeInteractArea_1", "UseBucketOnRope", false);                                <---
    AddEntityCollideCallback("RopeInteractArea_1", "invisible_box_mass_2_1", "CheckRopePosition", false, 0);
    AddEntityCollideCallback("AreaBottomWell", "invisible_box_mass_2_1", "RopeHitsBottomWell", false, 1);
}

void OnEnter()
{

}

void OnLeave()
{

}

///-------------------------------------------------------------------------------
///-------------------------------BUCKET & WELL-----------------------------------
///-------------------------------------------------------------------------------

void CheckRopePosition(string &in asParent, string &in asChild, int alState)
{
    if(alState == 1)
    {
        SetLocalVarInt("RopeInArea", 1);
        AddDebugMessage("Rope inside of Area", false);
    }
    else
    {
        SetLocalVarInt("RopeInArea", -1);
        AddDebugMessage("Rope out of Area", false);
    }
}

void UseBucketOnRope(string &in asItem, string &in asEntity)
{
    for(int i = 1; i <= 3; i++)
    {    if(asItem != "bucket_"+i)
        {
            AddDebugMessage("Item not the bucket, no interaction occurs.", false);
            return;
        }
    }

    if(GetLocalVarInt("RopeInArea") != 1)
    {
    SetMessage("", "", 0);
    AddDebugMessage("Rope outside of area, no interaction occurs.", false);
    return;
    }

    AddAttachedPropToProp("invisible_box_mass_2_1", "wooden_bucket_onrope_1", "wooden_bucket_onrope.ent", 0,0,0,0,0,0);
    RemoveItem(asItem);
    
    SetLocalVarInt("BucketOnRope", 1);
}

void RopeHitsBottomWell(string &in asParent, string &in asChild, int alState)
{
    if(GetLocalVarInt("BucketOnRope") == 0)
    {
        return;
    }
    
    PlaySoundAtEntity("WaterSplash","impact_water_med.snt", "AreaBottomWell", 0, false);
    
    if(GetLocalVarInt("BucketFilled") != 1)
    {
        RemoveAttachedPropFromProp("invisible_box_mass_2_1", "wooden_bucket_onrope_1");
        
        AddAttachedPropToProp("invisible_box_mass_2_1", "wooden_bucket_onrope_filled_1", "wooden_bucket_onrope_filled.ent", 0,0,0,0,0,0);
        
        SetEntityActive("RopeInteractArea_1", false);
        SetLocalVarInt("BucketFilled", 1);
        
        SetEntityCustomFocusCrossHair("invisible_box_mass_2_1","Pick");
        
        SetEntityPlayerInteractCallback("invisible_box_mass_2_1", "PickUpFilledBucket", true);
    }
}

void PickUpFilledBucket(string &in asEntity)
{
    SetLocalVarInt("BucketOnRope", 0);
    SetLocalVarInt("BucketFilled", 0);
    
    RemoveAttachedPropFromProp("invisible_box_mass_2_1", "wooden_bucket_onrope_filled_1");
    PlaySoundAtEntity("pickb", "25_pick_bucket_water.snt", "Player", 0.0f, false);
    GiveItemFromFile("wooden_bucket_filled_1", "wooden_bucket_filled.ent");
}

03-16-2018, 07:59 AM
Find


Messages In This Thread
Something Wrong with AddUseItemCallback? - by AGP - 03-16-2018, 07:59 AM



Users browsing this thread: 1 Guest(s)