This is off the top of my head:
UserWidget:
void MyUserWidget::OnClickedGoldButton( )
{
AMyPlayerController *MyController = Cast<AMyPlayerController>(GetOwningPlayer( ));
if(MyController)
{
MyController->AddGold( );
}
}
Player Controller:
void MyPlayerController:AddGold( )
{
// Assumption made here that AddGold will always be called by MyUserWidget, which is the client side
if(Role < ROLE_Authority)
{
ServerAddGold( );
}
}
bool MyPlayerController::ServerAddGold_Validate( )
{
return true;
}
void MyPlayerController::ServerAddGold_Implementation( )
{
Gold += 1;
}