The idea was to have the script check for the surroundings and follow this rationale:
1) The script checks if the activating actor is a NPC or not. NPCs aren't allowed the choice to fill or pickup, but could only pickup.
2) Drinks are prioritized as "cow milk", "goat milk" and "water".
3) The script checks first if any reference with CowRace or GoatRace is around and, if it's so, it'll check which of these in order to give some units of either cow milk or goat milk.
4) The script checks if any viable water source (water activator or water movable static) is around, then will check if the water activator seem to be a source of "putrid water" (puddle, marsh,
etc...) from a FormList or if the Ocean floor statics are at more or less the distance as the water source...which would bring "salt water"...else "fresh water" is extracted.
5) If none of the above will apply, the script will giive a message suggesting the player to find a source of water or a source of milk.
In this script I've tried to use the "State", which seemed to be somewhat like the VBA "labels" and were a concept that I felt familiar...
...however...something has gone horribly wrong with the script, so, please, if anyone knowledgeable could point me out what's I've done wrong it'd be really appreciated...

Jashkar
"Scriptname BUABucketFillOrPickup extends ObjectReference
{This script allows to either pickup or fill a bucket with water (near a watersource) or milk (near a goat or cow)}
Message Property msgActivationMenu Auto
Message Property msgFillWaterNotification Auto
Message Property msgFillMilkNotification Auto
Message Property msgFillFailure Auto
Race Property rPrimaryMilkSource Auto
Race Property rSecondaryMilkSource Auto
FormList Property flWaterSources Auto
FormList Property flPutridWaterSources Auto
FormList Property flWaterLandmarks Auto
FormList Property flOceanFloor Auto
Potion[] Property ptWaterFound Auto
Potion[] Property ptMilkFound Auto
Event OnActivate(ObjectReference akActionRef)
bool bPlayerActivated
int iPlayerChoice = 0
int iWaterQuality = 0
float fWaterDistance
float fPutridWaterDistance
float fOceanDistance
if (akActionRef == !(game.GetPlayer()))
GotoState("NPCPickUp")
else
GotoState("SelectionMenu")
EndIf
state SelectionMenu
iPlayerChoice = msgActivationMenu.Show()
if (iPlayerChoice == 0)
ObjectReference.AddToContainer player 1
GotoState("CloseScript")
else
GotoState("CheckForSource")
EndIf
endState
state CheckForSource
ObjectReference orClosestCow = Game.FindClosestReferenceOfTypeFromRef(rPrimaryMilkSource, Game.GetPlayer(), 128.0)
ObjectReference orClosestGoat = Game.FindClosestReferenceOfTypeFromRef(rSecondaryMilkSource, Game.GetPlayer(), 128.0)
ObjectReference orClosestWaterSource = Game.FindClosestReferenceOfAnyTypeInListFromRef(flWaterSources, Game.GetPlayer(), 128.0)
ObjectReference orClosestWaterLandmark = Game.FindClosestReferenceOfAnyTypeInListFromRef(flWaterLandmarks, Game.GetPlayer(), 128.0)
ObjectReference orClosestPutridWaterSource = Game.FindClosestReferenceOfAnyTypeInListFromRef(flPutridWaterSources, Game.GetPlayer(), 128.0)
ObjectReference orClosestOceanFloor= Game.FindClosestReferenceOfAnyTypeInListFromRef(flOceanFloor, Game.GetPlayer(), 2560.0)
if ((orClosestCow != NONE) || (orClosestGoat!= NONE))
GotoState("ExtractMilk")
elseif orClosestWaterSource != NONE || orClosestWaterLandmark != NONE
GotoState("ExtractWater")
else
msgFillFailure.Show()
GotoState("CloseScript")
endif
endState
state ExtractMilk
msgFillMilkNotification.Show()
if orClosestCow != NONE
Player.Additem ptMilkFound[0] 6
else
Player.Additem ptMilkFound[1] 6
endif
GotoState("CloseScript")
endState
state ExtractWater
msgFillWaterNotification.Show()
if orClosestWaterSource == NONE
fWaterDistance = Game.GetPlayer().GetDistance(orClosestWaterLandmark)
else
fWaterDistance = Game.GetPlayer().GetDistance(orClosestWaterSource)
endif
if orClosestPutridWaterSource != NONE
fPutridWaterDistance = Game.GetPlayer().GetDistance(orClosestPutridWaterSource)
if fPutridWaterDistance > fWaterDistance
iWaterQuality += 1
EndIf
elseif orClosestOceanFloor != NONE
fOceanDistance = Game.GetPlayer().GetDistance(orClosestOceanFloor)
if fPutridWaterDistance > fWaterDistance
iWaterQuality += 1
EndIf
EndIf
Player.Additem ptWaterFound[iWaterQuality] 6
iWaterQuality = 0
GotoState("CloseScript")
endState
state NPCPickUp
ObjectReference.AddToContainer akActionRef 1
GotoState("CloseScript")
endState
state CloseScript
endState
EndEvent"
Errors
"Starting 1 compile threads for 1 files...
Compiling "BUABucketFillOrPickup"...
e:\giochi\steam\steamapps\common\skyrim\Data\Scripts\Source\temp\BUABucketFillOrPickup.psc(46,0): mismatched input 'state' expecting ENDEVENT
e:\giochi\steam\steamapps\common\skyrim\Data\Scripts\Source\temp\BUABucketFillOrPickup.psc(48,2): no viable alternative at input 'iPlayerChoice'
e:\giochi\steam\steamapps\common\skyrim\Data\Scripts\Source\temp\BUABucketFillOrPickup.psc(48,16): mismatched input '=' expecting LPAREN
e:\giochi\steam\steamapps\common\skyrim\Data\Scripts\Source\temp\BUABucketFillOrPickup.psc(0,0): error while attempting to read script BUABucketFillOrPickup: Reference to an object not set on an instance of object. [This was liberally translated as this blasted compiler seems to use my own language and English as it "feels like"!
]No output generated for BUABucketFillOrPickup, compilation failed.
Batch compile of 1 files finished. 0 succeeded, 1 failed.
Failed on BUABucketFillOrPickup"

