// Main function
void main()
{
    // Send a message to the first PC that the script has started
    object oPC = GetFirstPC();
    SendMessageToPC(oPC, "Script started.");

    // Get the parameters from the event
    object oItem = GetEventParamObject(0);
    object oTarget = GetEventParamObject(1);
    object oUser = GetEventParamObject(2);

    // Debugging: check if we got the correct objects
    if (!GetIsObjectValid(oItem))
    {
        SendMessageToPC(oUser, "Invalid item object.");
    }
    else
    {
        SendMessageToPC(oUser, "oItem: " + GetName(oItem));
    }

    if (!GetIsObjectValid(oTarget))
    {
        SendMessageToPC(oUser, "Invalid target object.");
    }
    else
    {
        SendMessageToPC(oUser, "oTarget: " + GetName(oTarget));
    }

    if (!GetIsObjectValid(oUser))
    {
        SendMessageToPC(oPC, "Invalid user object.");
    }
    else
    {
        SendMessageToPC(oUser, "oUser: " + GetName(oUser));
    }

    // Get the location of the target
    if (GetIsObjectValid(oTarget))
    {
        location lTarget = GetLocation(oTarget);
        vector vTargetPosition = GetPosition(oTarget);
        SendMessageToPC(oUser, "Target location: " + VectorToString(vTargetPosition));

        // Create the red beam effect
        effect eBeam = EffectBeam(VFX_BEAM_FIRE, oUser, BODY_NODE_CHEST);
        ApplyEffectAtLocation(DURATION_TYPE_INSTANT, eBeam, lTarget);
        SendMessageToPC(oUser, "Beam effect applied at location: " + VectorToString(vTargetPosition));
    }
    else
    {
        SendMessageToPC(oUser, "Beam effect not applied. Target object is invalid.");
    }

    // Send a message to the first PC that the script has completed
    SendMessageToPC(oPC, "Script completed.");
}
